Skip to main content

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 the LLMProvider interface (pkg/providers/types.go):

Supported Providers

HTTP-Compatible Providers

Providers using OpenAI-compatible HTTP API (pkg/providers/http_provider.go):

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

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 same model_name enable round-robin load balancing:
Behavior:
  • Requests alternate between endpoints
  • Reduces single-endpoint rate limits
  • Improves availability

Fallback Chain

Automatic failover when primary model fails.

Configuration

Method 1: Model-specific
Method 2: Agent-specific

Fallback Execution

Implemented in pkg/providers/fallback.go:

Error Classification

Defined in pkg/providers/error_classifier.go:

Cooldown Tracking

Prevents rapid retries after rate limit:
Default cooldown: 60 seconds for rate limits

Legacy Provider Configuration

Deprecated but still supported for backward compatibility.

Legacy Format

Migration to model_list

Before:
After:

Provider Selection Logic

Implemented in pkg/providers/factory.go:

Provider Resolution Examples

Special Providers

OpenRouter

Universal model router supporting all major providers:
Supports:
  • 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:
Note: PicoClaw only strips the litellm/ prefix. The rest is passed to the proxy.

Ollama (Local)

Run models locally:
No API key required for local Ollama.

GitHub Copilot

Connect to local GitHub Copilot agent:

Model Routing Patterns

Pattern 1: Single Provider

Simplest setup:

Pattern 2: Multi-Provider Fallback

Automatic failover:

Pattern 3: Load Balanced Primary

Distribute load across endpoints:

Pattern 4: Per-Agent Models

Different models for different agents:

Best Practices

1. Always Configure Fallbacks

Ensure reliability:

2. Use OpenRouter for Flexibility

Single API key for all models:

3. Set Appropriate Timeouts

Longer timeouts for complex tasks:

4. Monitor Rate Limits

Use load balancing for high-volume:

5. Local Development

Use Ollama for free testing:

6. Cost Optimization

Cheap models for simple tasks, expensive for complex: