Overview
Providers abstract LLM API interactions, enabling PicoClaw to work with multiple AI models and services through a unified interface. The provider system supports automatic fallback, load balancing, and zero-code provider addition.Provider Interface
All providers implement theLLMProvider interface (pkg/providers/types.go):
Supported Providers
HTTP-Compatible Providers
Providers using OpenAI-compatible HTTP API (pkg/providers/http_provider.go):
| Provider | Prefix | Default API Base | Notes |
|---|---|---|---|
| OpenAI | openai/ | https://api.openai.com/v1 | GPT models |
| Anthropic | anthropic/ | https://api.anthropic.com/v1 | Claude (via OpenAI format) |
| Zhipu | zhipu/ | https://open.bigmodel.cn/api/paas/v4 | GLM models |
| DeepSeek | deepseek/ | https://api.deepseek.com/v1 | DeepSeek models |
| Gemini | gemini/ | https://generativelanguage.googleapis.com/v1beta | Google Gemini |
| Groq | groq/ | https://api.groq.com/openai/v1 | Fast inference |
| Moonshot | moonshot/ | https://api.moonshot.cn/v1 | Kimi models |
| Qwen | qwen/ | https://dashscope.aliyuncs.com/compatible-mode/v1 | Alibaba Qwen |
| NVIDIA | nvidia/ | https://integrate.api.nvidia.com/v1 | NVIDIA models |
| Ollama | ollama/ | http://localhost:11434/v1 | Local models |
| OpenRouter | openrouter/ | https://openrouter.ai/api/v1 | Multi-model proxy |
| LiteLLM | litellm/ | http://localhost:4000/v1 | LiteLLM proxy |
| VLLM | vllm/ | http://localhost:8000/v1 | vLLM inference |
| Cerebras | cerebras/ | https://api.cerebras.ai/v1 | Fast inference |
Native Providers
Claude Provider (pkg/providers/claude_provider.go)
Native Anthropic API implementation with:
- Prompt caching
- Extended thinking
- Vision support
Codex Provider (pkg/providers/codex_provider.go)
OpenAI OAuth/token authentication.
GitHub Copilot (pkg/providers/github_copilot_provider.go)
gRPC connection to local GitHub Copilot agent.
Model List Configuration
The modern way to configure providers: zero-code model addition.Basic Configuration
Model Entry Fields
| Field | Type | Required | Description |
|---|---|---|---|
model_name | string | Yes | Unique identifier for this model |
model | string | Yes | Full model ID with vendor prefix |
api_key | string | No* | API key (*required for most providers) |
api_base | string | No | Override default API base |
request_timeout | int | No | Timeout in seconds (default: 120) |
Provider Auto-Detection
Providers are automatically selected based on model prefix:Custom API Base
Override default endpoints:Request Timeout
Set per-model timeout:Load Balancing
Multiple entries with samemodel_name enable round-robin load balancing:
- Requests alternate between endpoints
- Reduces single-endpoint rate limits
- Improves availability
Fallback Chain
Automatic failover when primary model fails.Configuration
Method 1: Model-specificFallback Execution
Implemented inpkg/providers/fallback.go:
Error Classification
Defined inpkg/providers/error_classifier.go:
| Reason | Retry? | Examples |
|---|---|---|
auth | Yes | Invalid API key, expired token |
rate_limit | Yes (with cooldown) | 429 Too Many Requests |
billing | Yes | Insufficient credits, quota exceeded |
timeout | Yes | Network timeout, deadline exceeded |
overloaded | Yes | 503 Service Unavailable |
format | No | Invalid image size, unsupported content |
unknown | Yes | Other errors |
Cooldown Tracking
Prevents rapid retries after rate limit:Legacy Provider Configuration
Deprecated but still supported for backward compatibility.Legacy Format
Migration to model_list
Before:Provider Selection Logic
Implemented inpkg/providers/factory.go:
Provider Resolution Examples
Special Providers
OpenRouter
Universal model router supporting all major providers:- OpenAI (GPT-4, GPT-3.5, etc.)
- Anthropic (Claude)
- Google (Gemini)
- Meta (Llama)
- And 100+ other models
LiteLLM Proxy
Connect to LiteLLM proxy for unified model access:litellm/ prefix. The rest is passed to the proxy.