Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 11 additions & 7 deletions content/copilot/how-tos/copilot-sdk/auth/authenticate.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ await using var client = new CopilotClient();
{% codetab java %}

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.CopilotClient;

// Default: uses logged-in user credentials
var client = new CopilotClient();
Expand Down Expand Up @@ -166,7 +166,7 @@ func main() {
import copilot "github.com/github/copilot-sdk/go"

client := copilot.NewClient(&copilot.ClientOptions{
GithubToken: userAccessToken, // Token from OAuth flow
GitHubToken: userAccessToken, // Token from OAuth flow
UseLoggedInUser: copilot.Bool(false), // Don't use stored CLI credentials
})
```
Expand Down Expand Up @@ -198,9 +198,11 @@ await using var client = new CopilotClient(new CopilotClientOptions
{% endcodetab %}
{% codetab java %}

<!-- docs-validate: skip -->

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;

var client = new CopilotClient(new CopilotClientOptions()
.setGitHubToken(userAccessToken) // Token from OAuth flow
Expand Down Expand Up @@ -292,13 +294,15 @@ BYOK allows you to use your own API keys from model providers like Azure AI Foun

When multiple authentication methods are available, the SDK uses them in this priority order:

1. **Explicit `gitHubToken`** - Token passed directly to SDK constructor
1. **Explicit `gitHubToken`** - Token passed directly to the SDK client or session configuration
1. **HMAC key** - `CAPI_HMAC_KEY` or `COPILOT_HMAC_KEY` environment variables
1. **Direct API token** - `GITHUB_COPILOT_API_TOKEN` with `COPILOT_API_URL`
1. **Environment variable tokens** - `COPILOT_GITHUB_TOKEN` → `GH_TOKEN` → `GITHUB_TOKEN`
1. **Stored OAuth credentials** - From previous `copilot` CLI login
1. **GitHub CLI** - `gh auth` credentials

For multi-user server mode, pass a per-session `gitHubToken` so each session runs with the correct GitHub identity; see [AUTOTITLE](/copilot/how-tos/copilot-sdk/setup/multi-tenancy).

## Disabling auto-login

To prevent the SDK from automatically using stored credentials or `gh` CLI auth, use the `useLoggedInUser: false` option:
Expand Down Expand Up @@ -365,8 +369,8 @@ await using var client = new CopilotClient(new CopilotClientOptions
{% codetab java %}

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;

var client = new CopilotClient(new CopilotClientOptions()
.setUseLoggedInUser(false) // Only use explicit tokens
Expand Down
20 changes: 11 additions & 9 deletions content/copilot/how-tos/copilot-sdk/auth/byok.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func main() {
Provider: &copilot.ProviderConfig{
Type: "openai",
BaseURL: "https://your-resource.openai.azure.com/openai/v1/",
WireApi: "responses", // Use "completions" for older models
WireAPI: "responses", // Use "completions" for older models
APIKey: os.Getenv("FOUNDRY_API_KEY"),
},
})
Expand Down Expand Up @@ -177,9 +177,8 @@ Console.WriteLine(response?.Data.Content);
{% codetab java %}

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.events.*;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;

var client = new CopilotClient();
client.start().get();
Expand Down Expand Up @@ -214,15 +213,17 @@ client.stop().get();
| `baseUrl` / `base_url` | string | **Required.** API endpoint URL |
| `apiKey` / `api_key` | string | API key (optional for local providers like Ollama) |
| `bearerToken` / `bearer_token` | string | Bearer token auth (takes precedence over apiKey) |
| `wireApi` / `wire_api` | `"completions"` \| `"responses"` | API format (default: `"completions"`) |
| `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. |
| `azure.apiVersion` / `azure.api_version` | string | Azure API version (default: `"2024-10-21"`) |

### Wire API format

The `wireApi` setting determines which OpenAI API format to use:

* **`"completions"`** (default) - Chat Completions API (`/chat/completions`). Use for most models.
* **`"responses"`** - Responses API. Use for GPT-5 series models that support the newer responses format.
* **`"completions"`** (default) - Chat Completions API (`/chat/completions`) for broad model compatibility.
* **`"responses"`** - Responses API for multi-turn state management, tool namespacing, and reasoning support.

Anthropic models always use the Anthropic Messages API regardless of this setting.

### Type-specific notes

Expand Down Expand Up @@ -450,8 +451,8 @@ var client = new CopilotClient(new CopilotClientOptions
{% codetab java %}

```java
import com.github.copilot.sdk.CopilotClient;
import com.github.copilot.sdk.json.*;
import com.github.copilot.CopilotClient;
import com.github.copilot.rpc.*;
import java.util.List;
import java.util.concurrent.CompletableFuture;

Expand Down Expand Up @@ -489,6 +490,7 @@ Some Copilot features may behave differently with BYOK:
* **Model availability** - Only models supported by your provider are available
* **Rate limiting** - Subject to your provider's rate limits, not Copilot's
* **Usage tracking** - Usage is tracked by your provider, not GitHub Copilot
* **Premium requests** - Do not count against Copilot premium request quotas

### Provider-specific limitations

Expand Down
Loading
Loading