Edit

Share via


Azure AI Foundry SDK client libraries

The Azure AI Foundry SDK is a comprehensive toolchain designed to simplify the development of AI applications on Azure. It enables developers to:

  • Access popular models from various model providers through a single interface
  • Easily combine together models, data, and AI services to build AI-powered applications
  • Evaluate, debug, and improve application quality & safety across development, testing, and production environments

The Azure AI Foundry SDK is a set of client libraries and services designed to work together.

Note

This article applies to a Foundry project. The code shown here doesn't work for a hub based project. For more information, see Types of projects.

Prerequisites

  • An Azure subscription. If you don't have one, create a free account.

  • Create a Foundry project if you don't have one already.

  • Sign in with the Azure CLI using the same account that you use to access your project:

    az login
    

Important

Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don't recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.

Unified Projects client library

The Azure AI Foundry Projects client library is a unified library that enables you to use multiple client libraries together by connecting to a single project endpoint.

  • Install the project client library

    pip install azure-ai-projects azure-ai-identity
    
  • Create a project client in code. Copy the Azure AI Foundry project endpoint from the Overview page of the project and update the connections string value.

    from azure.identity import DefaultAzureCredential
    from azure.ai.projects import AIProjectClient
    
    project = AIProjectClient.from_connection_string(
      endpoint="your_project_endpoint",  # Replace with your endpoint
      credential=DefaultAzureCredential())
    
  • Add these packages to your installation (preview):

    • com.azure.ai.projects
    • com.azure.core
  • Create a project client in code. Copy the Azure AI Foundry project endpoint from the Overview page of the project and update the connections string value.

    import com.azure.ai.projects.ProjectsClient;
    import com.azure.ai.projects.ProjectsClientBuilder;
    import com.azure.core.credential.AzureKeyCredential;
    
    String endpoint ="your_project_endpoint"; // Replace with your endpoint
    
    ProjectsClient projectClient = new ProjectsClientBuilder()
        .credential(new DefaultAzureCredential())
        .endpoint(endpoint)
        .buildClient();
    
  • Install dependencies (preview):

    npm install @azure/ai-projects @azure/identity
    
  • Create a project client in code. Copy the Azure AI Foundry project endpoint from the Overview page of the project and update the connections string value.

    import { AIProjectClient } from '@azure/ai-projects';
    import { DefaultAzureCredential } from '@azure/identity';
    
    const endpoint = "your_project_endpoint"; // Replace with your actual endpoint
    const project = new AIProjectClient(endpoint, new DefaultAzureCredential());
    
  • Install packages:

    dotnet add package Azure.Identity
    dotnet add package Azure.Core
    dotnet add package Azure.AI.Inference
    
  • Create a project client in code. Copy the Azure AI Foundry project endpoint from the Overview page of the project and update the connections string value.

    using Azure;
    using Azure.Identity;
    using Azure.AI.Inference;
    using Azure.Core;
    using Azure.Core.Pipeline;
    
    var endpointUrl = "your_project_endpoint"; // Replace with your actual endpoint
    var credential = new DefaultAzureCredential();
    
    AzureAIInferenceClientOptions clientOptions = new AzureAIInferenceClientOptions();
    BearerTokenAuthenticationPolicy tokenPolicy = new BearerTokenAuthenticationPolicy(
        credential, 
        new string[] { "https://cognitiveservices.azure.com/.default" }
    );
    clientOptions.AddPolicy(tokenPolicy, HttpPipelinePosition.PerRetry);
    
    var projectClient = new ChatCompletionsClient(
        endpointUrl, 
        credential,
        clientOptions
    );
    

Azure AI Services client libraries

To use Azure AI services, you can use the following client libraries with the endpoints listed on the project homepage.

C# supported services

Service Description Reference documentation
Speech icon Speech Add speech to text, text to speech, translation, and speaker recognition capabilities to applications. • Speech SDK for .NET

• Speech NuGet package (Speech CLI)
Content Safety icon Content Safety Detect harmful content in applications and services. • Content Safety SDK for .NET

• Content Safety NuGet package
Vision icon Vision Analyze content in digital images and rich media assets. • Vision SDK for .NET

• Vision NuGet package
Language icon Language Build applications with natural language understanding capabilities. • Language SDK for .NET (text analysis)

