provider field in your API request. Your application code never needs to know which underlying SDK is in use. The get_llm_provider factory in app/packages/ai/llm.py instantiates the right client, passes the correct API key from your environment, and returns a consistent ChatResponse regardless of which model generated it.
Supported providers
Shipfastai ships with three first-class provider implementations insideproducts/pro/backend/app/packages/ai/llm.py:
| Provider | provider value | Default model | Env var |
|---|---|---|---|
| OpenAI | openai | gpt-4o | OPENAI_API_KEY |
| Anthropic | anthropic | claude-sonnet-4-20250514 | ANTHROPIC_API_KEY |
| Google Gemini | gemini | gemini-2.0-flash | GOOGLE_API_KEY |
LLMProvider interface with chat() and stream_chat() methods, so switching providers requires no changes to your route handlers.
Configuring OpenAI
Configuring Anthropic
Configuring Google Gemini
Switching providers at runtime
Because theprovider and model fields are part of each request body, you can switch providers on a per-request basis without redeploying. This is useful for A/B testing models or falling back to a cheaper provider under load.
- OpenAI GPT-4o
- Anthropic Claude
- Google Gemini
POST /api/ai/chat
"stream": true to the request body. The endpoint returns a text/event-stream response where each event is a JSON object { "token": "..." }, terminated by data: [DONE].
POST /api/ai/chat (streaming)
Extending with a new provider
All providers inherit from the abstract base classLLMProvider defined in products/pro/backend/app/packages/ai/llm.py. To add a new provider, you implement two async methods and register the provider in the factory function.
Create your provider class
Add a new class that extends
LLMProvider and implements chat() and stream_chat():products/pro/backend/app/packages/ai/llm.py
Register the provider in the factory
Update
get_llm_provider() to handle your new provider string:products/pro/backend/app/packages/ai/llm.py
app/api/ai/chat.py delegates entirely to get_llm_provider(), your new provider is immediately available to all routes — including streaming completions — without any further changes.