Skip to content

Commit cd7b0f8

Browse files
scottaddieCopilot
andcommitted
docs: expand managed identity BYOK guidance
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c19bbd67-bd50-4f54-93e1-8c6961012916
1 parent ffb4d98 commit cd7b0f8

2 files changed

Lines changed: 625 additions & 68 deletions

File tree

‎docs/auth/byok.md‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ client.stop().get();
205205
| `baseUrl` / `base_url` | string | **Required.** API endpoint URL |
206206
| `apiKey` / `api_key` | string | API key (optional for local providers like Ollama) |
207207
| `bearerToken` / `bearer_token` | string | Bearer token auth (takes precedence over apiKey) |
208+
| `bearerTokenProvider` / `bearer_token_provider` | callback | Returns a bearer token on demand (takes precedence over `apiKey` and `bearerToken`) |
208209
| `wireApi` / `wire_api` | `"completions"` \| `"responses"` | Select `"completions"` for broad model compatibility (the Chat Completions API); select `"responses"` for multi-turn state management, tool namespacing, and reasoning support (the Responses API). Anthropic models always use the Messages API regardless of this setting. |
209210
| `azure.apiVersion` / `azure.api_version` | string | Azure API version (default: `"2024-10-21"`) |
210211

@@ -326,7 +327,9 @@ provider: {
326327

327328
### Bearer token authentication
328329

329-
Some providers require bearer token authentication instead of API keys:
330+
Some providers require bearer token authentication instead of API keys. Supply a static token with `bearerToken`, or supply a `bearerTokenProvider` callback that the GitHub Copilot SDK runtime invokes before outbound provider requests. The callback or identity library it wraps manages token caching and refresh.
331+
332+
Use `bearerToken` when your application already has a token:
330333

331334
```typescript
332335
provider: {
@@ -339,6 +342,22 @@ provider: {
339342
> [!NOTE]
340343
> The `bearerToken` option accepts a **static token string** only. The SDK does not refresh this token automatically. If your token expires, requests will fail and you'll need to create a new session with a fresh token.
341344
345+
Use `bearerTokenProvider` to acquire tokens on demand:
346+
347+
<!-- docs-validate: skip -->
348+
349+
```typescript
350+
provider: {
351+
type: "openai",
352+
baseUrl: "https://my-custom-endpoint.example.com/v1",
353+
bearerTokenProvider: async () => {
354+
return await acquireBearerToken();
355+
},
356+
}
357+
```
358+
359+
For more details about acquiring and refreshing Microsoft Entra bearer tokens, see [Azure Managed Identity with BYOK](../setup/azure-managed-identity.md).
360+
342361
## Custom model listing
343362

344363
When using BYOK, the CLI server may not know which models your provider supports. You can supply a custom `onListModels` handler at the client level so that `client.listModels()` returns your provider's models in the standard `ModelInfo` format. This lets downstream consumers discover available models without querying the CLI.

0 commit comments

Comments
 (0)