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
TheProviderConfig class has the following properties.
Basic usage
When using a custom provider, themodel parameter is required.
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
typetoazure(notopenai) - Set
baseUrlto host only (do not include path like/openai/v1)
Important notes
- For Azure endpoints (
*.openai.azure.com), always usetype: 'azure'. - Set
baseUrlto host only. The SDK builds request paths automatically.
onListModels handler
In BYOK mode with a custom provider, you can makeclient->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().
null to remove the handler and return to default CLI server behavior.
listModelsUsing() is set, listModels() does not require a CLI server connection and does not use cache.
For the latest updates, see the GitHub repository.