client Option
Added in 0.216.0
The client option provides a simple way to override which LLM client a function uses at runtime. It’s a shorthand for creating a ClientRegistry and calling set_primary().
Quick Start
Python
TypeScript
Go
When to Use
Use the client option when you want to:
- Quickly switch between different LLM providers or models
- A/B test different models
- Use different clients for different environments (dev vs prod)
- Override the default client defined in your
.bamlfiles
Precedence
If you provide both client and client_registry, the client option takes precedence:
Python
TypeScript
Go
Valid Client Names
The client value can be:
-
Shorthand provider/model syntax - Use
provider/modelformat for quick access:"openai/gpt-4o-mini"- OpenAI models"anthropic/claude-sonnet-4-20250514"- Anthropic models"openrouter/meta-llama/llama-3.1-70b-instruct"- OpenRouter models"google-ai/gemini-2.0-flash"- Google AI models
-
Client defined in
.bamlfiles - Reference by name (e.g.,"MyCustomClient")
If the client name is not found, you’ll get a runtime error when the function is called.
Comparison with ClientRegistry
Use client for simple overrides. Use ClientRegistry when you need to add new clients or customize client options at runtime.
Related Topics
- ClientRegistry - For advanced client configuration
- with_options - Set default options for a client