• Language NuGet package (text analysis)

• Language SDK for .NET (Question Answering)

• Language NuGet package (question answering)
Translator icon Translator Use AI-powered translation technology to translate more than 100 in-use, at-risk, and endangered languages and dialects. • Translator SDK for .NET (text)

• Translator NuGet package (text)

• Translator SDK for .NET (batch)

• Translator NuGet package (batch)
Document Intelligence icon Document Intelligence Turn documents into intelligent data-driven solutions. • Document Intelligence SDK for .NET

• Document Intelligence NuGet package
Azure AI Search icon Azure AI Search Bring AI-powered cloud search to your mobile and web apps. • Azure AI Search SDK for .NET

• Azure AI Search NuGet package

Java supported services

Service Description Reference documentation
Speech icon Speech Add speech to text, text to speech, translation, and speaker recognition capabilities to applications. • Speech SDK for Java

• Speech Maven package
Content Safety icon Content Safety Detect harmful content in applications and services. • Content Safety SDK for Java

• Content Safety Maven package
Vision icon [Vision]../../../ai-services/computer-vision/index.yml) Analyze content in digital images and rich media assets. • Vision SDK for Java

• Vision Maven package
Language icon Language Build applications with natural language understanding capabilities. • Language SDK for Java (text analysis)

• Language Maven package
Translator icon Translator Use AI-powered translation technology to translate more than 100 in-use, at-risk, and endangered languages and dialects. • Translator SDK for Java (text)

• Translator Maven package (text)
Document Intelligence icon Document Intelligence Turn documents into intelligent data-driven solutions. • Document Intelligence SDK for Java

• Document Intelligence Maven package
Azure AI Search icon Azure AI Search Bring AI-powered cloud search to your mobile and web apps. • Azure AI Search SDK for Java

• Azure AI Search Maven package

JavaScript Supported Services

Service Description Reference documentation
Speech icon Speech Add speech to text, text to speech, translation, and speaker recognition capabilities to applications. • Speech SDK for JavaScript

• Speech npm package
Content Safety icon Content Safety Detect harmful content in applications and services. • Content Safety SDK for JavaScript

• Content Safety npm package
Vision icon Vision Analyze content in digital images and rich media assets. • Vision SDK for JavaScript

• Vision npm package
Language icon Language Build applications with natural language understanding capabilities. • Language SDK for JavaScript (text analysis)

• Language npm package
Translator icon Translator Use AI-powered translation technology to translate more than 100 in-use, at-risk, and endangered languages and dialects. • Translator SDK for JavaScript (text)

• Translator npm package (text)
Document Intelligence icon Document Intelligence Turn documents into intelligent data-driven solutions. • Document Intelligence SDK for JavaScript

• Document Intelligence npm package
Azure AI Search icon Azure AI Search Bring AI-powered cloud search to your mobile and web apps. • Azure AI Search SDK for JavaScript

• Azure AI Search npm package

Python supported services

Service Description Reference documentation
Speech icon Speech Add speech to text, text to speech, translation, and speaker recognition capabilities to applications. • Speech SDK for Python

• Speech PyPi package
Content Safety icon Content Safety Detect harmful content in applications and services. • Content Safety SDK for Python

• Content Safety PyPi package
Vision icon Vision Analyze content in digital images and rich media assets. • Vision SDK for Python

• Vision PyPi package
Language icon Language Build applications with natural language understanding capabilities. • Language SDK for Python (text analysis)

• Language PyPi package (text analysis)

• Language SDK for Python (question answering)

• Language PyPi package (question answering)

• Language SDK for Python (language conversations)

• Language PyPi package (language conversations)
Translator icon Translator Use AI-powered translation technology to translate more than 100 in-use, at-risk, and endangered languages and dialects. • Translator SDK for Python (text)

• Translator PyPi package (text)

• Translator SDK for Python (batch)

• Translator PyPi package (batch)
Document Intelligence icon Document Intelligence Turn documents into intelligent data-driven solutions. • Document Intelligence SDK for Python

• Document Intelligence PyPi package
Azure AI Search icon Azure AI Search Bring AI-powered cloud search to your mobile and web apps. • Azure AI Search SDK for Python

• Azure AI Search PyPi package