Skip to content

Commit 7b15df0

Browse files
committed
Add provider info to docs
1 parent 24da763 commit 7b15df0

2 files changed

Lines changed: 130 additions & 2 deletions

File tree

go/README.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,21 @@ func main() {
9797
- `AutoRestart` (\*bool): Auto-restart on crash (default: true). Use `Bool(false)` to disable.
9898
- `Env` ([]string): Environment variables for CLI process (default: inherits from current process)
9999

100+
**SessionConfig:**
101+
102+
- `Model` (string): Model to use ("gpt-5", "claude-sonnet-4.5", etc.). **Required when using custom provider.**
103+
- `SessionID` (string): Custom session ID
104+
- `Tools` ([]Tool): Custom tools exposed to the CLI
105+
- `SystemMessage` (\*SystemMessageConfig): System message configuration
106+
- `Provider` (\*ProviderConfig): Custom API provider configuration (BYOK). See [Custom Providers](#custom-providers) section.
107+
- `Streaming` (bool): Enable streaming delta events
108+
- `InfiniteSessions` (\*InfiniteSessionConfig): Automatic context compaction configuration
109+
100110
**ResumeSessionConfig:**
101111

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

105116
### Session
106117

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

341+
## Custom Providers
342+
343+
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.
344+
345+
**ProviderConfig:**
346+
347+
- `Type` (string): Provider type - "openai", "azure", or "anthropic" (default: "openai")
348+
- `BaseURL` (string): API endpoint URL (required)
349+
- `APIKey` (string): API key (optional for local providers like Ollama)
350+
- `BearerToken` (string): Bearer token for authentication (takes precedence over APIKey)
351+
- `WireApi` (string): API format for OpenAI/Azure - "completions" or "responses" (default: "completions")
352+
- `Azure.APIVersion` (string): Azure API version (default: "2024-10-21")
353+
354+
**Example with Ollama:**
355+
356+
```go
357+
session, err := client.CreateSession(&copilot.SessionConfig{
358+
Model: "deepseek-coder-v2:16b", // Required when using custom provider
359+
Provider: &copilot.ProviderConfig{
360+
Type: "openai",
361+
BaseURL: "http://localhost:11434/v1", // Ollama endpoint
362+
// APIKey not required for Ollama
363+
},
364+
})
365+
```
366+
367+
**Example with custom OpenAI-compatible API:**
368+
369+
```go
370+
session, err := client.CreateSession(&copilot.SessionConfig{
371+
Model: "gpt-4",
372+
Provider: &copilot.ProviderConfig{
373+
Type: "openai",
374+
BaseURL: "https://my-api.example.com/v1",
375+
APIKey: os.Getenv("MY_API_KEY"),
376+
},
377+
})
378+
```
379+
380+
**Example with Azure OpenAI:**
381+
382+
```go
383+
session, err := client.CreateSession(&copilot.SessionConfig{
384+
Model: "gpt-4",
385+
Provider: &copilot.ProviderConfig{
386+
Type: "azure",
387+
BaseURL: "https://my-resource.openai.azure.com",
388+
APIKey: os.Getenv("AZURE_OPENAI_KEY"),
389+
Azure: &copilot.AzureProviderOptions{
390+
APIVersion: "2024-10-21",
391+
},
392+
},
393+
})
394+
```
395+
396+
> **Note:** When using a custom provider, the `Model` parameter is **required**. The SDK will return an error if no model is specified.
397+
330398
## Transport Modes
331399

332400
### stdio (Default)

nodejs/README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ Create a new conversation session.
8686
**Config:**
8787

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

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

@@ -407,6 +408,65 @@ await session.send({
407408
});
408409
```
409410

411+
### Custom Providers
412+
413+
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.
414+
415+
**ProviderConfig:**
416+
417+
- `type?: "openai" | "azure" | "anthropic"` - Provider type (default: "openai")
418+
- `baseUrl: string` - API endpoint URL (required)
419+
- `apiKey?: string` - API key (optional for local providers like Ollama)
420+
- `bearerToken?: string` - Bearer token for authentication (takes precedence over apiKey)
421+
- `wireApi?: "completions" | "responses"` - API format for OpenAI/Azure (default: "completions")
422+
- `azure?.apiVersion?: string` - Azure API version (default: "2024-10-21")
423+
424+
**Example with Ollama:**
425+
426+
```typescript
427+
const session = await client.createSession({
428+
model: "deepseek-coder-v2:16b", // Required when using custom provider
429+
provider: {
430+
type: "openai",
431+
baseUrl: "http://localhost:11434/v1", // Ollama endpoint
432+
// apiKey not required for Ollama
433+
},
434+
});
435+
436+
await session.sendAndWait({ prompt: "Hello!" });
437+
```
438+
439+
**Example with custom OpenAI-compatible API:**
440+
441+
```typescript
442+
const session = await client.createSession({
443+
model: "gpt-4",
444+
provider: {
445+
type: "openai",
446+
baseUrl: "https://my-api.example.com/v1",
447+
apiKey: process.env.MY_API_KEY,
448+
},
449+
});
450+
```
451+
452+
**Example with Azure OpenAI:**
453+
454+
```typescript
455+
const session = await client.createSession({
456+
model: "gpt-4",
457+
provider: {
458+
type: "azure",
459+
baseUrl: "https://my-resource.openai.azure.com",
460+
apiKey: process.env.AZURE_OPENAI_KEY,
461+
azure: {
462+
apiVersion: "2024-10-21",
463+
},
464+
},
465+
});
466+
```
467+
468+
> **Note:** When using a custom provider, the `model` parameter is **required**. The SDK will throw an error if no model is specified.
469+
410470
## Error Handling
411471

412472
```typescript

0 commit comments

Comments
 (0)