Skip to main content

Overview

CLI Proxy API supports adding custom OpenAI-compatible providers through the openai-compatibility configuration. This allows you to integrate third-party services like OpenRouter, Groq, DeepSeek, Together AI, or any other service that implements the OpenAI API format.

Basic Configuration

Add providers to your config.yaml under the openai-compatibility section:
config.yaml

Configuration Examples

OpenRouter

OpenRouter provides access to multiple AI models through a single API:
config.yaml

Groq

Groq provides ultra-fast inference for open-source models:
config.yaml

DeepSeek

DeepSeek offers competitive pricing for coding models:
config.yaml

Together AI

Together AI provides access to open-source models:
config.yaml

Advanced Configuration

Multiple API Keys

Configure multiple API keys for load balancing:
config.yaml
CLI Proxy API will automatically distribute requests across these keys using round-robin load balancing.

Per-Key Proxy Settings

Route specific API keys through different proxies:
config.yaml

Custom Headers

Add custom headers for provider-specific requirements:
config.yaml

Model Prefixes

Use prefixes to organize providers:
config.yaml
Clients must now use the prefix:

Model Pools

Create internal model pools for automatic failover:
config.yaml
When clients request smart-model, CLI Proxy API will:
  1. Round-robin between the three upstream models
  2. Automatically failover if one model fails before producing output
  3. Expose only one model name (smart-model) to clients

Excluding Models

Exclude specific models from being exposed:
config.yaml

Integration Examples

Using with Cursor

1

Configure Provider

Add OpenRouter to your config.yaml:
config.yaml
2

Configure Cursor

In Cursor settings:
  • Base URL: http://localhost:8317/v1
  • API Key: your-api-key-1 (from CLI Proxy API config)
  • Model: openrouter-claude

Using with Cline

1

Configure Provider

Add Groq to your config.yaml:
config.yaml
2

Configure Cline

In Cline settings:
settings.json

Using with curl

Model Discovery

List available models including custom providers:
Response:

Management API

The Management API provides endpoints to manage OpenAI-compatible providers dynamically:

List Providers

Add Provider

Update Provider

Delete Provider

Troubleshooting

Provider Connection Failed

If requests to your custom provider fail:
  1. Verify the base-url is correct
  2. Test the upstream API directly:
  3. Check for network/firewall issues
  4. Verify the API key is valid

Model Not Available

If a model doesn’t appear in the model list:
  1. Check the models configuration
  2. Verify the upstream model name is correct
  3. Ensure no excluded-models patterns are matching
  4. Restart CLI Proxy API if you just added the provider

Authentication Errors

If you see authentication errors:
  1. Verify the API key in api-key-entries is valid
  2. Check if the provider requires specific headers (add them under headers)
  3. Some providers need API keys in custom header formats

Rate Limiting

If you hit rate limits:
  1. Add multiple API keys in api-key-entries
  2. Configure request retry settings:
    config.yaml

Best Practices

  1. Use descriptive aliases for easy model identification
  2. Configure multiple API keys for load balancing and redundancy
  3. Set up model pools for automatic failover between similar models
  4. Use prefixes to organize different provider groups
  5. Monitor costs by checking provider dashboards regularly
  6. Enable debug logging during initial setup: debug: true
  7. Test providers before production use with curl or similar tools
  8. Document model capabilities for your team (context length, pricing, etc.)

See Also