Skip to content
Sign in Create account

Post rules

POST /api/v1/arbitrage/rules

Read or update saved provider-routing rules for the authenticated account. Rules are stored and validated but are not applied to requests yet; requests continue to follow the account's default routing.

Authenticate with a portal session token.

Request body

application/json OrggrcArbitrageRuleCreate

  • condition object required

    Supported keys are lang, role, length, region, and expr. The expr value is parsed as a condition with prompt.tokens, cost.cents_estimate, length, detector.<id>, task, tier, lang, role, region, or needs.reasoning fields; comparisons may be joined by AND or OR and grouped with parentheses. Expressions and model targets are validated when saved. These saved rules are not currently applied to inference requests. An empty condition is allowed only when is_catch_all is true.

    • expr string

      A condition expression; see the supported fields and operators on condition.

      Length: at most 2048 characters
    • lang any
    • length any
    • region any
    • role any
  • enabled boolean
  • fallback_provider string or null

    A provider slug, provider/model pair, or model ID from the current provider catalog. Display names without a matching catalog ID are rejected.

    Length: at most 60 characters. Example: "openai/gpt-5.4-mini"
  • is_catch_all boolean
  • name string required
    Length: 1 to 120 characters. Example: "Primary route"
  • position integer
    Range: 0 to 9999
  • primary_provider string required

    A provider slug, provider/model pair, or model ID from the current provider catalog. Display names without a matching catalog ID are rejected.

    Length: 1 to 60 characters. Example: "anthropic/claude-haiku-4-5"
  • weight integer
    Range: 1 to 100

Example

{
  "condition": {
    "expr": "prompt.tokens > 1000"
  },
  "name": "Large prompt route",
  "primary_provider": "anthropic/claude-haiku-4-5"
}

Responses

201 Operation completed successfully.

application/json object

Any keys are accepted.

401 Authentication is required or invalid.

application/json ErrorWithCode

  • error_code string required
  • message string required
  • request_id string (uuid)
  • status string required
    Example: "error"
403 The authenticated user is not permitted to perform this operation.

application/json ErrorWithCode

  • error_code string required
  • message string required
  • request_id string (uuid)
  • status string required
    Example: "error"
422 The expression or provider/model target failed validation.

application/json ArbitrageRuleValidationError

  • error ErrorWithCode
  • message string
  • errors object required

    Other keys: array of string

429 The request was rate limited. API-generated responses are JSON;

Response headers

  • Retry-After string header

    Seconds to wait before retrying, when provided.

  • X-RateLimit-Scope string header

    Identifies the scope of the request limit, when provided.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

text/html string

500 The operation failed because of a server error.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.