Owner Pricing Overrides

This page explains how an owner can provide delta overrides on top of system defaults. The overrides are written into the PRICING config key and take effect immediately. During billing, owner overrides are preferred and missing fields fall back to system defaults (pricing.json).


Endpoints & Auth

  • Read current overrides: GET /x-config (see configs.PRICING, a string)
  • Set/update overrides: PUT /x-config (pass PRICING string)
  • Clear overrides (restore defaults): DELETE /x-config with body { "keys": ["PRICING"] }

Owner API key is required (isOwner).


Schema (same as pricing.json)

PRICING is a JSON string. After parsing, it follows the structure below. You only need to provide the deltas; unspecified fields keep system defaults. For brevity, the schema below keeps only the commonly used fields; advanced counters like Size*/Find/Page/Query can be ignored in most cases.

{
  "ChatPricing": {
    "<model>": {
      "CacheWrite": 0,
      "CachedText": 0,
      "CachedAudio": 0,
      "InputText": 0,
      "InputAudio": 0,
      "InputImage": 0,
      "ReasonText": 0,
      "OutputText": 0,
      "OutputAudio": 0,
      "OutputImage": 0,
      "Rates": 1
    }
  },
  "ImgPricing": {
    "<model>": {
      "Call": 0,
      "Rates": 1,
      "Sizes": {"1024x1024": 0}
    }
  },
  "AudioPricing": {
    "<model>": {
      "Input": 0,
      "InputAudio": 0,
      "Output": 0,
      "OutputAudio": 0,
      "Call": 0,
      "Rates": 1
    }
  },
  "CallPricing": {
    "<model>": {"Call": 0, "Rates": 1}
  },
  "RerankPricing": {
    "<model>": {"Input": 0, "Call": 0, "Rates": 1}
  },
  "FineTuningPricing": {
    "<base-model>": {"InputText": 0, "OutputText": 0, "Rates": 1}
  }
}

Field meanings and units

ChatPricing (chat/general) β€” Common fields:

  • InputText/OutputText: USD per 1M tokens (input/output text)
  • CachedText/CacheWrite: USD per 1M tokens (cache read/write)
  • ReasonText: USD per 1M tokens (reasoning text, e.g. o1 series)
  • InputAudio/OutputAudio: USD per 1M token-equivalents (audio I/O)
  • InputImage/OutputImage: USD per 1M token-equivalents (image I/O)
  • CachedAudio: USD per 1M token-equivalents (cached audio)
  • Rates: per-model multiplier (default 1)

ChatPricing advanced fields (model-specific, usually not needed):

  • Call: USD per request (very few models like Perplexity Sonar use this)
  • SizeHigh/SizeMedium/SizeLow: USD (Perplexity Sonar search result size billing)
  • Find/Query: USD (OpenAI gpt-4o, Anthropic search/grounding features)
  • Page: USD per page (Mistral OCR and similar per-page billing)

Other pricing categories:

  • ImgPricing (image generation): Call per request, Sizes per image by size (USD/image), Rates multiplier
  • AudioPricing (speech/audio): Input/Output (USD/1M tokens), InputAudio/OutputAudio (USD/1M tokens), Call (USD/call), Rates multiplier
  • RerankPricing (reranking): Input (USD/1M tokens), Call (USD/call), Rates multiplier
  • CallPricing (call-only): Call (USD/call), Rates multiplier
  • FineTuningPricing (fine-tuning): keyed by base model (e.g. gpt-4o-mini-2024-07-18), fields same as ChatPricing common fields

Behavior & scope

  • New model keys are supported (owner-scoped). The /v1/models listing is still built from system defaults and won’t show your additions.
  • Unspecified fields/models inherit system defaults; billing uses the merged β€œeffective pricing”.
  • To make a newly added model callable, configure routing via MODEL_MAPPER or LEVEL_MAPPER (map it to an upstream model or assign it to a Level).
  • Final charge also multiplies owner/user factors (Rates/Factor) at usage time.

Examples

  1. Minimal delta (tune input/output prices of one chat model):

my_pricing.json

{
  "ChatPricing": {
    "gpt-4o": {"InputText": 3.5, "OutputText": 12, "Rates": 1}
  }
}

Upload (use jq to encode as a JSON string):

curl -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -X PUT https://api.xaixapi.com/x-config \
  -d "{\"PRICING\": $(jq -Rs . < my_pricing.json)}"
  1. Override image size prices (only certain sizes):
{
  "ImgPricing": {
    "dall-e-3": {"Sizes": {"1024x1024": 0.05, "1792x1024": 0.10}}
  }
}
  1. Read and clear:
# Read current override (string)
curl -H "Authorization: Bearer $API_KEY" https://api.xaixapi.com/x-config | jq -r '.configs.PRICING'

# Clear override (restore defaults)
curl -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -X DELETE https://api.xaixapi.com/x-config \
  -d '{"keys":["PRICING"]}'

Validation & limits

  • JSON size ≀ 128 KB
  • Total entries (sum of models across all sections) ≀ 1024
  • Unknown fields rejected (strict parsing)
  • All numeric values must be finite and non-negative