LanguageModel instance.
Supported Providers
OpenAI
GPT-5, GPT-4o, and o-series reasoning models
Anthropic
Claude 3.5 Sonnet, Claude 3 Opus, and more
Gemini 2.0, Gemini 1.5 Pro and Flash
OpenRouter
Access any model through one API
DeepSeek
DeepSeek Chat and Reasoner models
Groq
Groq LPU Inference
Workers AI
Cloudflare Workers AI via OpenAI-compatible endpoints
Custom Providers
Build your own provider adapters and wrappers
Meta Llama
Official Meta Llama API
xAI
Grok Models via xAI API
Cloud Providers
Bedrock
AWS Bedrock - managed foundation models
Quick Start
Each provider requires an API key set as an environment variable:Usage
All providers follow the same pattern - import the factory function and use it withgenerate_text() or stream_text():
Switching Providers
One of the key benefits of ai-query is how easy it is to switch between providers:Provider Options
Each provider supports specific options through theprovider_options parameter:
OpenAI-Compatible Providers
OpenRouter, DeepSeek, Groq, and Workers AI use OpenAI-compatible APIs internally. This means:- They share the same request/response format
- Provider options still use their own provider keys (
"openrouter","deepseek","groq","workers_ai") - Tool calling works identically