Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

Onwards is configured through a JSON file. Each key in the targets object defines a model alias that clients can request.

Global options

OptionTypeRequiredDescription
strict_modeboolNoEnable strict mode globally for all targets (see Strict Mode). Default: false
authobjectNoGlobal authentication configuration (see Authentication)
targetsobjectYesMap of model aliases to target configurations

Target options

OptionTypeRequiredDescription
urlstringYesBase URL of the AI provider
onwards_keystringNoAPI key to include in requests to the target
onwards_modelstringNoModel name to use when forwarding requests
keysstring[]NoAPI keys required for authentication to this target
rate_limitobjectNoPer-target rate limiting (see Rate Limiting)
concurrency_limitobjectNoPer-target concurrency limiting (see Concurrency Limiting)
upstream_auth_header_namestringNoCustom header name for upstream auth (default: Authorization)
upstream_auth_header_prefixstringNoCustom prefix for upstream auth header value (default: Bearer )
response_headersobjectNoKey-value pairs to add or override in the response headers
sanitize_responseboolNoEnforce strict OpenAI schema compliance for responses only (see Sanitization)
strategystringNoLoad balancing strategy: weighted_random or priority
fallbackobjectNoRetry configuration (see Load Balancing)
providersarrayNoArray of provider configurations for load balancing

Rate limit object

FieldTypeDescription
requests_per_secondfloatNumber of requests allowed per second
burst_sizeintegerMaximum burst size of requests

Concurrency limit object

FieldTypeDescription
max_concurrent_requestsintegerMaximum number of concurrent requests

Auth configuration

The top-level auth object configures global authentication:

FieldTypeDescription
global_keysstring[]Keys that grant access to all authenticated targets
key_definitionsobjectNamed key definitions with per-key rate/concurrency limits

See Authentication for details.

Minimal example

{
  "targets": {
    "gpt-4": {
      "url": "https://api.openai.com",
      "onwards_key": "sk-your-openai-key"
    }
  }
}

Full example

{
  "strict_mode": true,
  "auth": {
    "global_keys": ["global-api-key-1"],
    "key_definitions": {
      "premium_user": {
        "key": "sk-premium-67890",
        "rate_limit": {
          "requests_per_second": 100,
          "burst_size": 200
        },
        "concurrency_limit": {
          "max_concurrent_requests": 10
        }
      }
    }
  },
  "targets": {
    "gpt-4": {
      "url": "https://api.openai.com",
      "onwards_key": "sk-your-openai-key",
      "onwards_model": "gpt-4-turbo",
      "keys": ["premium_user"],
      "rate_limit": {
        "requests_per_second": 50,
        "burst_size": 100
      },
      "concurrency_limit": {
        "max_concurrent_requests": 20
      },
      "response_headers": {
        "Input-Price-Per-Token": "0.0001",
        "Output-Price-Per-Token": "0.0002"
      },
      "sanitize_response": true
    }
  }
}