Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Build custom Copilot extensions and AI agents using the Azure-hosted GitHub Copilot SDK
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/azure-model-config.md
1# Model Configuration23Three model paths for the Copilot SDK. Each session needs different configuration.45## Path 1: GitHub Default67No configuration needed. SDK uses the default model.89```typescript10const session = await client.createSession({});11// or simply: client.createSession()12```1314Best for: quick prototyping, no model preference.1516## Path 2: GitHub Specific Model1718Specify a model name. Discover available models with `listModels()`.1920```typescript21const models = await client.listModels();22// Pick from available models23const session = await client.createSession({24model: "o4-mini",25});26```2728## Path 3: Azure BYOM (Bring Your Own Model)2930Use your own Azure AI deployment. For local development use `DefaultAzureCredential`; for production use `ManagedIdentityCredential` — see [auth-best-practices.md](auth-best-practices.md).3132> ⚠️ **Warning:** The Copilot SDK encrypts prompt content. Only models that support decrypting encrypted content work with BYOM. Using unsupported models returns "400 Encrypted content is not supported" or silently times out.3334### Supported Models3536| Family | Models |37|--------|--------|38| **o-series** | o3, o3-mini, o4-mini (cheapest) |39| **gpt-5 family** | gpt-5, gpt-5-mini, gpt-5.1, gpt-5.1-mini, gpt-5.1-nano, gpt-5.2-codex, codex-mini |40| ❌ **NOT supported** | gpt-4o, gpt-4.1, gpt-4.1-nano, and other non-o/non-gpt-5 models |4142### Required API Settings4344| Setting | Value | Notes |45|---------|-------|-------|46| `wireApi` | `"completions"` | ⚠️ Do NOT use `"responses"` — breaks multi-turn tool calls (`store: false` causes 400) |47| `azure.apiVersion` | `"2025-04-01-preview"` or later | ⚠️ Must be nested under `azure:`, NOT top-level |4849### Provider Config5051| Endpoint type | `type` | `baseUrl` pattern |52|---|---|---|53| Azure OpenAI | `azure` | `https://<resource>.openai.azure.com` |54| Azure AI Foundry | `openai` | `https://<resource>.services.ai.azure.com/api/projects/<project>/openai/v1/` |5556### Code Pattern5758> **Auth:** `DefaultAzureCredential` is for local development. See [auth-best-practices.md](auth-best-practices.md) for production patterns.5960```typescript61import { DefaultAzureCredential } from "@azure/identity";6263const credential = new DefaultAzureCredential();64const { token } = await credential.getToken("https://cognitiveservices.azure.com/.default");6566const session = await client.createSession({67model: process.env.MODEL_NAME || "o4-mini",68provider: {69type: "azure",70baseUrl: process.env.AZURE_OPENAI_ENDPOINT,71bearerToken: token,72wireApi: "completions",73azure: { apiVersion: "2025-04-01-preview" },74},75});76```7778### Environment Variables7980| Variable | Value | Required |81|----------|-------|----------|82| `AZURE_OPENAI_ENDPOINT` | `https://<resource>.openai.azure.com` | Yes |83| `MODEL_NAME` | Model deployment name | Yes |84| `AZURE_CLIENT_ID` | Managed identity client ID | Yes (Container Apps with user-assigned MI) |8586### Token Refresh8788> ⚠️ **Warning:** `bearerToken` is static — no auto-refresh.8990- Tokens valid ~1 hour91- **Production**: get fresh token per request92- Long-running sessions fail after expiry9394### Discovering Azure Deployments9596`listModels()` returns GitHub models only. For Azure deployments:9798```bash99az cognitiveservices account deployment list --name <resource> --resource-group <rg>100```101102## Template Environment Variables103104The template uses env vars for model path selection:105106| Variable | Values | Effect |107|----------|--------|--------|108| `MODEL_PROVIDER` | unset or `azure` | Selects GitHub or Azure BYOM |109| `MODEL_NAME` | model/deployment name | Selects specific model |110| `AZURE_OPENAI_ENDPOINT` | Azure endpoint URL | Required for BYOM |111112## Errors113114| Error | Cause | Fix |115|-------|-------|-----|116| `400 Encrypted content is not supported` | Model doesn't support SDK encryption | Use o-series or gpt-5 family only |117| `400` with tool calls / multi-turn | `wireApi: "responses"` with `store: false` | Use `wireApi: "completions"` instead |118| `CAPIError: 404 Resource not found` | `apiVersion` at top level instead of nested | Use `azure: { apiVersion: "..." }` |119| Silent timeout | Unsupported model (e.g., gpt-4o, gpt-4.1) | Switch to o4-mini or gpt-5 family |120| `model is required` | Missing `model` in BYOM config | Set `MODEL_NAME` env var |121| `401 Unauthorized` | Token expired or wrong scope | Refresh via `DefaultAzureCredential` |122| `404 Not Found` | Wrong endpoint or deployment name | Verify URL and deployment exists |123| `500` in Container Apps | Missing `AZURE_CLIENT_ID` env var | Set to managed identity client ID in Bicep |124