Skip to main content
The quota management endpoints control how CLI Proxy API responds when provider quotas are exceeded.

Quota Exceeded Behavior

When a provider returns a quota exceeded error, CLI Proxy API can automatically:
  1. Switch Project: Try another project/credential for the same provider
  2. Switch Preview Model: Fall back to preview/alternative model variants
These settings allow uninterrupted service when quotas are hit.

Get Project Switching

endpoint
/v0/management/quota-exceeded/switch-project
Returns whether automatic project switching is enabled.

Request

Response

boolean
Whether to automatically switch to another project when quota is exceeded

Update Project Switching

endpoint
/v0/management/quota-exceeded/switch-project
endpoint
/v0/management/quota-exceeded/switch-project
Enable or disable automatic project switching.

Request

Request Body

Response

string
Status of update operation

Get Preview Model Switching

endpoint
/v0/management/quota-exceeded/switch-preview-model
Returns whether automatic preview model switching is enabled.

Request

Response

boolean
Whether to automatically switch to preview model when quota is exceeded

Update Preview Model Switching

endpoint
/v0/management/quota-exceeded/switch-preview-model
endpoint
/v0/management/quota-exceeded/switch-preview-model
Enable or disable automatic preview model switching.

Request

Request Body

Response

Configuration File

These settings correspond to the quota-exceeded section in config.yaml:

How Project Switching Works

When enabled and a quota exceeded error occurs:
  1. Request fails with quota error from provider
  2. CLI Proxy API identifies other credentials for the same provider
  3. Request is retried with the next available credential
  4. Process continues until success or all credentials exhausted

Example Scenario

Configuration:
Flow:
  1. Request uses Project A → Quota exceeded
  2. Automatically retry with Project B → Success
  3. Client receives response without error

How Preview Model Switching Works

When enabled and a quota exceeded error occurs:
  1. Request fails with quota error for specific model
  2. CLI Proxy API checks for preview/alternative variants:
    • gemini-2.5-progemini-2.5-pro-preview
    • gemini-3-progemini-3-pro-preview
  3. Request is retried with preview model
  4. Original model name is restored in response

Example Scenario

Request:
Flow:
  1. Request for gemini-2.5-pro → Quota exceeded
  2. Automatically retry with gemini-2.5-pro-preview → Success
  3. Response shows "model": "gemini-2.5-pro" (original)

Combined Behavior

Both settings can be enabled simultaneously for maximum availability:
Retry Order:
  1. Try Project A with model-name
  2. Try Project A with model-name-preview (if enabled)
  3. Try Project B with model-name (if enabled)
  4. Try Project B with model-name-preview (if both enabled)
  5. Continue until success or all options exhausted

Disable All Quota Handling

To return quota errors immediately to clients:

Get Current Settings

Retrieve both settings in a single call using the main config endpoint:

Use Cases

High Availability Setup

Enable both features for maximum uptime:
Best for production environments where uninterrupted service is critical.

Strict Quota Monitoring

Disable both features to track quota usage:
Best for development/testing when you need to know exactly when quotas are hit.

Project-Level Failover Only

Enable project switching but disable preview models:
Best when you want failover between accounts but prefer explicit model selection.

Model-Level Failover Only

Enable preview switching but disable project switching:
Best when you have a single account but want automatic fallback to preview models. Quota handling works alongside:
  • Request Retry (/v0/management/request-retry) - Number of retry attempts
  • Max Retry Interval (/v0/management/max-retry-interval) - Max wait before retry
  • Routing Strategy (/v0/management/routing/strategy) - How credentials are selected
See Configuration Endpoints for details.

Error Responses

Invalid Value

Returned when request body is malformed or missing value field.

Persistence Failure

Returned when config file cannot be written.

Next Steps