Skip to main content

Custom providers

Custom providers (BYOK: Bring Your Own Key) let you connect to OpenAI-compatible API endpoints using your own API key. Local providers such as Ollama are also supported.

ProviderConfig

The ProviderConfig class has the following properties.

Basic usage

When using a custom provider, the model parameter is required.
You can also use array format.

Ollama (local provider)

For local providers such as Ollama, apiKey is not required.

Azure OpenAI

When using Azure OpenAI, keep these points in mind:
  • Always set type to azure (not openai)
  • Set baseUrl to host only (do not include path like /openai/v1)

Important notes

When you use a custom provider, model is required. If you omit it, the SDK returns an error.
  • For Azure endpoints (*.openai.azure.com), always use type: 'azure'.
  • Set baseUrl to host only. The SDK builds request paths automatically.

onListModels handler

In BYOK mode with a custom provider, you can make client->listModels() call a custom handler instead of the CLI server. Configure it with listModelsUsing(). Because the client may be re-initialized, always set listModelsUsing() before calling listModels().
Pass null to remove the handler and return to default CLI server behavior.
When listModelsUsing() is set, listModels() does not require a CLI server connection and does not use cache.
For the latest updates, see the GitHub repository.
Last modified on April 19, 2026