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
70 changes: 69 additions & 1 deletion go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,21 @@ func main() {
- `AutoRestart` (\*bool): Auto-restart on crash (default: true). Use `Bool(false)` to disable.
- `Env` ([]string): Environment variables for CLI process (default: inherits from current process)

**SessionConfig:**

- `Model` (string): Model to use ("gpt-5", "claude-sonnet-4.5", etc.). **Required when using custom provider.**
- `SessionID` (string): Custom session ID
- `Tools` ([]Tool): Custom tools exposed to the CLI
Comment on lines +100 to +104
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new SessionConfig section reads like an exhaustive field list, but it omits several fields that exist on copilot.SessionConfig (e.g., ConfigDir, AvailableTools, ExcludedTools, OnPermissionRequest, MCPServers, CustomAgents, SkillDirectories, DisabledSkills). Either include the missing fields or clarify that this list is partial.

Copilot uses AI. Check for mistakes.
- `SystemMessage` (\*SystemMessageConfig): System message configuration
- `Provider` (\*ProviderConfig): Custom API provider configuration (BYOK). See [Custom Providers](#custom-providers) section.
- `Streaming` (bool): Enable streaming delta events
- `InfiniteSessions` (\*InfiniteSessionConfig): Automatic context compaction configuration

**ResumeSessionConfig:**

- `Tools` ([]Tool): Tools to expose when resuming
- `Provider` (\*ProviderConfig): Custom model provider configuration
- `Provider` (\*ProviderConfig): Custom API provider configuration (BYOK). See [Custom Providers](#custom-providers) section.
- `Streaming` (bool): Enable streaming delta events

### Session

Expand Down Expand Up @@ -327,6 +338,63 @@ When enabled, sessions emit compaction events:
- `session.compaction_start` - Background compaction started
- `session.compaction_complete` - Compaction finished (includes token counts)

## Custom Providers

The SDK supports custom OpenAI-compatible API providers (BYOK - Bring Your Own Key), including local providers like Ollama. When using a custom provider, you must specify the `Model` explicitly.

**ProviderConfig:**

- `Type` (string): Provider type - "openai", "azure", or "anthropic" (default: "openai")
- `BaseURL` (string): API endpoint URL (required)
- `APIKey` (string): API key (optional for local providers like Ollama)
- `BearerToken` (string): Bearer token for authentication (takes precedence over APIKey)
- `WireApi` (string): API format for OpenAI/Azure - "completions" or "responses" (default: "completions")
- `Azure.APIVersion` (string): Azure API version (default: "2024-10-21")

**Example with Ollama:**

```go
session, err := client.CreateSession(&copilot.SessionConfig{
Model: "deepseek-coder-v2:16b", // Required when using custom provider
Provider: &copilot.ProviderConfig{
Type: "openai",
BaseURL: "http://localhost:11434/v1", // Ollama endpoint
Comment on lines +357 to +361
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These Go snippets declare session, err := ... but don’t use either value or handle the error, which makes the example not compile as-is. Consider adding minimal error handling and using session (or assign to _), and include any needed imports for os.Getenv in the subsequent examples.

Copilot uses AI. Check for mistakes.
// APIKey not required for Ollama
},
})
```

**Example with custom OpenAI-compatible API:**

```go
session, err := client.CreateSession(&copilot.SessionConfig{
Model: "gpt-4",
Provider: &copilot.ProviderConfig{
Type: "openai",
BaseURL: "https://my-api.example.com/v1",
APIKey: os.Getenv("MY_API_KEY"),
},
})
```

**Example with Azure OpenAI:**

```go
session, err := client.CreateSession(&copilot.SessionConfig{
Model: "gpt-4",
Provider: &copilot.ProviderConfig{
Type: "azure",
BaseURL: "https://my-resource.openai.azure.com",
APIKey: os.Getenv("AZURE_OPENAI_KEY"),
Azure: &copilot.AzureProviderOptions{
APIVersion: "2024-10-21",
},
},
})
```

> **Note:** When using a custom provider, the `Model` parameter is **required**. The SDK will return an error if no model is specified.

## Transport Modes

### stdio (Default)
Expand Down
62 changes: 61 additions & 1 deletion nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ Create a new conversation session.
**Config:**

- `sessionId?: string` - Custom session ID
- `model?: string` - Model to use ("gpt-5", "claude-sonnet-4.5", etc.)
- `model?: string` - Model to use ("gpt-5", "claude-sonnet-4.5", etc.). **Required when using custom provider.**
- `tools?: Tool[]` - Custom tools exposed to the CLI
- `systemMessage?: SystemMessageConfig` - System message customization (see below)
- `infiniteSessions?: InfiniteSessionConfig` - Configure automatic context compaction (see below)
- `provider?: ProviderConfig` - Custom API provider configuration (BYOK - Bring Your Own Key). See [Custom Providers](#custom-providers) section.

##### `resumeSession(sessionId: string, config?: ResumeSessionConfig): Promise<CopilotSession>`

Expand Down Expand Up @@ -407,6 +408,65 @@ await session.send({
});
```

### Custom Providers

The SDK supports custom OpenAI-compatible API providers (BYOK - Bring Your Own Key), including local providers like Ollama. When using a custom provider, you must specify the `model` explicitly.

**ProviderConfig:**

- `type?: "openai" | "azure" | "anthropic"` - Provider type (default: "openai")
- `baseUrl: string` - API endpoint URL (required)
- `apiKey?: string` - API key (optional for local providers like Ollama)
- `bearerToken?: string` - Bearer token for authentication (takes precedence over apiKey)
- `wireApi?: "completions" | "responses"` - API format for OpenAI/Azure (default: "completions")
- `azure?.apiVersion?: string` - Azure API version (default: "2024-10-21")
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the ProviderConfig field list, azure?.apiVersion looks like TypeScript optional-chaining syntax rather than the actual config shape. Consider documenting this as azure.apiVersion?: string (or azure?: { apiVersion?: string }) to match the ProviderConfig type and avoid confusion.

Suggested change
- `azure?.apiVersion?: string` - Azure API version (default: "2024-10-21")
- `azure?: { apiVersion?: string }` - Azure-specific configuration (default apiVersion: "2024-10-21")

Copilot uses AI. Check for mistakes.

**Example with Ollama:**

```typescript
const session = await client.createSession({
model: "deepseek-coder-v2:16b", // Required when using custom provider
provider: {
type: "openai",
baseUrl: "http://localhost:11434/v1", // Ollama endpoint
// apiKey not required for Ollama
},
});

await session.sendAndWait({ prompt: "Hello!" });
```

**Example with custom OpenAI-compatible API:**

```typescript
const session = await client.createSession({
model: "gpt-4",
provider: {
type: "openai",
baseUrl: "https://my-api.example.com/v1",
apiKey: process.env.MY_API_KEY,
},
});
```

**Example with Azure OpenAI:**

```typescript
const session = await client.createSession({
model: "gpt-4",
provider: {
type: "azure",
baseUrl: "https://my-resource.openai.azure.com",
apiKey: process.env.AZURE_OPENAI_KEY,
azure: {
apiVersion: "2024-10-21",
},
},
});
```

> **Note:** When using a custom provider, the `model` parameter is **required**. The SDK will throw an error if no model is specified.

## Error Handling

```typescript
Expand Down
Loading