# Providers

Clew supports 27 AI providers with a unified adapter layer. Set your API keys as environment variables and switch between providers at runtime with `/model`.

Provider configuration is declared in `src/services/ai/providers.json`. The ProviderManager resolves API keys, selects models, and manages provider config. Non-Anthropic providers are normalized via the AnthropicAdapter or GoogleAdapter.

## All Providers

Provider | Env Key | Default Model | Notes
--- | --- | --- | ---
Anthropic | `ANTHROPIC_API_KEY` | claude-sonnet-4-7 | Native Claude support with full tool calling and reasoning. Context: 1M tokens.
OpenAI | `OPENAI_API_KEY` | gpt-5.5 | GPT-5.5, GPT-5.5 Pro, GPT-5.4 Mini. Context: 1M+ tokens.
Google | `GOOGLE_API_KEY` | gemini-3.1-flash | Gemini 3.1 Flash, Pro. Context: up to 2M tokens. Uses GoogleAdapter.
GitHub Copilot | `COPILOT_GITHUB_TOKEN` | gpt-5.5 | Access via GitHub token. Includes Claude and GPT models. Context: 1M tokens.
OpenRouter | `OPENROUTER_API_KEY` | — | 100+ models via routed API. OpenAI-compatible.
DeepSeek | `DEEPSEEK_API_KEY` | deepseek-v4-pro | DeepSeek V4 Pro, V4 Flash. Context: 1M tokens. MoE architecture.
OpenCode | `OPENCODE_API_KEY` | claude-opus-4-7 | OpenCode AI gateway. OpenAI-compatible. Includes Claude, GPT, Gemini, Kimi, GLM, MiniMax.
OpenCode Go | `OPENCODE_GO_API_KEY` | minimax-m2.7 | Low cost subscription tier for open coding models.
Cline API | `CLINE_API_KEY` | anthropic/claude-opus-4-7 | OpenAI-compatible. Model IDs format: provider/model-name.
Groq | `GROQ_API_KEY` | — | Llama 4 70B, 8B. Fast inference. Context: 128K tokens.
xAI | `XAI_API_KEY` | grok-4-20 | Grok 4.20, Grok 4. Context: 128K tokens. Vision and tool calling.
Mistral | `MISTRAL_API_KEY` | mistral-small-latest | Mistral Large 4, Small 4, Ministral 3 14B. Tool calling and vision support.
KiloCode | `KILOCODE_API_KEY` | kilo-auto/free | Gateway with 500+ models. Includes free tier.
Ollama (Local) | `OLLAMA_API_KEY` | llama3.3 | Local models via Ollama server at `http://localhost:11434/v1`. Offline-capable.
Together AI | `TOGETHER_API_KEY` | — | Llama 4 models. OpenAI-compatible.
Fireworks AI | `FIREWORKS_API_KEY` | — | Llama 4 70B. Fast inference.
NVIDIA NIM | `NVIDIA_API_KEY` | — | NVIDIA AI Foundation Models. DeepSeek, Llama 3.1, Nemotron. Live model list fetched from API on /model list.
Cohere | `COHERE_API_KEY` | command-r-plus | Command R+ model. 128K context. No vision.
Deep Infra | `DEEPINFRA_API_KEY` | — | OpenAI-compatible gateway. Llama 4 Scout with 327K context.
Perplexity | `PERPLEXITY_API_KEY` | — | Sonar Huge Online. No tool calling support.
Cerebras | `CEREBRAS_API_KEY` | — | Wafer-Scale Engine. Extremely fast inference. Qwen 3 235B.
SiliconFlow | `SILICONFLOW_API_KEY` | — | China-based AI platform. DeepSeek V4 Pro and Flash.
Moonshot AI (Kimi) | `MOONSHOT_API_KEY` | kimi-latest | Kimi models. 128K context. Vision and tool calling.
Zhipu AI (GLM) | `ZHIPU_API_KEY` | glm-4 | GLM-4 model. 128K context.
Hugging Face | `HUGGINGFACE_API_KEY` | — | Inference API. Llama 3.1 70B. No tool calling.
Poe | `POE_API_KEY` | — | OpenAI-compatible gateway. Claude 3.7 Sonnet available.
DigitalOcean | `DIGITALOCEAN_API_KEY` | — | Serverless Inference. Llama 3.1 70B.

## Provider Selection

ProviderManager resolves the active provider by:

1. Scanning environment variables for configured API keys
2. Loading provider metadata from `providers.json`
3. Resolving model names to provider-specific identifiers
4. Applying the adapter layer for non-Anthropic providers
5. Handling config migration and backward compatibility

## Adapter Layer

Non-Anthropic providers pass through adapters that normalize:

- Content blocks — text, tool_use, tool_result, thinking block conversion (`contentBlockUtils.ts`)
- Tool calls — parsing across provider formats (`toolCallParser.ts`)
- Streaming chunks — per-chunk normalization for real-time display
- Errors — normalization with retry/rate-limit handling (`errorNormalizer.ts`)
- Usage — token counting and cost estimation (`usageNormalizer.ts`)

## Runtime Switching

    /model                          # Interactive model picker
    /model list                     # List all available models across providers
    /model claude-sonnet-4-7        # Switch to a specific model
    /provider-select                 # Show or change active provider

## Provider Capabilities

Each provider declares capabilities in `providers.json`:

- chat — Chat completion endpoint
- streaming — full, partial, or none
- toolCalling — native, adapted, or none
- vision — Image input support
- jsonSchema — Structured output via JSON schema
- reasoningEffort — Configurable reasoning depth
- contextLength — Maximum context window size

## Local / Offline Development

    # Ollama — fully offline
    export OLLAMA_API_KEY=ollama  # (any non-empty value)
    export OLLAMA_HOST=http://localhost:11434
    clew
    > /model ollama/llama4:70b

    # Debug specific provider
    DEBUG=provider:anthropic clew