### Install Azure AI SDKs Source: https://context7_llms Installs the necessary Python packages for interacting with Azure AI services, including projects, agents, and identity management. This is a prerequisite for using the Azure AI SDKs. ```bash pip install azure-ai-projects azure-ai-agents azure-identity ``` -------------------------------- ### Deploy Foundry Models using Azure CLI Source: https://context7_llms This snippet shows how to deploy Foundry Models using the Azure CLI. It assumes you have the Azure CLI installed and are logged in. ```bash az ml model create --file model-deployment.yml --resource-group YOUR_RESOURCE_GROUP --workspace-name YOUR_WORKSPACE_NAME ``` -------------------------------- ### Create Fine-tuning Job API Call (Python) Source: https://context7_llms Provides an example of initiating a fine-tuning job using the Azure OpenAI API with Python. This requires a previously uploaded file and a base model. The 'openai' library and Azure credentials are necessary. ```python from openai import AzureOpenAI client = AzureOpenAI( api_key="YOUR_API_KEY", api_version="2023-05-15", azure_endpoint="https://YOUR_AZURE_OPENAI_ENDPOINT.openai.azure.com" ) response = client.fine_tuning.jobs.create( training_file="FILE_ID", # The ID of the file uploaded previously model="YOUR_BASE_MODEL" # e.g., "gpt-35-turbo-0613" ) print(response.id) ``` -------------------------------- ### Create File Upload API Call (Python) Source: https://context7_llms Illustrates how to upload a file to Azure OpenAI using the Python SDK. This is often a prerequisite for fine-tuning models. Ensure you have the 'openai' library installed and your Azure credentials configured. ```python from openai import AzureOpenAI client = AzureOpenAI( api_key="YOUR_API_KEY", api_version="2023-05-15", azure_endpoint="https://YOUR_AZURE_OPENAI_ENDPOINT.openai.azure.com" ) with open("path/to/your/file.jsonl", "rb") as f: response = client.files.create( file=f, purpose='fine-tune' ) print(response.id) ``` -------------------------------- ### Create Chat Completion API Call (Node.js) Source: https://context7_llms Shows how to create a chat completion using the Azure OpenAI API with Node.js. This example utilizes the '@azure/openai' package and requires your Azure OpenAI endpoint and API key. ```javascript const { OpenAIClient, AzureKeyCredential } = require("@azure/openai"); const endpoint = "https://YOUR_AZURE_OPENAI_ENDPOINT.openai.azure.com"; const azureApiKey = "YOUR_API_KEY"; const client = new OpenAIClient(endpoint, new AzureKeyCredential(azureApiKey)); async function main() { const deploymentName = "YOUR_DEPLOYMENT_NAME"; // e.g., gpt-35-turbo const result = await client.getChatCompletions(deploymentName, [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "What is the capital of France?" }, ]); console.log(`Chat completion result: ${result.choices[0].message.content}`); } main().catch((err) => { console.error("The sample encountered an error", err); process.exit(1); }); ``` -------------------------------- ### Create Embedding API Call (Node.js) Source: https://context7_llms Demonstrates how to generate text embeddings using the Azure OpenAI API with Node.js. This example uses the '@azure/openai' package and requires your Azure OpenAI endpoint and API key. ```javascript const { OpenAIClient, AzureKeyCredential } = require("@azure/openai"); const endpoint = "https://YOUR_AZURE_OPENAI_ENDPOINT.openai.azure.com"; const azureApiKey = "YOUR_API_KEY"; const client = new OpenAIClient(endpoint, new AzureKeyCredential(azureApiKey)); async function main() { const deploymentName = "YOUR_EMBEDDING_DEPLOYMENT_NAME"; // e.g., text-embedding-ada-002 const result = await client.getEmbeddings(deploymentName, [ "This is a sample text to get embeddings for." ]); console.log("Embeddings: ", result.data[0].embedding); } main().catch((err) => { console.error("The sample encountered an error", err); process.exit(1); }); ``` -------------------------------- ### List Models API Call (Python) Source: https://context7_llms Demonstrates how to list available models using the Azure OpenAI API with Python. This is useful for understanding which models are accessible for your deployment. Requires the 'openai' library and Azure credentials. ```python from openai import AzureOpenAI client = AzureOpenAI( api_key="YOUR_API_KEY", api_version="2023-05-15", azure_endpoint="https://YOUR_AZURE_OPENAI_ENDPOINT.openai.azure.com" ) response = client.models.list() for model in response.data: print(model.id) ``` -------------------------------- ### Python Authentication Pattern for Azure AI Projects Source: https://context7_llms Demonstrates how to authenticate with Azure AI services using `DefaultAzureCredential` and initialize an `AIProjectClient`. This pattern is essential for programmatically accessing and managing Azure AI projects. ```python from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient credential = DefaultAzureCredential() client = AIProjectClient( endpoint="https://.services.ai.azure.com/api/projects/", credential=credential ) ``` -------------------------------- ### Create Chat Completion API Call (Python) Source: https://context7_llms Demonstrates how to create a chat completion using the Azure OpenAI API with Python. This snippet requires the 'openai' library and an Azure OpenAI endpoint and key. ```python from openai import AzureOpenAI client = AzureOpenAI( api_key="YOUR_API_KEY", api_version="2023-05-15", azure_endpoint="https://YOUR_AZURE_OPENAI_ENDPOINT.openai.azure.com" ) response = client.chat.completions.create( model="YOUR_DEPLOYMENT_NAME", # e.g., gpt-35-turbo messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"}, {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."} ] ) print(response.choices[0].message.content) ``` -------------------------------- ### Agent Skills and Workflows Source: https://context7_llms This section covers how to use function calling, set up and use agent workflows in Visual Studio Code, and manage agent resources. ```APIDOC ## Function Calling ### Description Learn how to enable function calling for your agents to interact with external tools and services. ### Method N/A (Conceptual) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Declarative Agent Workflows in VS Code ### Description Utilize the Visual Studio Code extension to create and manage agent workflows using a low-code approach. ### Method N/A (VS Code Extension Feature) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Hosted Agent Workflows in VS Code ### Description Leverage the Visual Studio Code extension for pro-code development and management of hosted agent workflows. ### Method N/A (VS Code Extension Feature) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Agent Resource Setup ### Description Guides on setting up the necessary Azure resources for your AI agents. ### Method N/A (Configuration) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Standard Agent Setup ### Description Information on the standard configuration and setup for AI agents within Azure AI Foundry. ### Method N/A (Conceptual) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Using Your Own Azure Resources ### Description Instructions on how to integrate your existing Azure resources with Azure AI Foundry agents. ### Method N/A (Configuration) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Migrating Agents ### Description Guidance on migrating existing agents to Azure AI Foundry. ### Method N/A (Process Guide) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Virtual Networks ### Description Information on configuring and utilizing virtual networks for your AI agents. ### Method N/A (Configuration) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## AI Gateway ### Description Details on how to use and configure the AI Gateway for managing agent interactions. ### Method N/A (Conceptual/Configuration) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Managing Grounding with Bing ### Description Learn how to manage and configure grounding capabilities using Bing search within your agents. ### Method N/A (Configuration) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Deploy Foundry Models using Python SDK Source: https://context7_llms This snippet demonstrates how to deploy Foundry Models using the Azure SDK for Python. It requires the 'azure-ai-ml' package and an Azure ML workspace. ```python from azure.ai.ml import MLClient from azure.ai.ml.entities import Model, ModelVersion from azure.identity import DefaultAzureCredential # Authenticate and get ML client credential = DefaultAzureCredential() ml_client = MLClient(credential, subscription_id="YOUR_SUBSCRIPTION_ID", resource_group_name="YOUR_RESOURCE_GROUP", workspace_name="YOUR_WORKSPACE_NAME") # Define model details model_name = "your-model-name" model_path = "azureml://registries/azureml/models/llama-2-13b-chat/versions/1" # Create a Model entity model = Model(path=model_path, name=model_name) # Register the model ml_client.models.create_or_update(model) ``` -------------------------------- ### Configure Keyless Authentication for Foundry Models Source: https://context7_llms This snippet demonstrates how to configure keyless authentication for Foundry Models using Azure Active Directory (now Microsoft Entra ID). It involves setting up a service principal and granting it necessary permissions. ```bash # Create a service principal az ad sp create-for-rbac --name "FoundryModelSP" --role contributor --scopes /subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/YOUR_RESOURCE_GROUP # Get the service principal details # az ad sp list --display-name "FoundryModelSP" --query "[].appId" -o tsv # az ad sp list --display-name "FoundryModelSP" --query "[].password" -o tsv # If using a secret instead of certificate ``` -------------------------------- ### Foundry Models Source: https://context7_llms This section details the different types of Foundry Models available, including those sold directly by Azure and from partners, model versions, deployment options, and monitoring. ```APIDOC ## Foundry Models Sold Directly by Azure ### Description Information on large language models offered directly by Azure within the Foundry Models ecosystem. ### Method N/A (Conceptual) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Foundry Models from Partners and Community ### Description Details about accessing and utilizing Foundry Models provided by third-party partners and the community. ### Method N/A (Conceptual) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Model Versions ### Description Information regarding the different versions of models available within Azure AI Foundry. ### Method N/A (Conceptual) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Marketplace Configuration for Partner Models ### Description Guides on configuring the marketplace to discover and use partner models. ### Method N/A (Configuration) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## GPT-5 vs GPT-4.1 Model Choice Guide ### Description A guide to help you choose between GPT-5 and GPT-4.1 models based on your needs. ### Method N/A (Guidance) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## What's New in Model Router ### Description Updates and new features related to the Model Router in Azure AI Foundry. ### Method N/A (Information) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Responses API with Foundry Models ### Description Learn how to use the Responses API to generate responses from Foundry Models. ### Method N/A (API Usage) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Deploy Foundry Models in the Portal ### Description Instructions for deploying Foundry Models using the Azure portal. ### Method N/A (Portal Operation) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Deploy Foundry Models using Code ### Description Guidance on programmatically deploying Foundry Models using code. ### Method N/A (Code Deployment) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Deployment Types ### Description Overview of the different types of model deployments available in Azure AI Foundry. ### Method N/A (Conceptual) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Upgrade GitHub Models to Foundry Models ### Description Instructions for migrating or upgrading models from GitHub repositories to Foundry Models. ### Method N/A (Migration Guide) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Claude in Foundry Models ### Description Information on how to use Claude models within the Azure AI Foundry environment. ### Method N/A (Usage Guide) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Monitor Model Deployments ### Description Guidance on monitoring the performance and health of your deployed Foundry Models. ### Method N/A (Monitoring Guide) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Endpoints for Foundry Models ### Description Details about the endpoints provided for accessing and interacting with Foundry Models. ### Method N/A (Conceptual) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Get Started with DeepSeek-R1 Reasoning Model ### Description A tutorial to help you begin using the DeepSeek-R1 reasoning model. ### Method N/A (Tutorial) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Foundry Models Quotas and Limits ### Description Information on the quotas and limits applicable to Foundry Models deployments and usage. ### Method N/A (Information) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Configure Keyless Authentication ### Description Instructions for setting up keyless authentication (e.g., using Azure AD) for Foundry Models. ### Method N/A (Configuration) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ``` -------------------------------- ### Files API Source: https://context7_llms Manage files for use with the API, such as uploading training data for fine-tuning. ```APIDOC ## POST /v1/files ### Description Uploads a file that can be used for various purposes, such as fine-tuning. ### Method POST ### Endpoint /v1/files ### Parameters #### Query Parameters - **api-key** (string) - Required - Your Azure OpenAI API key. - **api-version** (string) - Required - The version of the API to use. #### Request Body - **file** (file) - Required - The file to upload. - **purpose** (string) - Required - The intended use of the file (e.g., 'fine-tune'). ### Response #### Success Response (200) - **id** (string) - Unique identifier for the file. - **object** (string) - Type of object, e.g., 'file'. - **bytes** (integer) - File size in bytes. - **created_at** (integer) - Unix timestamp of when the file was created. - **filename** (string) - The name of the file. - **purpose** (string) - The purpose of the file. #### Response Example ```json { "id": "file-abc123xyz", "object": "file", "bytes": 1024, "created_at": 1677652288, "filename": "training_data.jsonl", "purpose": "fine-tune" } ``` ``` -------------------------------- ### Chat Completions API Source: https://context7_llms Create chat completions for conversational AI models. This endpoint allows for generating responses in a chat format. ```APIDOC ## POST /v1/chat/completions ### Description Creates a completion for the chat message ### Method POST ### Endpoint /v1/chat/completions ### Parameters #### Query Parameters - **api-key** (string) - Required - Your Azure OpenAI API key. - **api-version** (string) - Required - The version of the API to use. #### Request Body - **model** (string) - Required - The name of the model to use for generation. - **messages** (array) - Required - A list of messages comprising the conversation. - **temperature** (number) - Optional - Controls randomness. Lower values make the output more focused and deterministic. - **top_p** (number) - Optional - Controls diversity via nucleus sampling. Lower values mean the model considers only the most probable tokens. - **n** (integer) - Optional - How many chat completion choices to generate for each input message. - **stream** (boolean) - Optional - Whether to stream back partial message deltas as they are generated. - **stop** (string or array) - Optional - Up to 4 sequences where the API will stop generating further tokens. - **max_tokens** (integer) - Optional - The maximum number of tokens to generate in the completion. - **presence_penalty** (number) - Optional - Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. - **frequency_penalty** (number) - Optional - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. - **logit_bias** (object) - Optional - A map of token IDs to be overridden with new probabilities. ### Request Example ```json { "model": "gpt-4", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"} ] } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the completion. - **object** (string) - Type of object returned, e.g., 'chat.completion'. - **created** (integer) - Unix timestamp of when the completion was created. - **model** (string) - The model used for the completion. - **choices** (array) - A list of completion choices. - **index** (integer) - Index of the choice. - **message** (object) - The message content. - **role** (string) - Role of the author, e.g., 'assistant'. - **content** (string) - The content of the message. - **finish_reason** (string) - The reason the model stopped generating tokens. - **usage** (object) - Usage statistics for the completion. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **completion_tokens** (integer) - Number of tokens in the completion. - **total_tokens** (integer) - Total tokens used. #### Response Example ```json { "id": "chatcmpl-123", "object": "chat.completion", "created": 1677652288, "model": "gpt-4", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020." }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 15, "total_tokens": 25 } } ``` ``` -------------------------------- ### Create Embedding API Call (Python) Source: https://context7_llms Shows how to generate embeddings for text using the Azure OpenAI API with Python. This requires the 'openai' library and valid Azure OpenAI credentials. ```python from openai import AzureOpenAI client = AzureOpenAI( api_key="YOUR_API_KEY", api_version="2023-05-15", azure_endpoint="https://YOUR_AZURE_OPENAI_ENDPOINT.openai.azure.com" ) response = client.embeddings.create( input="Your text string goes here", model="YOUR_EMBEDDING_DEPLOYMENT_NAME" # e.g., text-embedding-ada-002 ) print(response.data[0].embedding) ``` -------------------------------- ### Fine-tuning API Source: https://context7_llms Manage and create fine-tuning jobs for models. This allows you to customize models with your own data. ```APIDOC ## POST /v1/fine_tuning/jobs ### Description Creates a fine-tuning job to customize a base model with your data. ### Method POST ### Endpoint /v1/fine_tuning/jobs ### Parameters #### Query Parameters - **api-key** (string) - Required - Your Azure OpenAI API key. - **api-version** (string) - Required - The version of the API to use. #### Request Body - **training_file** (string) - Required - The ID of the training data file. - **model** (string) - Required - The base model to fine-tune (e.g., 'gpt-3.5-turbo'). - **hyperparameters** (object) - Optional - Hyperparameters for the fine-tuning job. - **n_epochs** (integer) - Optional - Number of epochs to train for. - **suffix** (string) - Optional - A string to append to the fine-tuned model name. ### Request Example ```json { "training_file": "file-abc123xyz", "model": "gpt-3.5-turbo", "suffix": "my-custom-model" } ``` ### Response #### Success Response (200) - **id** (string) - Unique identifier for the fine-tuning job. - **object** (string) - Type of object, e.g., 'fine_tuning.job'. - **created_at** (integer) - Unix timestamp of when the job was created. - **model** (string) - The base model used for fine-tuning. - **fine_tuned_model** (string or null) - The name of the fine-tuned model if the job is completed. - **status** (string) - The status of the job (e.g., 'validating_files', 'queued', 'running', 'succeeded', 'failed'). - **error** (object or null) - Error details if the job failed. #### Response Example ```json { "id": "ftjob-abc123xyz", "object": "fine_tuning.job", "created_at": 1677652288, "model": "gpt-3.5-turbo", "fine_tuned_model": null, "status": "queued", "error": null } ``` ``` -------------------------------- ### Models API Source: https://context7_llms List available models. This endpoint provides information about the models accessible through the API. ```APIDOC ## GET /v1/models ### Description Lists the models available for use. ### Method GET ### Endpoint /v1/models ### Parameters #### Query Parameters - **api-key** (string) - Required - Your Azure OpenAI API key. - **api-version** (string) - Required - The version of the API to use. ### Response #### Success Response (200) - **object** (string) - Type of object, e.g., 'list'. - **data** (array) - A list of model objects. - **id** (string) - The unique identifier for the model. - **object** (string) - Type of object, e.g., 'model'. - **created** (integer) - Unix timestamp of when the model was created. - **owned_by** (string) - The entity that owns the model. #### Response Example ```json { "object": "list", "data": [ { "id": "gpt-4", "object": "model", "created": 1686936000, "owned_by": "openai" }, { "id": "gpt-3.5-turbo", "object": "model", "created": 1677610602, "owned_by": "openai" } ] } ``` ``` -------------------------------- ### Embeddings API Source: https://context7_llms Create embeddings for text. This endpoint is used to generate vector representations of text for tasks like search and clustering. ```APIDOC ## POST /v1/embeddings ### Description Creates an embedding vector for the provided input text. ### Method POST ### Endpoint /v1/embeddings ### Parameters #### Query Parameters - **api-key** (string) - Required - Your Azure OpenAI API key. - **api-version** (string) - Required - The version of the API to use. #### Request Body - **model** (string) - Required - The name of the model to use for generating embeddings. - **input** (string or array) - Required - The input text or list of texts to embed. - **encoding_format** (string) - Optional - The format of the embeddings. Supported values are `float` and `base64`. ### Request Example ```json { "model": "text-embedding-ada-002", "input": "The quick brown fox jumps over the lazy dog." } ``` ### Response #### Success Response (200) - **object** (string) - Type of object returned, e.g., 'list'. - **data** (array) - A list of embedding objects. - **object** (string) - Type of object, e.g., 'embedding'. - **embedding** (array) - The embedding vector. - **index** (integer) - The index of the input text. - **model** (string) - The model used for generating embeddings. - **usage** (object) - Usage statistics. - **prompt_tokens** (integer) - Number of tokens in the prompt. - **total_tokens** (integer) - Total tokens used. #### Response Example ```json { "object": "list", "data": [ { "object": "embedding", "embedding": [ 0.0023064255, -0.009327292, -0.0028841185, // ... more dimensions ], "index": 0 } ], "model": "text-embedding-ada-002", "usage": { "prompt_tokens": 8, "total_tokens": 8 } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.