Supported phases
on_http_request
Type
ai-gateway
Basic structure
Configuration fields
Maximum number of tokens allowed in the prompt and context. Requests exceeding this limit will be rejected.
No limit is applied if not specified. Maximum allowed value is 500,000.
Maximum number of tokens allowed in the completion response.
No limit is applied if not specified. Maximum allowed value is 500,000.
Additional HTTP headers to include in requests to AI providers.
Additional query parameters to append to provider requests.
Additional JSON fields to merge into the request body.
Behavior when all failover attempts are exhausted.
halt (default) - Stop processing and return error to clientcontinue - Continue to next action in Traffic PolicyMaximum total time for all failover attempts across all models and keys. Must be specified as a duration string (for example, “2m”, ”90s”).
Timeout for a single request to a provider. Must be specified as a duration string (for example, ”45s”, “1m”).
List of AI provider configurations. When empty, all built-in providers are allowed in passthrough mode.
See Provider Configuration below for detailed field definitions.
When true, only providers explicitly listed in providers are allowed. Requests to other providers are rejected with an error.
When true, only models explicitly listed in provider configurations are allowed. Requests for other models are rejected.
Strategy for selecting model candidates using CEL expressions. The first strategy that returns models wins—subsequent strategies are only used if previous ones return no models.
See Model Selection Strategies for details and CEL Functions Reference for available functions.
Strategy for selecting API keys using CEL expressions. Enables intelligent key selection based on metrics like quota usage and error rates.
When not specified, keys are tried in the order listed. See CEL Functions Reference for available functions.
Provider configuration
Each provider in theproviders array supports these fields:
Provider identifier. Use built-in names (openai, anthropic, google, deepseek) or custom names for self-hosted providers.
Alternative identifiers for this provider. Allows clients to reference the same provider by different names.
Custom endpoint URL for self-hosted or alternative provider endpoints. Required for custom providers.
Human-readable name for the provider.
Description of the provider.
Provider’s website URL.
Temporarily disable this provider without removing its configuration.
Custom metadata for tracking and organization. Not sent to providers. Available in selection strategies via m.getMetadata().
List of API keys for this provider. Keys are tried in order for automatic failover.
List of model configurations for this provider. See Model Configuration below.
API key configuration
Each API key inproviders[].api_keys supports:
The API key value. Use secrets.get() for secure storage.
Model configuration
Each model inproviders[].models supports:
Model identifier as recognized by the provider.
Alternative identifiers for this model.
ID of the model author (for third-party models).
Human-readable name for the model.
Description of the model.
Temporarily disable this model.
Custom metadata for the model. Available in selection strategies.
Input types supported by the model (for example, “text”, “image”, “audio”).
Output types supported by the model.
Maximum context window size in tokens.
Maximum output tokens the model can generate.
Features supported by the model (for example, “tool-calling”, “coding”).