Supported Providers
Gemini
Google’s Gemini models with multi-model fallback
OpenAI
GPT-4 and other OpenAI models
Claude
Anthropic’s Claude models
Configuration
AI provider settings are stored inuser.api.settings.json in your application data folder:
Location: %AppData%/Chapi/user.api.settings.json
Settings Structure
Your Google AI API key for Gemini models. Get one at Google AI Studio.
Your OpenAI API key. Get one at OpenAI Platform.
Your Anthropic API key for Claude. Get one at Anthropic Console.
Your preferred AI provider. Options:
Gemini: Google’s Gemini modelsOpenAI: OpenAI GPT modelsClaude: Anthropic Claude models
Example Configuration
user.api.settings.json
Provider Selection Logic
The system uses a smart fallback mechanism to ensure AI features always work:Preferred Provider
Attempts to use the provider specified in
PreferredAiProvider if its API key is configuredFallback Order
If preferred provider is unavailable, tries providers in this order:
- Gemini
- OpenAI
- Claude
App.xaml.cs (lines 95-123)
Gemini Configuration
Supported Models
Gemini uses multi-model fallback for reliability:gemini-3.0-flash(primary)gemini-2.5-flash(fallback)gemma-3(fallback)
Google AI API key from Google AI Studio
Features
Streaming Support
Uses streaming API to avoid HTTP/2 connection hanging
Timeout Protection
35-second timeout per model attempt
Auto-Retry
Automatically tries next model on failure
Quota Handling
Detects and reports quota limit errors
Usage Example
GeminiChatClient.cs
OpenAI Configuration
Supported Models
The OpenAI model to use. Can be customized when instantiating the client.
OpenAI API key from OpenAI Platform
Features
- Standard Chat Completions: Uses OpenAI’s
/v1/chat/completionsendpoint - Bearer Authentication: API key passed via Authorization header
- Flexible Model Selection: Default to
gpt-4o, customizable
Usage Example
OpenAiChatClient.cs
Claude Configuration
Supported Models
The Claude model to use. Can be customized when instantiating the client.
Anthropic API key from Anthropic Console
Features
- Messages API: Uses Anthropic’s
/v1/messagesendpoint - API Version: Fixed to
2023-06-01 - Token Limit: Default max_tokens set to 1024
Usage Example
ClaudeChatClient.cs
Proxy Configuration
If you’re behind a corporate proxy, configure these settings:Enable proxy for AI provider connections
Proxy server URL (e.g.,
http://proxy.company.com:8080)Proxy authentication username (if required)
Proxy authentication password (if required)
Getting API Keys
Gemini (Google AI)
- Visit Google AI Studio
- Sign in with your Google account
- Click “Create API Key”
- Copy the generated key
OpenAI
- Visit OpenAI Platform
- Sign in or create an account
- Click “Create new secret key”
- Copy the key (it won’t be shown again)
Claude (Anthropic)
- Visit Anthropic Console
- Sign in or create an account
- Navigate to API Keys
- Create and copy your API key
Troubleshooting
No AI provider configured
No AI provider configured
Error:
InvalidOperationException: No se ha configurado ningún proveedor de IASolution:- Add at least one API key to
user.api.settings.json - Ensure the key is not empty or whitespace
- Restart the application after updating settings
Quota limit reached (Gemini)
Quota limit reached (Gemini)
Error:
⚠️ Se alcanzó el límite de cuota del modelo de IASolution:- Check your usage at Google AI Studio
- Wait for quota reset or upgrade your plan
- Configure an alternative provider (OpenAI/Claude)
All Gemini models failed
All Gemini models failed
Error:
Fallaron todos los modelos de GeminiSolution:- Verify your API key is valid
- Check network connectivity
- Review the last error message for specific issues
- Try alternative providers
API key invalid or revoked
API key invalid or revoked
Solution:
- Regenerate API key from provider’s console
- Update
user.api.settings.jsonwith new key - Ensure no extra spaces or characters in the key
Connection timeout
Connection timeout
Solution:
- Check internet connection
- Configure proxy settings if behind firewall
- Increase timeout if possible (35s for Gemini)
Source Code Reference
- Gemini Client:
~/workspace/source/Chapi/Infrastructure/AI/GeminiChatClient.cs - OpenAI Client:
~/workspace/source/Chapi/Infrastructure/AI/OpenAiChatClient.cs - Claude Client:
~/workspace/source/Chapi/Infrastructure/AI/ClaudeChatClient.cs - Settings Model:
~/workspace/source/Chapi/Infrastructure/Persistence/Settings/UserSettings.cs - Provider Selection:
~/workspace/source/Chapi/App.xaml.cs:95-123