> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Foundry integration

> Deploy Baseten-powered models in Microsoft Foundry and call them with Azure authentication and billing.

Deploy Baseten-powered models from the Microsoft Foundry catalog and call them from your application. Azure handles authentication and billing.

Baseten on Microsoft Foundry is in public preview. [Request preview access](https://aka.ms/Baseten-Preview-Request) if your organization needs access.

## Prerequisites

* An active Azure subscription.
* A [Microsoft Foundry resource and project](https://learn.microsoft.com/en-us/azure/foundry/how-to/create-projects).
* The **Cognitive Services Contributor** role or equivalent permissions on the Foundry resource. See Microsoft's [deployment prerequisites](https://learn.microsoft.com/en-us/azure/foundry/foundry-models/how-to/deploy-foundry-models#prerequisites).

## Deploy a model

1. Open your project in [Microsoft Foundry](https://ai.azure.com/).
2. Go to **Build** > **Catalog** > **Model Catalog** and open the Baseten entry for a model such as GLM-5.3. Check the available deployment types and regions on its model card.
3. Select **Deploy** > **Custom settings** and enter a deployment name.
4. Choose **Global Standard** for global processing or **Data Zone Standard** to keep processing in the United States data zone, where the model supports it. Both types bill per token.
5. Select **Deploy**, then go to **Build** > **Models** and confirm the deployment status shows **Succeeded**.

## Call a deployment

Use `https://<FOUNDRY_RESOURCE_NAME>.services.ai.azure.com/openai/v1/` as your base URL. Replace `<FOUNDRY_RESOURCE_NAME>` with your Foundry resource name and set `<DEPLOYMENT_NAME>` to the name you chose when you deployed the model.

Send a Chat Completions request with a Foundry resource key for a quick test, or use [Microsoft Entra ID](#microsoft-entra-id) to control access through Azure role assignments.

### Resource key

In the Azure portal, open the Foundry resource in your base URL and select **Keys and Endpoint**. Replace `<FOUNDRY_API_KEY>` with a key from that resource.

```bash theme={"system"}
export AZURE_INFERENCE_CREDENTIAL="<FOUNDRY_API_KEY>"
```

> [tab] Python
>
> Install the OpenAI SDK with `pip install openai`. Save this example as `chat.py` and run `python chat.py`.
>
> ```python chat.py theme={"system"}
> import os
> from openai import OpenAI
>
> client = OpenAI(
>     base_url="https://<FOUNDRY_RESOURCE_NAME>.services.ai.azure.com/openai/v1/",
>     api_key=os.environ["AZURE_INFERENCE_CREDENTIAL"],
> )
>
> response = client.chat.completions.create(
>     model="<DEPLOYMENT_NAME>",
>     messages=[
>         {"role": "user", "content": "Explain inference optimization in one paragraph."}
>     ],
> )
>
> print(response.choices[0].message.content)
> ```

> [tab] JavaScript
>
> Install the OpenAI SDK with `npm install openai`. Save this example as `chat.mjs` and run `node chat.mjs`.
>
> ```javascript chat.mjs theme={"system"}
> import OpenAI from "openai";
>
> const client = new OpenAI({
>   baseURL: "https://<FOUNDRY_RESOURCE_NAME>.services.ai.azure.com/openai/v1/",
>   apiKey: process.env.AZURE_INFERENCE_CREDENTIAL,
> });
>
> const response = await client.chat.completions.create({
>   model: "<DEPLOYMENT_NAME>",
>   messages: [
>     { role: "user", content: "Explain inference optimization in one paragraph." },
>   ],
> });
>
> console.log(response.choices[0].message.content);
> ```

> [tab] cURL
>
> Run this command to call your deployment.
>
> ```bash theme={"system"}
> curl "https://<FOUNDRY_RESOURCE_NAME>.services.ai.azure.com/openai/v1/chat/completions" \
>   -H "Content-Type: application/json" \
>   -H "Authorization: Bearer $AZURE_INFERENCE_CREDENTIAL" \
>   -d '{
>     "model": "<DEPLOYMENT_NAME>",
>     "messages": [
>       {"role": "user", "content": "Explain inference optimization in one paragraph."}
>     ]
>   }'
> ```

### Microsoft Entra ID

[Configure Microsoft Entra ID on your Foundry resource](https://learn.microsoft.com/en-us/azure/foundry/foundry-models/how-to/configure-entra-id) and assign each caller the **Cognitive Services User** role on the resource. Sign in to the Azure CLI with `az login` to run the examples locally. Request tokens with the `https://ai.azure.com/.default` scope.

> [tab] Python
>
> Install the dependencies with `pip install openai azure-identity`. Save this example as `entra.py` and run `python entra.py`.
>
> ```python entra.py theme={"system"}
> from azure.identity import DefaultAzureCredential, get_bearer_token_provider
> from openai import OpenAI
>
> token_provider = get_bearer_token_provider(
>     DefaultAzureCredential(),
>     "https://ai.azure.com/.default",
> )
>
> client = OpenAI(
>     base_url="https://<FOUNDRY_RESOURCE_NAME>.services.ai.azure.com/openai/v1/",
>     api_key=token_provider,
> )
>
> response = client.chat.completions.create(
>     model="<DEPLOYMENT_NAME>",
>     messages=[
>         {"role": "user", "content": "Explain inference optimization in one paragraph."}
>     ],
> )
>
> print(response.choices[0].message.content)
> ```

> [tab] JavaScript
>
> Install the dependencies with `npm install openai @azure/identity`. Save this example as `entra.mjs` and run `node entra.mjs`.
>
> ```javascript entra.mjs theme={"system"}
> import { DefaultAzureCredential, getBearerTokenProvider } from "@azure/identity";
> import OpenAI from "openai";
>
> const tokenProvider = getBearerTokenProvider(
>   new DefaultAzureCredential(),
>   "https://ai.azure.com/.default",
> );
>
> const client = new OpenAI({
>   baseURL: "https://<FOUNDRY_RESOURCE_NAME>.services.ai.azure.com/openai/v1/",
>   apiKey: tokenProvider,
> });
>
> const response = await client.chat.completions.create({
>   model: "<DEPLOYMENT_NAME>",
>   messages: [
>     { role: "user", content: "Explain inference optimization in one paragraph." },
>   ],
> });
>
> console.log(response.choices[0].message.content);
> ```

> [tab] cURL
>
> 1. Set `AZURE_OPENAI_AUTH_TOKEN` to your Azure access token.
>
>    ```bash theme={"system"}
>    export AZURE_OPENAI_AUTH_TOKEN="$(az account get-access-token --resource https://ai.azure.com --query accessToken --output tsv)"
>    ```
>
> 2. Send a Chat Completions request with the token.
>
>    ```bash theme={"system"}
>    curl "https://<FOUNDRY_RESOURCE_NAME>.services.ai.azure.com/openai/v1/chat/completions" \
>      -H "Content-Type: application/json" \
>      -H "Authorization: Bearer $AZURE_OPENAI_AUTH_TOKEN" \
>      -d '{
>        "model": "<DEPLOYMENT_NAME>",
>        "messages": [
>          {"role": "user", "content": "Explain inference optimization in one paragraph."}
>        ]
>      }'
>    ```

A successful request returns HTTP `200`. The SDK examples print the model's answer. In the cURL response, the answer is in `choices[0].message.content`.

## Control model access

Use [Azure Policy for model deployment](https://learn.microsoft.com/en-us/azure/foundry/how-to/model-deployment-policy) to control which models your organization can deploy.

## Billing

Azure bills Foundry usage under your Microsoft agreement. Open the model card in Foundry for pricing. If you have a Microsoft Azure Consumption Commitment (MACC), [track eligible usage in Azure Cost Management](https://learn.microsoft.com/en-us/azure/cost-management-billing/benefits/macc/track-consumption-commitment).

## Delete a deployment

Deleting a deployment removes its inference endpoint.

1. In your Foundry project, go to **Build** > **Models**.
2. Select the deployment, choose **Delete**, and confirm.
3. Check that the deployment no longer appears under **Models**.

## Troubleshoot the integration

| Issue | Resolution |
| - | - |
| Baseten-powered models don't appear in the catalog | [Request preview access](https://aka.ms/Baseten-Preview-Request) if your organization still needs it. |
| You can't create a deployment | Verify that you have the **Cognitive Services Contributor** role or equivalent permissions on the Foundry resource. |
| Deployment fails with a quota error | Check the available quota for the model and deployment type in the region you selected. See Microsoft's [quota guidance](https://learn.microsoft.com/en-us/azure/foundry/foundry-models/quotas-limits) to request an increase. |
| Requests return `401` or `403` | Use a key from the Foundry resource in your base URL. For Microsoft Entra ID, check the **Cognitive Services User** role assignment and request a token for `https://ai.azure.com/.default`. |
| Requests return `404` | Check that the base URL names the correct Foundry resource and includes `/openai/v1/`. Set `model` to the deployment name shown under **Models**. |
| A Responses API request stops at 4,096 output tokens | Use Chat Completions for requests that need longer answers. |

If the issue persists, [open an Azure support request](https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request). Include the model, deployment type, Azure region, error message, and request time. Exclude API keys and sensitive prompts.
