Skip to main content

Overview

Advanced configuration options allow fine-tuning of the CLI Proxy API behavior including network proxies, request payload manipulation, custom headers, retry strategies, and streaming optimizations.

Proxy Configuration

proxy-url
string
default:"(empty)"
Global proxy URL for outbound requests. Supports socks5, http, and https protocols.Format:
Examples:

Per-Provider Proxy Override

Each provider supports per-credential proxy configuration:

Custom Headers

Add custom HTTP headers to upstream provider requests.
<provider>[].headers
object
Custom headers for provider requests. Applied to all requests made with this credential.Example:

Supported Providers

All API key providers support custom headers:
  • gemini-api-key
  • claude-api-key
  • codex-api-key
  • openai-compatibility
  • vertex-api-key

Headers Example

Passthrough Headers

passthrough-headers
boolean
default:"false"
When true, forward filtered upstream response headers to downstream clients.Forwarded headers include:
  • Content-Type
  • X-Request-ID
  • Custom provider headers
Example:
Security-sensitive headers (Authorization, Set-Cookie) are always filtered and never forwarded.

Retry Configuration

request-retry
integer
default:"3"
Number of times to retry a request. Retries occur if HTTP response code is 403, 408, 500, 502, 503, or 504.Example:
max-retry-credentials
integer
default:"0"
Maximum number of different credentials to try for one failed request.Values:
  • 0 - Try all available credentials (legacy behavior)
  • Positive integer - Limit credential rotation
Example:
max-retry-interval
integer
default:"30"
Maximum wait time in seconds for a cooled-down credential before triggering a retry.Example:

Quota Exceeded Behavior

quota-exceeded
object
Behavior when API quota limits are exceeded.

Retry Example

Routing Strategy

routing.strategy
string
default:"round-robin"
Credential selection strategy when multiple credentials match.Supported values:
  • "round-robin" - Distribute requests evenly across all credentials
  • "fill-first" - Use first credential until quota exhausted, then next
Example:

Streaming Configuration

streaming
object
Server-side streaming behavior (SSE keep-alives and safe bootstrap retries).
nonstream-keepalive-interval
integer
default:"0"
Emit blank lines every N seconds for non-streaming responses to prevent idle timeouts.Values:
  • 0 - Disabled (default)
  • Positive integer - Interval in seconds
Example:

Streaming Example

Payload Rules

Payload rules allow modification of request payloads before forwarding to upstream providers.
payload
object
Default and override parameter rules applied to provider payloads.

Payload Rule Structure

Each rule contains:
  • models - List of model patterns and protocol constraints
  • params - JSON path → value mappings (or array of paths for filter rules)

Payload Examples

Default Rules (Set if Missing)

Default Raw Rules (Raw JSON)

Raw JSON values must be valid JSON strings. Invalid JSON will cause the rule to be dropped on startup.

Override Rules (Always Set)

Override Raw Rules

Filter Rules (Remove Parameters)

Model Patterns

Supports wildcard matching:
  • "gpt-*" - Prefix match (gpt-4, gpt-5, etc.)
  • "*-mini" - Suffix match (gpt-4-mini, claude-3-haiku-mini, etc.)
  • "*codex*" - Substring match (gpt-5-codex, codex-turbo, etc.)
  • "gemini-2.5-pro" - Exact match

Protocol Constraints

Supported protocols:
  • "openai" - OpenAI Chat Completions format
  • "gemini" - Google Gemini format
  • "claude" - Anthropic Claude format
  • "codex" - OpenAI Codex format
  • "antigravity" - Gemini 3.0 experimental

WebSocket Authentication

ws-auth
boolean
default:"false"
When true, enable authentication for the WebSocket API (/v1/ws).Example:
WebSocket authentication uses the same API keys as HTTP requests.

Complete Advanced Configuration Example

Best Practices

Proxy Configuration:
  • Use global proxy-url for most cases
  • Override per-provider only when necessary
  • Test proxy connectivity before deployment
  • Use authentication for proxy servers in production
Payload Rules:
  • Test payload rules with actual requests
  • Use default rules for optional parameters
  • Use override rules sparingly (may break client expectations)
  • Validate raw JSON strings before deployment
  • Order matters: filter rules run before defaults and overrides
Retry Strategy:
  • Higher request-retry increases reliability but adds latency
  • Set max-retry-credentials to prevent exhausting all keys on persistent failures
  • Adjust max-retry-interval based on your quota reset periods

Troubleshooting

Proxy Not Working

  1. Verify proxy URL format (protocol://host:port)
  2. Test proxy connectivity outside the application
  3. Check firewall rules allow proxy connections
  4. Verify authentication credentials if required

Payload Rules Not Applied

  1. Check model name pattern matches exactly (case-sensitive)
  2. Verify protocol constraint matches provider
  3. Validate raw JSON strings are well-formed
  4. Check server logs for rule validation errors

Headers Not Forwarded

  1. Ensure passthrough-headers: true
  2. Check upstream provider actually sends the headers
  3. Verify headers are not security-sensitive (filtered automatically)

Excessive Retries

  1. Lower request-retry value
  2. Set max-retry-credentials to limit credential rotation
  3. Check upstream provider status (may be down)
  4. Review quota limits and cooldown periods