{
  "components": {
    "parameters": {
      "CustomerScope": {
        "description": "External customer identifier. Required with project API-key auth for tier-scoped data-plane requests; omit with a customer bearer token because the token already carries the canonical customer scope.",
        "in": "header",
        "name": "X-ModelRelay-Customer-Id",
        "required": false,
        "schema": {
          "minLength": 1,
          "type": "string"
        }
      },
      "ProjectID": {
        "in": "path",
        "name": "id",
        "required": true,
        "schema": {
          "format": "uuid",
          "type": "string"
        }
      },
      "SQLProfileID": {
        "in": "path",
        "name": "profile_id",
        "required": true,
        "schema": {
          "format": "uuid",
          "type": "string"
        }
      },
      "ToolHookID": {
        "in": "path",
        "name": "hook_id",
        "required": true,
        "schema": {
          "format": "uuid",
          "type": "string"
        }
      },
      "WebhookID": {
        "in": "path",
        "name": "webhook_id",
        "required": true,
        "schema": {
          "format": "uuid",
          "type": "string"
        }
      }
    },
    "schemas": {
      "AccountBalanceResponse": {
        "description": "Account balance information for PAYGO billing",
        "properties": {
          "balance_microcents": {
            "description": "Current account balance in microcents (1 cent = 1,000,000 microcents)",
            "format": "int64",
            "type": "integer"
          },
          "balance_formatted": {
            "description": "Human-readable balance (e.g., \"$50.00\")",
            "type": "string"
          },
          "currency": {
            "description": "Currency code (e.g., \"usd\")",
            "type": "string"
          },
          "low_balance_threshold_cents": {
            "description": "Threshold for low balance warnings in cents",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "balance_microcents",
          "currency",
          "low_balance_threshold_cents",
          "balance_formatted"
        ],
        "type": "object"
      },
      "APIError": {
        "properties": {
          "code": {
            "type": "string"
          },
          "cause": {
            "enum": [
              "validation",
              "authentication",
              "authorization",
              "rate_limit",
              "timeout",
              "canceled",
              "transport",
              "upstream_response",
              "invalid_response",
              "unavailable",
              "internal"
            ],
            "type": "string"
          },
          "batch_id": {
            "type": "string"
          },
          "detail": {
            "description": "Provider-originated safe detail only",
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "failures": {
            "description": "All typed callback failures retained when an RLM execution fails",
            "items": {
              "$ref": "#/components/schemas/AttributableFailure"
            },
            "type": "array"
          },
          "layer": {
            "enum": [
              "request",
              "routing",
              "modelrelay",
              "provider_integration",
              "upstream"
            ],
            "type": "string"
          },
          "item_id": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "provider_request_id": {
            "type": "string"
          },
          "request_id": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          },
          "status_code": {
            "type": "integer"
          }
        },
        "required": [
          "error",
          "code",
          "message",
          "layer",
          "cause",
          "status_code",
          "retryable"
        ],
        "type": "object"
      },
      "AttributableFailure": {
        "properties": {
          "batch_id": {
            "type": "string"
          },
          "cause": {
            "enum": [
              "validation",
              "authentication",
              "authorization",
              "rate_limit",
              "timeout",
              "canceled",
              "transport",
              "upstream_response",
              "invalid_response",
              "unavailable",
              "internal"
            ],
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "detail": {
            "description": "Provider-originated safe detail only",
            "type": "string"
          },
          "item_id": {
            "type": "string"
          },
          "layer": {
            "enum": [
              "request",
              "routing",
              "modelrelay",
              "provider_integration",
              "upstream"
            ],
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "provider_request_id": {
            "type": "string"
          },
          "request_id": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          },
          "status_code": {
            "type": "integer"
          }
        },
        "required": [
          "layer",
          "cause",
          "status_code",
          "code",
          "message",
          "retryable"
        ],
        "type": "object"
      },
      "DeviceAuthorization": {
        "description": "A device sign-in as the approving user sees it",
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "expires_at": {
            "format": "date-time",
            "type": "string"
          },
          "status": {
            "description": "One of pending, approved, denied, expired",
            "type": "string"
          },
          "user_code": {
            "type": "string"
          }
        },
        "required": [
          "user_code",
          "status",
          "created_at",
          "expires_at"
        ],
        "type": "object"
      },
      "DeviceCodeResponse": {
        "description": "RFC 8628 device authorization response",
        "properties": {
          "device_code": {
            "description": "Secret the client polls with; only its hash is stored",
            "type": "string"
          },
          "expires_in": {
            "description": "Seconds until the codes expire",
            "type": "integer"
          },
          "interval": {
            "description": "Minimum seconds between token polls",
            "type": "integer"
          },
          "user_code": {
            "description": "Short code the user checks on the approval page, e.g. WDJB-MJHT",
            "type": "string"
          },
          "verification_uri": {
            "description": "Dashboard approval page",
            "type": "string"
          },
          "verification_uri_complete": {
            "description": "Approval page with the user code filled in",
            "type": "string"
          }
        },
        "required": [
          "device_code",
          "user_code",
          "verification_uri",
          "verification_uri_complete",
          "expires_in",
          "interval"
        ],
        "type": "object"
      },
      "DeviceTokenError": {
        "description": "RFC 6749 token error",
        "properties": {
          "error": {
            "description": "One of authorization_pending, slow_down, access_denied, expired_token, invalid_grant, invalid_request, unsupported_grant_type",
            "type": "string"
          },
          "error_description": {
            "type": "string"
          },
          "interval": {
            "description": "Polling interval now in force (set on slow_down)",
            "type": "integer"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "DeviceTokenRequest": {
        "properties": {
          "device_code": {
            "type": "string"
          },
          "grant_type": {
            "description": "Optional; must be urn:ietf:params:oauth:grant-type:device_code when present",
            "type": "string"
          }
        },
        "required": [
          "device_code"
        ],
        "type": "object"
      },
      "DeviceUserCodeRequest": {
        "properties": {
          "user_code": {
            "type": "string"
          }
        },
        "required": [
          "user_code"
        ],
        "type": "object"
      },
      "AuthResponse": {
        "properties": {
          "access_token": {
            "type": "string"
          },
          "expires_at": {
            "format": "date-time",
            "type": "string"
          },
          "refresh_token": {
            "type": "string"
          },
          "signup_project": {
            "$ref": "#/components/schemas/SignupProject"
          },
          "tokens": {
            "$ref": "#/components/schemas/AuthTokens"
          },
          "user": {
            "$ref": "#/components/schemas/User"
          }
        },
        "type": "object"
      },
      "IssuedAPIKey": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "project_id": {
            "format": "uuid",
            "type": "string"
          },
          "redacted_key": {
            "type": "string"
          },
          "secret_key": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "SignupProject": {
        "properties": {
          "issued_key": {
            "$ref": "#/components/schemas/IssuedAPIKey"
          },
          "project": {
            "$ref": "#/components/schemas/Project"
          }
        },
        "type": "object"
      },
      "AuthTokens": {
        "properties": {
          "access_token": {
            "type": "string"
          },
          "expires_at": {
            "format": "date-time",
            "type": "string"
          },
          "refresh_token": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "AutoTopupConfigRequest": {
        "properties": {
          "amount_cents": {
            "format": "int64",
            "type": "integer"
          },
          "enabled": {
            "type": "boolean"
          },
          "threshold_cents": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "enabled",
          "threshold_cents",
          "amount_cents"
        ],
        "type": "object"
      },
      "AutoTopupConfigResponse": {
        "properties": {
          "amount_cents": {
            "format": "int64",
            "type": "integer"
          },
          "enabled": {
            "type": "boolean"
          },
          "failure_count": {
            "type": "integer"
          },
          "last_triggered_at": {
            "format": "date-time",
            "type": "string"
          },
          "limits": {
            "$ref": "#/components/schemas/AutoTopupLimits"
          },
          "payment_method": {
            "$ref": "#/components/schemas/AutoTopupPaymentMethod"
          },
          "threshold_cents": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "enabled",
          "threshold_cents",
          "amount_cents",
          "failure_count",
          "limits"
        ],
        "type": "object"
      },
      "AutoTopupConfirmRequest": {
        "properties": {
          "setup_intent_id": {
            "type": "string"
          }
        },
        "required": [
          "setup_intent_id"
        ],
        "type": "object"
      },
      "AutoTopupLimits": {
        "properties": {
          "max_daily_cents": {
            "format": "int64",
            "type": "integer"
          },
          "max_monthly_cents": {
            "format": "int64",
            "type": "integer"
          },
          "max_single_cents": {
            "format": "int64",
            "type": "integer"
          },
          "min_topup_cents": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "min_topup_cents",
          "max_single_cents",
          "max_daily_cents",
          "max_monthly_cents"
        ],
        "type": "object"
      },
      "AutoTopupPaymentMethod": {
        "properties": {
          "brand": {
            "type": "string"
          },
          "exp_month": {
            "format": "int64",
            "type": "integer"
          },
          "exp_year": {
            "format": "int64",
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "last4": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "brand",
          "last4",
          "exp_month",
          "exp_year"
        ],
        "type": "object"
      },
      "AutoTopupSetupResponse": {
        "properties": {
          "client_secret": {
            "type": "string"
          },
          "setup_intent_id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        },
        "required": [
          "setup_intent_id",
          "client_secret"
        ],
        "type": "object"
      },
      "CardVerificationConfirmRequest": {
        "properties": {
          "checkout_session_id": {
            "type": "string"
          }
        },
        "required": [
          "checkout_session_id"
        ],
        "type": "object"
      },
      "CardVerificationOutcome": {
        "description": "Card verification state for an account. Free signup credits require a verified, non-prepaid card; each card fingerprint can claim the grant once, ever.",
        "properties": {
          "verified": {
            "type": "boolean"
          },
          "verified_at": {
            "format": "date-time",
            "type": "string"
          },
          "card_brand": {
            "type": "string"
          },
          "card_last4": {
            "type": "string"
          },
          "credit_granted": {
            "type": "boolean"
          },
          "grant_amount_cents": {
            "format": "int64",
            "type": "integer"
          },
          "grant_already_used_by_card": {
            "type": "boolean"
          }
        },
        "required": [
          "verified",
          "credit_granted"
        ],
        "type": "object"
      },
      "CardVerificationSession": {
        "properties": {
          "verification_id": {
            "format": "uuid",
            "type": "string"
          },
          "checkout_session_id": {
            "type": "string"
          },
          "checkout_url": {
            "type": "string"
          },
          "expires_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "verification_id",
          "checkout_session_id",
          "checkout_url",
          "expires_at"
        ],
        "type": "object"
      },
      "BillingMode": {
        "description": "Billing mode for a project. 'managed' uses ModelRelay billing with tiers and subscriptions. 'byob' (Bring Your Own Billing) allows external billing.",
        "enum": [
          "managed",
          "byob"
        ],
        "type": "string"
      },
      "BillingProvider": {
        "description": "Billing provider backing the subscription or tier.",
        "enum": [
          "stripe",
          "crypto",
          "app_store",
          "external"
        ],
        "type": "string"
      },
      "ChangeTierRequest": {
        "properties": {
          "tier_code": {
            "description": "The tier code to switch to",
            "type": "string"
          }
        },
        "required": [
          "tier_code"
        ],
        "type": "object"
      },
      "CheckoutSessionResponse": {
        "properties": {
          "session_id": {
            "description": "Stripe checkout session ID",
            "type": "string"
          },
          "url": {
            "description": "Checkout URL",
            "format": "uri",
            "type": "string"
          }
        },
        "required": [
          "session_id",
          "url"
        ],
        "type": "object"
      },
      "Citation": {
        "properties": {
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "ContentPartFile": {
        "additionalProperties": false,
        "properties": {
          "file": {
            "additionalProperties": false,
            "properties": {
              "data_base64": {
                "description": "Base64-encoded file content",
                "type": "string"
              },
              "filename": {
                "type": "string"
              },
              "mime_type": {
                "description": "IANA media type (e.g., application/pdf, image/png)",
                "type": "string"
              },
              "size_bytes": {
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "data_base64",
              "mime_type"
            ],
            "type": "object"
          },
          "type": {
            "const": "file"
          }
        },
        "required": [
          "type",
          "file"
        ],
        "type": "object"
      },
      "ContentPartText": {
        "additionalProperties": false,
        "properties": {
          "text": {
            "type": "string"
          },
          "logprobs": {
            "description": "Raw provider token log-probability facts. Provider extensions such as token_id are preserved.",
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array"
          },
          "type": {
            "const": "text"
          }
        },
        "required": [
          "type",
          "text"
        ],
        "type": "object"
      },
      "ContentPart": {
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "text": "#/components/schemas/ContentPartText",
            "file": "#/components/schemas/ContentPartFile"
          }
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/ContentPartText"
          },
          {
            "$ref": "#/components/schemas/ContentPartFile"
          }
        ]
      },
      "Customer": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "email": {
            "description": "Customer email address",
            "format": "email",
            "type": "string"
          },
          "external_id": {
            "description": "External customer identifier from your system",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "metadata": {
            "$ref": "#/components/schemas/CustomerMetadata"
          },
          "project_id": {
            "format": "uuid",
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "CustomerBalanceResponse": {
        "properties": {
          "balance_microcents": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "billing_profile_id": {
            "description": "Billing profile UUID for wallet/balance.",
            "format": "uuid",
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "customer_id": {
            "description": "Internal customer UUID (identity).",
            "format": "uuid",
            "type": "string"
          },
          "reserved_microcents": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "customer_id",
          "billing_profile_id",
          "balance_microcents",
          "reserved_microcents",
          "currency"
        ],
        "type": "object"
      },
      "CustomerCreate": {
        "properties": {
          "email": {
            "description": "Customer email address",
            "format": "email",
            "type": "string"
          },
          "external_id": {
            "description": "External customer identifier from your system",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "metadata": {
            "$ref": "#/components/schemas/CustomerMetadata"
          }
        },
        "required": [
          "external_id",
          "email"
        ],
        "type": "object"
      },
      "CustomerLedgerEntry": {
        "properties": {
          "amount_microcents": {
            "format": "int64",
            "type": "integer"
          },
          "balance_after_microcents": {
            "format": "int64",
            "type": "integer"
          },
          "credit_amount_cents": {
            "format": "int64",
            "type": "integer"
          },
          "description": {
            "type": "string"
          },
          "direction": {
            "type": "string"
          },
          "gross_amount_cents": {
            "format": "int64",
            "type": "integer"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "input_tokens": {
            "format": "int64",
            "type": "integer"
          },
          "model_id": {
            "$ref": "#/components/schemas/ModelId"
          },
          "occurred_at": {
            "format": "date-time",
            "type": "string"
          },
          "output_tokens": {
            "format": "int64",
            "type": "integer"
          },
          "owner_revenue_cents": {
            "format": "int64",
            "type": "integer"
          },
          "platform_fee_cents": {
            "format": "int64",
            "type": "integer"
          },
          "reason": {
            "type": "string"
          },
          "request_id": {
            "format": "uuid",
            "type": "string"
          },
          "stripe_checkout_session_id": {
            "type": "string"
          },
          "stripe_invoice_id": {
            "type": "string"
          },
          "stripe_payment_intent_id": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "direction",
          "reason",
          "amount_microcents",
          "description",
          "occurred_at"
        ],
        "type": "object"
      },
      "CustomerLedgerResponse": {
        "properties": {
          "entries": {
            "items": {
              "$ref": "#/components/schemas/CustomerLedgerEntry"
            },
            "type": "array"
          }
        },
        "required": [
          "entries"
        ],
        "type": "object"
      },
      "CustomerMe": {
        "properties": {
          "customer": {
            "$ref": "#/components/schemas/Customer"
          },
          "subscription": {
            "$ref": "#/components/schemas/Subscription"
          },
          "tier": {
            "$ref": "#/components/schemas/Tier"
          }
        },
        "required": [
          "customer"
        ],
        "type": "object"
      },
      "CustomerMeBillingPortalRequest": {
        "properties": {
          "return_url": {
            "description": "URL to redirect the customer to after they finish in the Stripe billing portal. Optional; when provided it must be an absolute http(s) URL. Falls back to the configured default when omitted.",
            "format": "uri",
            "type": "string"
          }
        },
        "type": "object"
      },
      "CustomerMeBillingPortalResponse": {
        "properties": {
          "url": {
            "description": "Stripe billing portal session URL",
            "format": "uri",
            "type": "string"
          }
        },
        "required": [
          "url"
        ],
        "type": "object"
      },
      "CustomerMeCheckoutRequest": {
        "properties": {
          "cancel_url": {
            "description": "URL to redirect to if checkout is cancelled",
            "format": "uri",
            "type": "string"
          },
          "success_url": {
            "description": "URL to redirect to after successful checkout",
            "format": "uri",
            "type": "string"
          },
          "tier_code": {
            "description": "The tier code to subscribe to",
            "type": "string"
          }
        },
        "required": [
          "tier_code",
          "success_url",
          "cancel_url"
        ],
        "type": "object"
      },
      "CustomerMeResponse": {
        "properties": {
          "customer": {
            "$ref": "#/components/schemas/CustomerMe"
          }
        },
        "required": [
          "customer"
        ],
        "type": "object"
      },
      "CustomerMeSubscription": {
        "description": "Customer-visible subscription details for the current tier.",
        "properties": {
          "cancel_at_period_end": {
            "description": "True when the subscription is scheduled to end after the current billing period instead of renewing",
            "type": "boolean"
          },
          "current_period_end": {
            "description": "End of the current billing period",
            "format": "date-time",
            "type": "string"
          },
          "current_period_start": {
            "description": "Start of the current billing period",
            "format": "date-time",
            "type": "string"
          },
          "price_amount_cents": {
            "description": "Subscription price amount in cents (omitted for free tiers)",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "price_currency": {
            "description": "Currency code for the price (e.g., 'usd')",
            "type": "string"
          },
          "price_interval": {
            "$ref": "#/components/schemas/PriceInterval"
          },
          "subscription_status": {
            "$ref": "#/components/schemas/SubscriptionStatusKind"
          },
          "tier_code": {
            "$ref": "#/components/schemas/TierCode"
          },
          "tier_display_name": {
            "description": "Human-readable tier name",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "tier_code",
          "tier_display_name"
        ],
        "type": "object"
      },
      "CustomerMeSubscriptionResponse": {
        "properties": {
          "subscription": {
            "$ref": "#/components/schemas/CustomerMeSubscription"
          }
        },
        "required": [
          "subscription"
        ],
        "type": "object"
      },
      "CustomerMeChangeTierResponse": {
        "properties": {
          "action": {
            "description": "Result of the tier-change request. changed covers a different tier with no price increase or decrease; unchanged means the requested tier was already applied.",
            "enum": [
              "upgraded",
              "downgraded",
              "scheduled_cancellation",
              "changed",
              "unchanged"
            ],
            "type": "string"
          },
          "subscription": {
            "$ref": "#/components/schemas/CustomerMeSubscription"
          }
        },
        "required": [
          "subscription",
          "action"
        ],
        "type": "object"
      },
      "CustomerMeUsage": {
        "description": "Customer-visible usage metrics for the current billing window.",
        "properties": {
          "cache_read_input_tokens": {
            "description": "Input tokens served from provider cache; a subset of input_tokens",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "cache_write_input_tokens": {
            "description": "Input tokens written to provider cache; a subset of input_tokens",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "daily": {
            "items": {
              "$ref": "#/components/schemas/CustomerUsagePoint"
            },
            "type": "array"
          },
          "images": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "input_tokens": {
            "description": "Total input tokens, including cache-read and cache-write subsets",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "low": {
            "description": "True when 80% or more of spend limit is used (nil if unlimited)",
            "type": "boolean"
          },
          "overage_enabled": {
            "description": "True when PAYGO wallet can cover subscription overages",
            "type": "boolean"
          },
          "output_tokens": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "percentage_used": {
            "description": "Percentage of spend limit used (nil if unlimited)",
            "format": "float",
            "maximum": 100,
            "minimum": 0,
            "type": "number"
          },
          "requests": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "spend_limit_cents": {
            "description": "Spend ceiling in cents for this billing window. Absent or null means the tier has no ceiling; 0 is a real ceiling that permits no spend.",
            "format": "int64",
            "minimum": 0,
            "type": "integer",
            "nullable": true
          },
          "spend_remaining_microcents": {
            "description": "Remaining budget in microcents after converting spend_limit_cents to the exact internal unit (nil if unlimited)",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "tokens": {
            "description": "Total input plus output tokens; cache subsets are not added again",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "total_cost_microcents": {
            "description": "Total cost incurred in this billing window in microcents (always populated)",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "wallet_balance_microcents": {
            "description": "PAYGO wallet balance in microcents (available when PAYGO wallet is enabled)",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "wallet_reserved_microcents": {
            "description": "PAYGO wallet reserved amount in microcents",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "window_end": {
            "description": "End of the current billing window",
            "format": "date-time",
            "type": "string"
          },
          "window_start": {
            "description": "Start of the current billing window",
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "window_start",
          "window_end",
          "requests",
          "tokens",
          "input_tokens",
          "cache_read_input_tokens",
          "cache_write_input_tokens",
          "output_tokens",
          "images",
          "total_cost_microcents",
          "daily"
        ],
        "type": "object"
      },
      "CustomerMeUsageResponse": {
        "properties": {
          "usage": {
            "$ref": "#/components/schemas/CustomerMeUsage"
          }
        },
        "required": [
          "usage"
        ],
        "type": "object"
      },
      "CustomerMetadata": {
        "additionalProperties": true,
        "description": "Arbitrary customer metadata (max 10KB). Keys are limited to 40 characters. Values can be any JSON type. Nesting depth limited to 5 levels.",
        "type": "object"
      },
      "CustomerTokenResponse": {
        "properties": {
          "billing_profile_id": {
            "description": "Billing profile UUID for managed billing customers.",
            "format": "uuid",
            "type": "string"
          },
          "customer_external_id": {
            "description": "External customer identifier",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "customer_id": {
            "description": "Internal customer UUID (identity).",
            "format": "uuid",
            "type": "string"
          },
          "expires_at": {
            "description": "Token expiration timestamp",
            "format": "date-time",
            "type": "string"
          },
          "expires_in": {
            "description": "Seconds until token expires",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "project_id": {
            "description": "Project the token is scoped to",
            "format": "uuid",
            "type": "string"
          },
          "tier_code": {
            "$ref": "#/components/schemas/TierCode"
          },
          "token": {
            "description": "The customer bearer token",
            "type": "string"
          }
        },
        "required": [
          "token",
          "expires_at",
          "expires_in",
          "project_id",
          "customer_external_id",
          "customer_id"
        ],
        "type": "object"
      },
      "CustomerTopupRequest": {
        "properties": {
          "cancel_url": {
            "format": "uri",
            "type": "string"
          },
          "credit_amount_cents": {
            "format": "int64",
            "minimum": 1,
            "type": "integer"
          },
          "success_url": {
            "format": "uri",
            "type": "string"
          }
        },
        "required": [
          "credit_amount_cents",
          "success_url",
          "cancel_url"
        ],
        "type": "object"
      },
      "CustomerTopupResponse": {
        "properties": {
          "checkout_url": {
            "format": "uri",
            "type": "string"
          },
          "credit_amount_cents": {
            "format": "int64",
            "type": "integer"
          },
          "gross_amount_cents": {
            "format": "int64",
            "type": "integer"
          },
          "owner_revenue_cents": {
            "format": "int64",
            "type": "integer"
          },
          "platform_fee_cents": {
            "format": "int64",
            "type": "integer"
          },
          "session_id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          }
        },
        "required": [
          "session_id",
          "checkout_url",
          "gross_amount_cents",
          "credit_amount_cents",
          "owner_revenue_cents",
          "platform_fee_cents",
          "status"
        ],
        "type": "object"
      },
      "CryptoTopupConfigResponse": {
        "properties": {
          "chain_id": {
            "format": "int64",
            "type": "integer"
          },
          "confirmations": {
            "format": "int64",
            "type": "integer"
          },
          "destination_address": {
            "type": "string"
          },
          "session_ttl_seconds": {
            "format": "int64",
            "type": "integer"
          },
          "usdc_contract": {
            "type": "string"
          }
        },
        "required": [
          "chain_id",
          "destination_address",
          "usdc_contract",
          "confirmations",
          "session_ttl_seconds"
        ],
        "type": "object"
      },
      "CryptoTopupSubmitRequest": {
        "properties": {
          "sender_address": {
            "type": "string"
          },
          "session_id": {
            "format": "uuid",
            "type": "string"
          },
          "tx_hash": {
            "type": "string"
          }
        },
        "required": [
          "session_id",
          "tx_hash",
          "sender_address"
        ],
        "type": "object"
      },
      "TopupHistoryResponse": {
        "properties": {
          "topups": {
            "items": {
              "$ref": "#/components/schemas/TopupSessionResponse"
            },
            "type": "array"
          }
        },
        "required": [
          "topups"
        ],
        "type": "object"
      },
      "TopupRequest": {
        "properties": {
          "amount_cents": {
            "format": "int64",
            "minimum": 1,
            "type": "integer"
          },
          "billing_provider": {
            "$ref": "#/components/schemas/BillingProvider"
          }
        },
        "required": [
          "amount_cents"
        ],
        "type": "object"
      },
      "TopupResponse": {
        "properties": {
          "amount_cents": {
            "format": "int64",
            "type": "integer"
          },
          "billing_provider": {
            "$ref": "#/components/schemas/BillingProvider"
          },
          "checkout_url": {
            "format": "uri",
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "session_id": {
            "format": "uuid",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/TopupStatus"
          }
        },
        "required": [
          "session_id",
          "amount_cents",
          "currency",
          "checkout_url",
          "status"
        ],
        "type": "object"
      },
      "TopupSessionResponse": {
        "properties": {
          "amount_cents": {
            "format": "int64",
            "type": "integer"
          },
          "billing_provider": {
            "$ref": "#/components/schemas/BillingProvider"
          },
          "completed_at": {
            "format": "date-time",
            "type": "string"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "crypto_chain_id": {
            "format": "int64",
            "type": "integer"
          },
          "crypto_sender_address": {
            "type": "string"
          },
          "crypto_tx_hash": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/TopupSource"
          },
          "status": {
            "$ref": "#/components/schemas/TopupStatus"
          }
        },
        "required": [
          "id",
          "amount_cents",
          "currency",
          "status",
          "source",
          "billing_provider",
          "created_at"
        ],
        "type": "object"
      },
      "TopupSource": {
        "description": "How a top-up was initiated.",
        "enum": [
          "checkout",
          "auto"
        ],
        "type": "string",
        "x-enum-varnames": [
          "Checkout",
          "Auto"
        ]
      },
      "TopupStatus": {
        "description": "Status of a top-up session.",
        "enum": [
          "pending",
          "completed",
          "expired",
          "failed"
        ],
        "type": "string"
      },
      "CustomerUsagePoint": {
        "properties": {
          "cache_read_input_tokens": {
            "description": "Input tokens served from provider cache; a subset of input_tokens",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "cache_write_input_tokens": {
            "description": "Input tokens written to provider cache; a subset of input_tokens",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "day": {
            "description": "UTC day bucket",
            "format": "date-time",
            "type": "string"
          },
          "images": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "input_tokens": {
            "description": "Total input tokens, including cache-read and cache-write subsets",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "output_tokens": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "requests": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "tokens": {
            "description": "Total input plus output tokens; cache subsets are not added again",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "day",
          "requests",
          "tokens",
          "input_tokens",
          "cache_read_input_tokens",
          "cache_write_input_tokens",
          "output_tokens"
        ],
        "type": "object"
      },
      "CustomerWithSubscription": {
        "properties": {
          "billing_customer_id": {
            "description": "Billing provider customer ID (e.g., Stripe customer ID)",
            "type": "string"
          },
          "customer": {
            "$ref": "#/components/schemas/Customer"
          },
          "subscription": {
            "$ref": "#/components/schemas/Subscription"
          }
        },
        "required": [
          "customer"
        ],
        "type": "object"
      },
      "ImageData": {
        "description": "A single generated image.",
        "properties": {
          "b64_json": {
            "description": "Base64-encoded image data (when response_format is 'b64_json')",
            "type": "string"
          },
          "expires_at": {
            "description": "When the image URL expires (null if pinned)",
            "format": "date-time",
            "type": "string"
          },
          "image_id": {
            "description": "Unique identifier for the image (used for pinning)",
            "type": "string"
          },
          "mime_type": {
            "description": "MIME type of the image (e.g., 'image/png', 'image/webp')",
            "type": "string"
          },
          "pin_url": {
            "description": "URL to pin this image for permanent storage",
            "type": "string"
          },
          "url": {
            "description": "URL of the generated image (when response_format is 'url')",
            "type": "string"
          }
        },
        "type": "object"
      },
      "ImagePinResponse": {
        "description": "Response from pin/unpin operations.",
        "properties": {
          "expires_at": {
            "description": "When the image expires (null if pinned)",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "Image ID",
            "type": "string"
          },
          "pinned": {
            "description": "Whether the image is currently pinned",
            "type": "boolean"
          },
          "url": {
            "description": "URL of the image",
            "type": "string"
          }
        },
        "required": [
          "id",
          "pinned",
          "url"
        ],
        "type": "object"
      },
      "ImageRequest": {
        "description": "Request to generate images from a text prompt.",
        "properties": {
          "model": {
            "description": "Image generation model ID (e.g., gemini-2.5-flash-image). Optional when using a customer token with a tier that defines a default model.",
            "$ref": "#/components/schemas/ModelId"
          },
          "preset": {
            "$ref": "#/components/schemas/PresetCode"
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderId"
          },
          "n": {
            "default": 1,
            "description": "Number of images to generate (1-10, default 1)",
            "maximum": 10,
            "minimum": 1,
            "type": "integer"
          },
          "prompt": {
            "description": "Text description of the image to generate",
            "type": "string"
          },
          "response_format": {
            "$ref": "#/components/schemas/ImageResponseFormat"
          }
        },
        "required": [
          "prompt"
        ],
        "not": {
          "required": [
            "model",
            "preset"
          ]
        },
        "type": "object"
      },
      "ImageResponse": {
        "description": "Response containing generated images.",
        "properties": {
          "data": {
            "description": "Generated images",
            "items": {
              "$ref": "#/components/schemas/ImageData"
            },
            "type": "array"
          },
          "id": {
            "description": "Unique identifier for this generation request",
            "type": "string"
          },
          "model": {
            "description": "Model used for generation",
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/ImageUsage"
          }
        },
        "required": [
          "id",
          "model",
          "data",
          "usage"
        ],
        "type": "object"
      },
      "ImageResponseFormat": {
        "default": "url",
        "description": "Output format for generated images.",
        "enum": [
          "url",
          "b64_json"
        ],
        "type": "string"
      },
      "ImageUsage": {
        "description": "Usage statistics for image generation.",
        "properties": {
          "images": {
            "description": "Number of images generated",
            "format": "int32",
            "type": "integer"
          }
        },
        "required": [
          "images"
        ],
        "type": "object"
      },
      "InputItem": {
        "properties": {
          "content": {
            "items": {
              "$ref": "#/components/schemas/ContentPart"
            },
            "type": "array"
          },
          "role": {
            "$ref": "#/components/schemas/MessageRole"
          },
          "tool_call_id": {
            "$ref": "#/components/schemas/ToolCallId"
          },
          "tool_calls": {
            "items": {
              "$ref": "#/components/schemas/ToolCall"
            },
            "type": "array"
          },
          "type": {
            "enum": [
              "message"
            ],
            "type": "string"
          }
        },
        "required": [
          "type"
        ],
        "type": "object"
      },
      "JSONPatchOperation": {
        "properties": {
          "from": {
            "type": "string"
          },
          "op": {
            "enum": [
              "add",
              "remove",
              "replace",
              "move",
              "copy",
              "test"
            ],
            "type": "string"
          },
          "path": {
            "type": "string"
          },
          "value": {
            "additionalProperties": true,
            "type": "object"
          }
        },
        "required": [
          "op",
          "path"
        ],
        "type": "object"
      },
      "JSONSchemaFormat": {
        "properties": {
          "description": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "schema": {
            "additionalProperties": true,
            "type": "object"
          },
          "strict": {
            "type": "boolean"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "MessageRole": {
        "enum": [
          "system",
          "user",
          "assistant",
          "tool"
        ],
        "type": "string"
      },
      "Model": {
        "properties": {
          "capabilities": {
            "items": {
              "$ref": "#/components/schemas/ModelCapability"
            },
            "type": "array"
          },
          "context_window": {
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "deprecated": {
            "type": "boolean"
          },
          "deprecation_message": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "model_cost_projection_available": {
            "description": "Whether the authoritative full-card rates are exactly representable by the optional scalar display projection. False means the scalar fields are unavailable, not free.",
            "type": "boolean"
          },
          "audio_service_rate": {
            "$ref": "#/components/schemas/AudioServiceRate"
          },
          "audio_token_rates": {
            "$ref": "#/components/schemas/AudioTokenRates"
          },
          "data_policy": {
            "$ref": "#/components/schemas/RouteDataPolicy"
          },
          "standard_text_context_rates": {
            "description": "Exact Standard/text display rates in ascending input-context bands. Settlement uses the authoritative immutable rate card.",
            "items": {
              "$ref": "#/components/schemas/ContextTokenRate"
            },
            "type": "array"
          },
          "input_cost_per_million_millicents": {
            "description": "Uncached text input rate in millicents per million tokens.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "cache_read_input_cost_per_million_millicents": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "cache_write_input_cost_per_million_millicents": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "max_output_tokens": {
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "model_id": {
            "$ref": "#/components/schemas/ModelId"
          },
          "output_cost_per_million_millicents": {
            "description": "Text output rate in millicents per million tokens.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderId"
          },
          "training_cutoff": {
            "description": "Training cutoff in YYYY-MM format",
            "type": "string"
          },
          "prompt_caching": {
            "$ref": "#/components/schemas/PromptCachingCapabilities"
          }
        },
        "required": [
          "model_id",
          "provider",
          "display_name",
          "description",
          "capabilities",
          "context_window",
          "max_output_tokens",
          "training_cutoff",
          "deprecated",
          "deprecation_message",
          "model_cost_projection_available",
          "data_policy"
        ],
        "type": "object"
      },
      "RouteDataPolicy": {
        "additionalProperties": false,
        "description": "What this route's provider does with request content, from the provider's own published default terms. Unknown is never ZDR and may train.",
        "properties": {
          "zdr": {
            "description": "True exactly when retention is none: the provider keeps no prompt or completion content after the response.",
            "type": "boolean"
          },
          "retention": {
            "enum": [
              "none",
              "retained",
              "unknown"
            ],
            "type": "string",
            "x-enum-varnames": [
              "DataRetentionNone",
              "DataRetentionRetained",
              "DataRetentionUnknown"
            ]
          },
          "retention_days": {
            "description": "Upper bound the provider publishes for retained content. Null when retention is not retained or no period is published.",
            "format": "int32",
            "minimum": 1,
            "nullable": true,
            "type": "integer"
          },
          "training": {
            "description": "Whether the provider trains on request content.",
            "enum": [
              "no",
              "yes",
              "unknown"
            ],
            "type": "string",
            "x-enum-varnames": [
              "DataTrainingNo",
              "DataTrainingYes",
              "DataTrainingUnknown"
            ]
          },
          "source_url": {
            "description": "The provider's own statement the values were read from.",
            "format": "uri",
            "nullable": true,
            "type": "string"
          },
          "reviewed_on": {
            "description": "Date the source was last read.",
            "format": "date",
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "zdr",
          "retention",
          "retention_days",
          "training",
          "source_url",
          "reviewed_on"
        ],
        "type": "object"
      },
      "AudioServiceRate": {
        "additionalProperties": false,
        "description": "Standard service tariff of an audio-only route (speech-to-text or text-to-speech), exactly as its rate card holds it. Present only on audio-only routes; absent means unknown, not free.",
        "properties": {
          "kind": {
            "enum": [
              "audio_transcription",
              "audio_speech"
            ],
            "type": "string"
          },
          "unit": {
            "description": "Billing unit: millisecond of input audio for audio_transcription, input character for audio_speech.",
            "enum": [
              "millisecond",
              "character"
            ],
            "type": "string"
          },
          "rate_per_million_units_microcents": {
            "description": "Rate in microcents (1e-8 USD) per million billing units. 2777778 per million milliseconds is $0.10 per audio-hour.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "minimum_units_per_request": {
            "description": "Least number of billing units one request is billed for, set where the upstream provider bills a per-request minimum. A request carrying fewer units is billed this many: 10000 milliseconds means a 3-second clip is billed as 10 seconds. Absent when the route bills exactly the units the request carries.",
            "format": "uint64",
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "kind",
          "unit",
          "rate_per_million_units_microcents"
        ],
        "type": "object"
      },
      "AudioTokenRates": {
        "additionalProperties": false,
        "description": "Standard prices of a text-to-speech route billed on the token counts its provider reports for each call: text tokens in, audio tokens out. Present instead of audio_service_rate on such routes; absent means the route is not token-billed or its prices are unknown, not free.",
        "properties": {
          "input_text_per_million_tokens_microcents": {
            "description": "Rate in microcents (1e-8 USD) per million input text tokens. 50000000 is $0.50 per 1M tokens.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "output_audio_per_million_tokens_microcents": {
            "description": "Rate in microcents (1e-8 USD) per million output audio tokens. 900000000 is $9.00 per 1M tokens.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "output_audio_tokens_per_second": {
            "description": "Audio tokens per second of audio, as the provider publishes it (25 for Gemini TTS), for stating the audio price per second. Absent when the provider publishes none.",
            "format": "uint64",
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "input_text_per_million_tokens_microcents",
          "output_audio_per_million_tokens_microcents"
        ],
        "type": "object"
      },
      "ContextTokenRate": {
        "properties": {
          "band": {
            "type": "string"
          },
          "min_input_tokens": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "input_cost_per_million_millicents": {
            "description": "Uncached text input rate in millicents per million tokens.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "cache_read_input_cost_per_million_millicents": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "cache_write_input_cost_per_million_millicents": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "output_cost_per_million_millicents": {
            "description": "Text output rate in millicents per million tokens.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "band",
          "min_input_tokens",
          "cache_read_input_cost_per_million_millicents",
          "cache_write_input_cost_per_million_millicents",
          "input_cost_per_million_millicents",
          "output_cost_per_million_millicents"
        ],
        "type": "object"
      },
      "ModelCapability": {
        "description": "Workflow-critical model capability identifier. Server-side tools are not model capabilities; they require only tools support.",
        "enum": [
          "text_generation",
          "tools",
          "vision",
          "document",
          "audio",
          "video",
          "computer_use",
          "code_execution",
          "image_generation",
          "decisions"
        ],
        "type": "string"
      },
      "ModelId": {
        "description": "Stable ModelRelay model identifier. It is independent of the selected provider and never contains a provider-native account path.",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^[a-z0-9]+([._-][a-z0-9]+)*$",
        "type": "string"
      },
      "ProviderPreference": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "sort": {
            "description": "Order the routes provider.order does not place: \"price\" (cheapest card first), \"throughput\" (highest measured output rate first), or \"latency\" (lowest measured time to first token first). OpenRouter's object form {\"by\": ...} is accepted. The model suffixes :nitro and :floor are shortcuts for throughput and price.",
            "oneOf": [
              {
                "type": "string",
                "enum": [
                  "price",
                  "throughput",
                  "latency"
                ]
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "by"
                ],
                "properties": {
                  "by": {
                    "type": "string",
                    "enum": [
                      "price",
                      "throughput",
                      "latency"
                    ]
                  },
                  "partition": {
                    "type": "string",
                    "enum": [
                      "model",
                      "none"
                    ],
                    "nullable": true
                  }
                }
              }
            ],
            "nullable": true
          },
          "max_price": {
            "description": "Highest price accepted, in USD per million tokens, as a number or decimal string. prompt caps every input rate the route bills except cache reads (uncached input and cache writes, every modality and context band); completion caps every output rate. Routes over the cap are never used, including as fallbacks; when none remain the request fails with 400.",
            "type": "object",
            "additionalProperties": false,
            "minProperties": 1,
            "properties": {
              "prompt": {
                "oneOf": [
                  {
                    "type": "number",
                    "minimum": 0
                  },
                  {
                    "type": "string"
                  }
                ],
                "nullable": true
              },
              "completion": {
                "oneOf": [
                  {
                    "type": "number",
                    "minimum": 0
                  },
                  {
                    "type": "string"
                  }
                ],
                "nullable": true
              }
            },
            "nullable": true
          },
          "preferred_min_throughput": {
            "description": "Preferred minimum median output rate in tokens per second. Routes below it, or not yet measured, are tried after the routes that meet it; they are never excluded. Only p50 is supported.",
            "oneOf": [
              {
                "type": "number",
                "minimum": 0
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "p50"
                ],
                "properties": {
                  "p50": {
                    "type": "number",
                    "minimum": 0
                  }
                }
              }
            ],
            "nullable": true
          },
          "preferred_max_latency": {
            "description": "Preferred maximum median time to first token in seconds. Routes above it, or not yet measured, are tried after the routes that meet it; they are never excluded. Only p50 is supported.",
            "oneOf": [
              {
                "type": "number",
                "minimum": 0
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "p50"
                ],
                "properties": {
                  "p50": {
                    "type": "number",
                    "minimum": 0
                  }
                }
              }
            ],
            "nullable": true
          },
          "only": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "order": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "ignore": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "allow_fallbacks": {
            "type": "boolean",
            "nullable": true
          },
          "zdr": {
            "description": "Require a ZDR inference route. False or null cannot override account or API-key require_zdr. Gateway storage and tools have separate policies.",
            "type": "boolean",
            "nullable": true
          },
          "data_collection": {
            "description": "Deny admits only routes whose reviewed policy excludes training; allow adds no constraint.",
            "type": "string",
            "enum": [
              "allow",
              "deny"
            ],
            "nullable": true
          }
        },
        "description": "OpenRouter-compatible provider routing preference. Accepted as `provider` on Chat Completions, and on the native Responses API alongside the string pin."
      },
      "RoutedModelId": {
        "description": "A ModelRelay model ID, optionally followed by a routing variant: `:nitro` sorts routes by throughput and `:floor` by price, like provider.sort. The response and billing name the bare model. Use auto or modelrelay/auto for automatic difficulty-based model selection.",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^(modelrelay/auto|[a-z0-9]+([._-][a-z0-9]+)*)(:(nitro|floor))*$",
        "type": "string"
      },
      "PresetCode": {
        "description": "Tier-owned preset code. Presets are selected explicitly and are not encoded in model IDs.",
        "maxLength": 64,
        "minLength": 1,
        "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
        "type": "string"
      },
      "ModelsResponse": {
        "properties": {
          "models": {
            "items": {
              "$ref": "#/components/schemas/Model"
            },
            "type": "array"
          }
        },
        "required": [
          "models"
        ],
        "type": "object"
      },
      "ModelEndpointsResponse": {
        "description": "Every route that serves a model, in OpenRouter's endpoints-listing shape.",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ModelEndpoints"
          }
        },
        "required": [
          "data"
        ],
        "type": "object"
      },
      "ModelEndpoints": {
        "properties": {
          "id": {
            "description": "ModelRelay model ID.",
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "created": {
            "description": "Unix timestamp.",
            "format": "int64",
            "type": "integer"
          },
          "description": {
            "type": "string"
          },
          "architecture": {
            "$ref": "#/components/schemas/ModelEndpointsArchitecture"
          },
          "endpoints": {
            "description": "Routes in default routing order: the first serves a request that sets no provider preferences, and failover walks the rest in order.",
            "items": {
              "$ref": "#/components/schemas/ModelEndpoint"
            },
            "type": "array"
          }
        },
        "required": [
          "id",
          "name",
          "created",
          "description",
          "architecture",
          "endpoints"
        ],
        "type": "object"
      },
      "ModelEndpointsArchitecture": {
        "properties": {
          "modality": {
            "example": "text+image->text",
            "type": "string"
          },
          "input_modalities": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "output_modalities": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "tokenizer": {
            "description": "Always null: ModelRelay does not catalogue tokenizers.",
            "type": "string",
            "nullable": true
          },
          "instruct_type": {
            "description": "Always null: ModelRelay does not catalogue instruct formats.",
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "modality",
          "input_modalities",
          "output_modalities",
          "tokenizer",
          "instruct_type"
        ],
        "type": "object"
      },
      "ModelEndpoint": {
        "description": "One route that serves the model, priced at its own provider's rate card: the price a request pays when this route serves it.",
        "properties": {
          "name": {
            "example": "Fireworks AI | glm-5.3-flash",
            "type": "string"
          },
          "model_id": {
            "type": "string"
          },
          "model_name": {
            "type": "string"
          },
          "context_length": {
            "format": "int32",
            "type": "integer",
            "nullable": true
          },
          "pricing": {
            "$ref": "#/components/schemas/ModelEndpointPricing"
          },
          "provider_name": {
            "example": "Fireworks AI",
            "type": "string"
          },
          "tag": {
            "description": "Provider ID: the value provider.order, provider.only and provider.ignore take to select this route.",
            "example": "fireworks",
            "type": "string"
          },
          "quantization": {
            "description": "Always null: not published per route.",
            "type": "string",
            "nullable": true
          },
          "max_completion_tokens": {
            "format": "int32",
            "type": "integer",
            "nullable": true
          },
          "max_prompt_tokens": {
            "description": "Always null: the prompt is bounded only by context_length.",
            "format": "int32",
            "type": "integer",
            "nullable": true
          },
          "supported_parameters": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "status": {
            "description": "0 while the route takes traffic; -1 while its provider's circuit breaker is open.",
            "enum": [
              0,
              -1
            ],
            "type": "integer",
            "x-enum-varnames": [
              "ModelEndpointStatusServing",
              "ModelEndpointStatusCircuitOpen"
            ]
          },
          "supports_tool_choice": {
            "$ref": "#/components/schemas/ModelEndpointToolChoiceSupport"
          },
          "supports_implicit_caching": {
            "description": "The provider caches prompts without being asked: the route bills cache reads and no cache writes.",
            "type": "boolean"
          },
          "native_tools": {
            "description": "Always empty.",
            "type": "object"
          },
          "supports_diarization": {
            "type": "boolean"
          },
          "uptime_last_30m": {
            "description": "Always null: not computed.",
            "format": "double",
            "type": "number",
            "nullable": true
          },
          "uptime_last_5m": {
            "description": "Always null: not computed.",
            "format": "double",
            "type": "number",
            "nullable": true
          },
          "uptime_last_1d": {
            "description": "Always null: not computed.",
            "format": "double",
            "type": "number",
            "nullable": true
          },
          "latency_last_30m": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ModelEndpointPercentiles"
              }
            ],
            "description": "Time to first content in milliseconds, over successful streamed requests in the last 30 minutes. Null below 30 samples.",
            "nullable": true
          },
          "throughput_last_30m": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ModelEndpointPercentiles"
              }
            ],
            "description": "Output tokens per second over the whole request, reasoning included, in the last 30 minutes. Percentiles are floors: p90 is the rate 90% of requests reached or exceeded. Null below 30 samples.",
            "nullable": true
          },
          "data_policy": {
            "$ref": "#/components/schemas/RouteDataPolicy"
          }
        },
        "required": [
          "name",
          "model_id",
          "model_name",
          "context_length",
          "pricing",
          "provider_name",
          "tag",
          "quantization",
          "max_completion_tokens",
          "max_prompt_tokens",
          "supported_parameters",
          "status",
          "supports_tool_choice",
          "supports_implicit_caching",
          "native_tools",
          "supports_diarization",
          "uptime_last_30m",
          "uptime_last_5m",
          "uptime_last_1d",
          "latency_last_30m",
          "throughput_last_30m",
          "data_policy"
        ],
        "type": "object"
      },
      "ModelEndpointPricing": {
        "description": "The route's rates in OpenRouter's units. Only the classes the route bills are present.",
        "properties": {
          "prompt": {
            "description": "USD per token, as a decimal string.",
            "type": "string"
          },
          "completion": {
            "description": "USD per token, as a decimal string.",
            "type": "string"
          },
          "input_cache_read": {
            "description": "USD per token, as a decimal string.",
            "type": "string"
          },
          "input_cache_write": {
            "description": "USD per token for the cache write a prompt-cached request is billed (Anthropic's 5-minute write). Absent when the route bills none.",
            "type": "string"
          },
          "audio_minute": {
            "description": "USD per minute of transcribed audio.",
            "type": "string"
          },
          "character": {
            "description": "USD per synthesized character.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "ModelEndpointPercentiles": {
        "description": "Percentiles of one route's live traffic over the last 30 minutes.",
        "properties": {
          "p50": {
            "format": "double",
            "type": "number"
          },
          "p75": {
            "format": "double",
            "type": "number"
          },
          "p90": {
            "format": "double",
            "type": "number"
          },
          "p99": {
            "format": "double",
            "type": "number"
          }
        },
        "required": [
          "p50",
          "p75",
          "p90",
          "p99"
        ],
        "type": "object"
      },
      "ModelEndpointToolChoiceSupport": {
        "description": "Which tool_choice values a request may carry on this route.",
        "properties": {
          "none": {
            "type": "boolean"
          },
          "auto": {
            "type": "boolean"
          },
          "required": {
            "type": "boolean"
          },
          "function": {
            "type": "boolean"
          }
        },
        "required": [
          "none",
          "auto",
          "required",
          "function"
        ],
        "type": "object"
      },
      "NDJSONStreamEvent": {
        "description": "Events sent during streaming responses (application/x-ndjson).\nEach line is a JSON object with an \"event\" field indicating the type.\n",
        "properties": {
          "event": {
            "description": "Event type",
            "enum": [
              "message_start",
              "message_delta",
              "message_stop",
              "tool_use_start",
              "tool_use_delta",
              "tool_use_stop",
              "ping",
              "keepalive"
            ],
            "type": "string"
          },
          "model": {
            "$ref": "#/components/schemas/ModelId"
          },
          "response_id": {
            "description": "Response identifier (message_start)",
            "type": "string"
          },
          "state_id": {
            "format": "uuid",
            "type": "string"
          },
          "stop_reason": {
            "description": "Why generation stopped (message_stop)",
            "type": "string"
          },
          "text_delta": {
            "description": "Text content fragment (message_delta)",
            "type": "string"
          },
          "tool_call_delta": {
            "$ref": "#/components/schemas/ToolCallDelta"
          },
          "tool_calls": {
            "description": "Completed tool calls (tool_use_stop, message_stop)",
            "items": {
              "$ref": "#/components/schemas/ToolCall"
            },
            "type": "array"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "event"
        ],
        "type": "object"
      },
      "NodeErrorV0": {
        "properties": {
          "code": {
            "type": "string"
          },
          "detail": {
            "description": "Raw error details from the provider",
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message"
        ],
        "type": "object"
      },
      "NodeId": {
        "description": "Workflow node identifier. Must start with a lowercase letter and contain only lowercase letters, numbers, and underscores.",
        "maxLength": 64,
        "minLength": 1,
        "pattern": "^[a-z][a-z0-9_]*$",
        "type": "string"
      },
      "NodeResultV0": {
        "properties": {
          "ended_at": {
            "format": "date-time",
            "type": "string"
          },
          "error": {
            "$ref": "#/components/schemas/NodeErrorV0"
          },
          "id": {
            "$ref": "#/components/schemas/NodeId"
          },
          "output": {
            "additionalProperties": true,
            "type": "object"
          },
          "started_at": {
            "format": "date-time",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/NodeStatusV0"
          },
          "type": {
            "$ref": "#/components/schemas/NodeTypeV0"
          }
        },
        "required": [
          "id",
          "type",
          "status"
        ],
        "type": "object"
      },
      "NodeStatusV0": {
        "enum": [
          "pending",
          "running",
          "waiting",
          "succeeded",
          "failed",
          "canceled"
        ],
        "type": "string"
      },
      "NodeTypeV0": {
        "description": "Type of workflow node.",
        "enum": [
          "llm.responses",
          "route.switch",
          "join.all",
          "join.any",
          "join.collect",
          "map.fanout",
          "transform.json"
        ],
        "type": "string"
      },
      "OutboundWebhookEvent": {
        "properties": {
          "attempt_count": {
            "format": "int32",
            "type": "integer"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "event_id": {
            "type": "string"
          },
          "event_type": {
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "last_attempt_at": {
            "format": "date-time",
            "type": "string"
          },
          "latency_ms": {
            "format": "int32",
            "type": "integer"
          },
          "next_attempt_at": {
            "format": "date-time",
            "type": "string"
          },
          "payload": {
            "type": "object"
          },
          "response_body": {
            "type": "string"
          },
          "response_status": {
            "format": "int32",
            "type": "integer"
          },
          "status": {
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "webhook_config_id": {
            "format": "uuid",
            "type": "string"
          }
        },
        "type": "object"
      },
      "OutputFormat": {
        "properties": {
          "json_schema": {
            "$ref": "#/components/schemas/JSONSchemaFormat"
          },
          "type": {
            "enum": [
              "text",
              "json_object",
              "json_schema"
            ],
            "type": "string"
          }
        },
        "required": [
          "type"
        ],
        "type": "object"
      },
      "OutputItem": {
        "properties": {
          "content": {
            "items": {
              "$ref": "#/components/schemas/ContentPart"
            },
            "type": "array"
          },
          "role": {
            "$ref": "#/components/schemas/MessageRole"
          },
          "tool_calls": {
            "items": {
              "$ref": "#/components/schemas/ToolCall"
            },
            "type": "array"
          },
          "type": {
            "enum": [
              "message"
            ],
            "type": "string"
          }
        },
        "required": [
          "type"
        ],
        "type": "object"
      },
      "PlanHash": {
        "description": "SHA-256 hash of the compiled workflow plan (64 hex characters).",
        "maxLength": 64,
        "minLength": 64,
        "pattern": "^[a-f0-9]{64}$",
        "type": "string"
      },
      "PriceInterval": {
        "description": "Billing interval for a tier.",
        "enum": [
          "month",
          "year"
        ],
        "type": "string"
      },
      "Project": {
        "properties": {
          "billing_mode": {
            "$ref": "#/components/schemas/BillingMode"
          },
          "billing_display_name": {
            "description": "Customer-facing business name shown on hosted billing surfaces; defaults to the project name.",
            "maxLength": 100,
            "type": "string"
          },
          "billing_logo_url": {
            "format": "uri",
            "maxLength": 2048,
            "type": "string"
          },
          "billing_support_url": {
            "format": "uri",
            "maxLength": 1165,
            "type": "string"
          },
          "billing_statement_descriptor": {
            "description": "Stripe subscription product statement descriptor. ASCII, up to 22 characters, and must contain a letter.",
            "maxLength": 22,
            "pattern": "^$|^.{5,22}$",
            "type": "string"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "default_tier_id": {
            "description": "Free tier assigned to new managed customers and restored when paid subscriptions end.",
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "markup_percentage": {
            "maximum": 100,
            "minimum": 0,
            "type": "number"
          },
          "name": {
            "type": "string"
          },
          "owner_id": {
            "format": "uuid",
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "ProviderId": {
        "description": "LLM provider identifier.",
        "enum": [
          "anthropic",
          "openai",
          "xai",
          "google-ai-studio",
          "fireworks",
          "meta",
          "together",
          "near-ai",
          "cerebras",
          "akashml",
          "inco"
        ],
        "type": "string"
      },
      "RequestId": {
        "description": "Unique identifier for an LLM request within a workflow run.",
        "format": "uuid",
        "type": "string"
      },
      "ChatCompletionRequest": {
        "additionalProperties": false,
        "description": "OpenAI Chat Completions compatibility with streaming, function tools, JSON schema outputs and inline images. Only documented controls are accepted; max_tokens and max_completion_tokens are mutually exclusive.",
        "not": {
          "anyOf": [
            {
              "required": [
                "max_completion_tokens",
                "max_tokens"
              ],
              "properties": {
                "max_completion_tokens": {"type": "integer"},
                "max_tokens": {"type": "integer"}
              }
            },
            {
              "required": [
                "temperature",
                "reasoning_effort"
              ],
              "properties": {
                "temperature": {"type": "number"},
                "reasoning_effort": {"type": "string"}
              }
            }
          ]
        },
        "properties": {
          "max_completion_tokens": {
            "description": "Maximum completion token budget. Translated to ModelRelay max_output_tokens.",
            "format": "uint32",
            "minimum": 1,
            "type": "integer",
            "nullable": true
          },
          "max_tokens": {
            "deprecated": true,
            "description": "Legacy alias for max_completion_tokens. Translated to ModelRelay max_output_tokens. Cannot be combined with max_completion_tokens.",
            "format": "uint32",
            "minimum": 1,
            "type": "integer",
            "nullable": true
          },
          "messages": {
            "items": {
              "$ref": "#/components/schemas/ChatCompletionRequestMessage"
            },
            "minItems": 1,
            "type": "array"
          },
          "model": {
            "$ref": "#/components/schemas/ChatCompletionModelId"
          },
          "reasoning_effort": {
            "description": "Model-specific reasoning effort. Accepted only when the resolved model advertises the requested value.",
            "enum": [
              "none",
              "minimal",
              "low",
              "medium",
              "high",
              "xhigh",
              "max"
            ],
            "type": "string",
            "nullable": true
          },
          "stream": {
            "description": "Stream Chat Completions SSE chunks, followed by [DONE].",
            "type": "boolean",
            "nullable": true
          },
          "temperature": {
            "description": "Sampling temperature. Accepted only for resolved models without a mapped reasoning control, and cannot be combined with reasoning_effort.",
            "maximum": 2,
            "minimum": 0,
            "type": "number",
            "nullable": true
          },
          "top_p": {
            "description": "Nucleus sampling probability.",
            "maximum": 1,
            "minimum": 0,
            "type": "number",
            "nullable": true
          },
          "logprobs": {
            "description": "Return raw token log-probability facts when supported by the resolved provider.",
            "type": "boolean",
            "nullable": true
          },
          "top_logprobs": {
            "description": "Number of alternative token facts; requires logprobs=true.",
            "maximum": 20,
            "minimum": 0,
            "type": "integer",
            "nullable": true
          },
          "tools": {
            "type": "array",
            "maxItems": 128,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "type",
                "function"
              ],
              "properties": {
                "type": {
                  "type": "string",
                  "const": "function"
                },
                "function": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "name"
                  ],
                  "properties": {
                    "name": {
                      "type": "string",
                      "pattern": "^[A-Za-z0-9_-]{1,64}$"
                    },
                    "description": {
                      "type": "string"
                    },
                    "parameters": {
                      "type": "object",
                      "additionalProperties": true
                    },
                    "strict": {
                      "type": "boolean",
                      "nullable": true
                    }
                  }
                }
              }
            },
            "nullable": true
          },
          "tool_choice": {
            "oneOf": [
              {
                "type": "string",
                "enum": [
                  "none",
                  "auto",
                  "required"
                ]
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "type",
                  "function"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "function"
                  },
                  "function": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "name"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            ],
            "nullable": true
          },
          "parallel_tool_calls": {
            "type": "boolean",
            "description": "Allow multiple function calls per turn. Unsupported provider constraints fail explicitly.",
            "nullable": true
          },
          "response_format": {
            "$ref": "#/components/schemas/OutputFormat",
            "nullable": true
          },
          "stop": {
            "oneOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "type": "array",
                "minItems": 1,
                "maxItems": 4,
                "items": {
                  "type": "string",
                  "minLength": 1
                }
              }
            ],
            "nullable": true
          },
          "stream_options": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "include_usage": {
                "type": "boolean"
              },
              "include_obfuscation": {
                "type": "boolean",
                "const": false
              }
            },
            "description": "Requires stream=true. include_usage adds a final chunk with an empty choices array.",
            "nullable": true
          },
          "reasoning": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "effort": {
                "description": "Model-specific reasoning effort. Accepted only when the resolved model advertises the requested value.",
                "enum": [
                  "none",
                  "minimal",
                  "low",
                  "medium",
                  "high",
                  "xhigh",
                  "max"
                ],
                "type": "string",
                "nullable": true
              },
              "exclude": {
                "type": "boolean"
              }
            },
            "description": "OpenRouter-compatible effort and streamed reasoning visibility. Structured reasoning replay and token budgets are unsupported.",
            "nullable": true
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderPreference"
          },
          "n": {
            "type": "integer",
            "const": 1,
            "nullable": true
          },
          "store": {
            "type": "boolean",
            "const": false,
            "nullable": true
          },
          "user": {
            "type": "string",
            "nullable": true
          },
          "prompt_cache_key": {
            "description": "Prompt-cache routing key, such as a conversation ID. Scoped to the tenant, provider and model before any provider sees it. The x-session-affinity header sets the same key; when both are sent they must match.",
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "nullable": true
          },
          "metadata": {
            "type": "object",
            "maxProperties": 16,
            "additionalProperties": {
              "type": "string",
              "maxLength": 512
            },
            "nullable": true
          },
          "modalities": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1,
            "items": {
              "type": "string",
              "const": "text"
            },
            "nullable": true
          },
          "frequency_penalty": {
            "type": "number",
            "const": 0,
            "nullable": true
          },
          "presence_penalty": {
            "type": "number",
            "const": 0,
            "nullable": true
          },
          "logit_bias": {
            "type": "object",
            "maxProperties": 0,
            "additionalProperties": {
              "type": "number"
            },
            "nullable": true
          },
          "service_tier": {
            "type": "string",
            "const": "auto",
            "nullable": true
          },
          "plugins": {
            "type": "array",
            "maxItems": 1,
            "items": {
              "$ref": "#/components/schemas/AutoRouterPlugin"
            },
            "description": "Optional auto-router plugin for model auto or modelrelay/auto. Other plugin IDs and unknown options are rejected."
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "ChatCompletionModelId": {
        "description": "Flat ModelRelay model ID or a documented equivalent OpenRouter alias.",
        "type": "string"
      },
      "ChatCompletionRequestMessage": {
        "description": "Chat history, including assistant function calls followed by matching tool results. User images must be inline data URLs.",
        "discriminator": {
          "mapping": {
            "assistant": "#/components/schemas/ChatCompletionAssistantRequestMessage",
            "developer": "#/components/schemas/ChatCompletionDeveloperRequestMessage",
            "system": "#/components/schemas/ChatCompletionSystemRequestMessage",
            "user": "#/components/schemas/ChatCompletionUserRequestMessage",
            "tool": "#/components/schemas/ChatCompletionToolRequestMessage"
          },
          "propertyName": "role"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/ChatCompletionDeveloperRequestMessage"
          },
          {
            "$ref": "#/components/schemas/ChatCompletionSystemRequestMessage"
          },
          {
            "$ref": "#/components/schemas/ChatCompletionUserRequestMessage"
          },
          {
            "$ref": "#/components/schemas/ChatCompletionAssistantRequestMessage"
          },
          {
            "$ref": "#/components/schemas/ChatCompletionToolRequestMessage"
          }
        ]
      },
      "ChatCompletionRequestMessageContent": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "items": {
              "$ref": "#/components/schemas/ChatCompletionTextPart"
            },
            "minItems": 1,
            "type": "array"
          }
        ]
      },
      "ChatCompletionUserRequestMessageContent": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "items": {
              "$ref": "#/components/schemas/ChatCompletionUserContentPart"
            },
            "minItems": 1,
            "type": "array"
          }
        ]
      },
      "ChatCompletionUserContentPart": {
        "discriminator": {
          "mapping": {
            "image_url": "#/components/schemas/ChatCompletionImageURLPart",
            "text": "#/components/schemas/ChatCompletionTextPart"
          },
          "propertyName": "type"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/ChatCompletionTextPart"
          },
          {
            "$ref": "#/components/schemas/ChatCompletionImageURLPart"
          }
        ]
      },
      "ChatCompletionImageURLPart": {
        "additionalProperties": false,
        "properties": {
          "image_url": {
            "$ref": "#/components/schemas/ChatCompletionImageURL"
          },
          "type": {
            "const": "image_url",
            "type": "string"
          }
        },
        "required": [
          "type",
          "image_url"
        ],
        "type": "object"
      },
      "ChatCompletionImageURL": {
        "additionalProperties": false,
        "properties": {
          "detail": {
            "description": "Accepted and ignored. Native file parts do not carry OpenAI image detail.",
            "type": "string"
          },
          "url": {
            "description": "Image data URL (data:image/...;base64,...). HTTP(S) URLs are rejected.",
            "type": "string"
          }
        },
        "required": [
          "url"
        ],
        "type": "object"
      },
      "ChatCompletionDeveloperRequestMessage": {
        "additionalProperties": false,
        "properties": {
          "content": {
            "$ref": "#/components/schemas/ChatCompletionRequestMessageContent"
          },
          "name": {
            "description": "Participant metadata accepted only as null or an empty string and ignored.",
            "maxLength": 0,
            "nullable": true,
            "type": "string"
          },
          "role": {
            "enum": [
              "developer"
            ],
            "type": "string",
            "x-enum-varnames": [
              "ChatCompletionDeveloperRole"
            ]
          }
        },
        "required": [
          "role",
          "content"
        ],
        "type": "object"
      },
      "ChatCompletionSystemRequestMessage": {
        "additionalProperties": false,
        "properties": {
          "content": {
            "$ref": "#/components/schemas/ChatCompletionRequestMessageContent"
          },
          "name": {
            "description": "Participant metadata accepted only as null or an empty string and ignored.",
            "maxLength": 0,
            "nullable": true,
            "type": "string"
          },
          "role": {
            "enum": [
              "system"
            ],
            "type": "string",
            "x-enum-varnames": [
              "ChatCompletionSystemRole"
            ]
          }
        },
        "required": [
          "role",
          "content"
        ],
        "type": "object"
      },
      "ChatCompletionUserRequestMessage": {
        "additionalProperties": false,
        "properties": {
          "content": {
            "$ref": "#/components/schemas/ChatCompletionUserRequestMessageContent"
          },
          "name": {
            "description": "Participant metadata accepted only as null or an empty string and ignored.",
            "maxLength": 0,
            "nullable": true,
            "type": "string"
          },
          "role": {
            "enum": [
              "user"
            ],
            "type": "string",
            "x-enum-varnames": [
              "ChatCompletionUserRole"
            ]
          }
        },
        "required": [
          "role",
          "content"
        ],
        "type": "object"
      },
      "ChatCompletionAssistantRequestMessage": {
        "additionalProperties": false,
        "properties": {
          "annotations": {
            "description": "Assistant completion replay metadata. Only null or an empty array is accepted and ignored; annotations with values are unsupported.",
            "items": {
              "additionalProperties": false,
              "type": "object"
            },
            "maxItems": 0,
            "nullable": true,
            "type": "array"
          },
          "audio": {
            "description": "Assistant completion replay metadata. Only null is accepted; audio values are unsupported.",
            "enum": [
              null
            ],
            "nullable": true,
            "type": "object"
          },
          "content": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ChatCompletionRequestMessageContent"
              },
              {
                "type": "string",
                "enum": [null],
                "nullable": true
              }
            ]
          },
          "function_call": {
            "deprecated": true,
            "description": "Assistant completion replay metadata. Only null is accepted; function calls are unsupported.",
            "enum": [
              null
            ],
            "nullable": true,
            "type": "object"
          },
          "name": {
            "description": "Participant metadata accepted only as null or an empty string and ignored.",
            "maxLength": 0,
            "nullable": true,
            "type": "string"
          },
          "refusal": {
            "description": "Assistant completion replay metadata. Only null or an empty string is accepted and ignored; refusals with content are unsupported.",
            "maxLength": 0,
            "nullable": true,
            "type": "string"
          },
          "role": {
            "enum": [
              "assistant"
            ],
            "type": "string",
            "x-enum-varnames": [
              "ChatCompletionAssistantRole"
            ]
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "type",
                "function"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "type": {
                  "type": "string",
                  "const": "function"
                },
                "function": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "name",
                    "arguments"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "arguments": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "nullable": true
          },
          "reasoning": {
            "description": "Assistant reasoning replay metadata (OpenRouter convention). Accepted and ignored; reasoning history is not forwarded to the model.",
            "type": "string",
            "nullable": true
          },
          "reasoning_content": {
            "description": "Assistant reasoning replay metadata (DeepSeek/vLLM convention). Accepted and ignored; reasoning history is not forwarded to the model.",
            "type": "string",
            "nullable": true
          },
          "reasoning_details": {
            "description": "Assistant reasoning replay metadata (OpenRouter convention). Accepted and ignored; reasoning history, including opaque or encrypted reasoning, is not forwarded to the model.",
            "type": "array",
            "items": {
              "type": "object"
            },
            "nullable": true
          }
        },
        "required": [
          "role"
        ],
        "type": "object",
        "anyOf": [
          {
            "required": [
              "content"
            ]
          },
          {
            "required": [
              "tool_calls"
            ]
          }
        ]
      },
      "ChatCompletionToolRequestMessage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "role",
          "content",
          "tool_call_id"
        ],
        "properties": {
          "role": {
            "type": "string",
            "const": "tool"
          },
          "content": {
            "$ref": "#/components/schemas/ChatCompletionRequestMessageContent"
          },
          "tool_call_id": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "description": "Participant metadata accepted only as null or an empty string and ignored.",
            "maxLength": 0,
            "nullable": true,
            "type": "string"
          }
        }
      },
      "ChatCompletionTextPart": {
        "additionalProperties": false,
        "properties": {
          "text": {
            "type": "string"
          },
          "type": {
            "const": "text",
            "type": "string"
          }
        },
        "required": [
          "type",
          "text"
        ],
        "type": "object"
      },
      "ChatCompletionResponse": {
        "additionalProperties": false,
        "properties": {
          "choices": {
            "items": {
              "$ref": "#/components/schemas/ChatCompletionResponseChoice"
            },
            "maxItems": 1,
            "minItems": 1,
            "type": "array"
          },
          "created": {
            "format": "int64",
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "model": {
            "$ref": "#/components/schemas/ChatCompletionModelId"
          },
          "object": {
            "const": "chat.completion",
            "type": "string"
          },
          "provider": {
            "description": "Slug of the provider whose route served the request, as accepted by provider.only. Also sent on every streamed chunk and as the X-ModelRelay-Provider header.",
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/ChatCompletionUsage"
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices",
          "usage"
        ],
        "type": "object"
      },
      "ChatCompletionResponseChoice": {
        "additionalProperties": false,
        "properties": {
          "finish_reason": {
            "enum": [
              "stop",
              "length",
              "content_filter",
              "tool_calls"
            ],
            "type": "string",
            "x-enum-varnames": [
              "ChatCompletionFinishReasonStop",
              "ChatCompletionFinishReasonLength",
              "ChatCompletionFinishReasonContentFilter",
              "ChatCompletionFinishReasonToolCalls"
            ]
          },
          "index": {
            "const": 0,
            "type": "integer"
          },
          "message": {
            "$ref": "#/components/schemas/ChatCompletionResponseMessage"
          },
          "logprobs": {
            "nullable": true,
            "additionalProperties": false,
            "properties": {
              "content": {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              }
            },
            "required": [
              "content"
            ],
            "type": "object"
          }
        },
        "required": [
          "index",
          "message",
          "finish_reason",
          "logprobs"
        ],
        "type": "object"
      },
      "ChatCompletionResponseMessage": {
        "additionalProperties": false,
        "properties": {
          "content": {
            "type": "string",
            "nullable": true
          },
          "role": {
            "const": "assistant",
            "type": "string"
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "type",
                "function"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "type": {
                  "type": "string",
                  "const": "function"
                },
                "function": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "name",
                    "arguments"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "arguments": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "refusal": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "role",
          "content"
        ],
        "type": "object"
      },
      "ChatCompletionUsage": {
        "additionalProperties": false,
        "properties": {
          "completion_tokens": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "prompt_tokens": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "prompt_tokens_details": {
            "additionalProperties": false,
            "properties": {
              "cached_tokens": {
                "default": 0,
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              },
              "cache_write_tokens": {
                "default": 0,
                "format": "uint64",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "cached_tokens",
              "cache_write_tokens"
            ],
            "type": "object"
          },
          "total_tokens": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "completion_tokens_details": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "reasoning_tokens": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "reasoning_tokens"
            ]
          }
        },
        "required": [
          "prompt_tokens",
          "completion_tokens",
          "total_tokens"
        ],
        "type": "object"
      },
      "OpenAICompatibleErrorResponse": {
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "nullable": true,
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "param": {
                "nullable": true,
                "type": "string"
              },
              "type": {
                "type": "string"
              }
            },
            "required": [
              "message",
              "type",
              "param",
              "code"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "ResponsesBatchError": {
        "properties": {
          "batch_id": {
            "type": "string"
          },
          "cause": {
            "enum": [
              "validation",
              "authentication",
              "authorization",
              "rate_limit",
              "timeout",
              "canceled",
              "transport",
              "upstream_response",
              "invalid_response",
              "unavailable",
              "internal"
            ],
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "detail": {
            "description": "Provider-originated safe error detail",
            "type": "string"
          },
          "item_id": {
            "type": "string"
          },
          "layer": {
            "enum": [
              "request",
              "routing",
              "modelrelay",
              "provider_integration",
              "upstream"
            ],
            "x-enum-varnames": [
              "ResponsesBatchErrorLayerRequest",
              "ResponsesBatchErrorLayerRouting",
              "ResponsesBatchErrorLayerModelrelay",
              "ResponsesBatchErrorLayerProviderIntegration",
              "ResponsesBatchErrorLayerUpstream"
            ],
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "status_code": {
            "type": "integer"
          },
          "request_id": {
            "type": "string"
          },
          "provider_request_id": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          }
        },
        "required": [
          "status",
          "message",
          "code",
          "layer",
          "cause",
          "status_code",
          "retryable"
        ],
        "type": "object"
      },
      "ResponsesBatchRequest": {
        "type": "object",
        "properties": {
          "requests": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResponsesBatchItem"
            }
          },
          "options": {
            "type": "object",
            "properties": {
              "max_concurrent": {
                "type": "integer",
                "format": "uint32",
                "minimum": 1,
                "maximum": 100
              },
              "fail_fast": {
                "type": "boolean"
              },
              "timeout_ms": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        },
        "required": [
          "requests"
        ]
      },
      "ResponsesBatchResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ResponsesBatchResult"
            }
          },
          "usage": {
            "$ref": "#/components/schemas/ResponsesBatchUsage"
          }
        },
        "required": [
          "id",
          "results",
          "usage"
        ]
      },
      "ResponsesBatchResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "success",
              "error"
            ]
          },
          "response": {
            "$ref": "#/components/schemas/ResponsesResponse"
          },
          "error": {
            "$ref": "#/components/schemas/ResponsesBatchError"
          }
        },
        "required": [
          "id",
          "status"
        ]
      },
      "ResponsesRequest": {
        "properties": {
          "depth": {
            "description": "Recursion depth of a call made against an execution grant: 0 is the outermost call, and anything deeper draws on the grant's subcall budget and is priced at its subcall rate. Only the engine running the program knows this, so the engine states it. Ignored without a grant credential, which authorizes no recursion to bound.",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "input": {
            "items": {
              "$ref": "#/components/schemas/InputItem"
            },
            "type": "array"
          },
          "max_output_tokens": {
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "max_input_tokens": {
            "description": "Optional ModelRelay admission ceiling for request-represented text input tokens. When present, it must cover the serialized request, a conservative provider wire representation of each tool/output schema, and the 4096-token provider-framing allowance; it is also validated against every reachable pricing band and the selected model's context window. It cannot bound state_id, file/multimodal input, relay- or provider-executed tools, or a schema whose provider wire size cannot be established safely; combining those shapes with max_input_tokens is rejected. This is not forwarded to providers. When omitted, self-contained text requests with client function tools authorize against that expanded request estimate. Shapes with provider input not represented by request bytes, and schemas without a safe finite wire-size estimate for the selected provider, authorize against the full context window.",
            "format": "int32",
            "minimum": 4097,
            "type": "integer"
          },
          "model": {
            "$ref": "#/components/schemas/RoutedModelId"
          },
          "preset": {
            "$ref": "#/components/schemas/PresetCode"
          },
          "output_format": {
            "$ref": "#/components/schemas/OutputFormat"
          },
          "provider": {
            "description": "Either a provider slug, which pins the request to that provider's route and never falls back, or a provider routing object (the same one Chat Completions accepts) that orders, filters and sorts the model's routes.",
            "oneOf": [
              {
                "$ref": "#/components/schemas/ProviderId"
              },
              {
                "$ref": "#/components/schemas/ProviderPreference"
              }
            ]
          },
          "prompt_cache": {
            "$ref": "#/components/schemas/PromptCache"
          },
          "response_cache": {
            "$ref": "#/components/schemas/ResponseCache"
          },
          "state_id": {
            "format": "uuid",
            "type": "string"
          },
          "stop": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "temperature": {
            "type": "number"
          },
          "top_p": {
            "maximum": 1,
            "minimum": 0,
            "type": "number"
          },
          "top_logprobs": {
            "description": "Request token log-probability facts and up to this many alternatives per output token. Unsupported providers fail explicitly.",
            "maximum": 20,
            "minimum": 0,
            "type": "integer"
          },
          "tool_choice": {
            "$ref": "#/components/schemas/ToolChoice"
          },
          "tools": {
            "items": {
              "$ref": "#/components/schemas/Tool"
            },
            "type": "array"
          },
          "reasoning_effort": {
            "description": "Reasoning/thinking effort for the model: 'none' disables thinking where the provider supports it; 'minimal'/'low'/'medium'/'high'/'xhigh'/'max' scale it. Empty uses the provider default. Provider/model discovery reports the exact supported subset; unsupported values are rejected rather than substituted.",
            "type": "string",
            "enum": [
              "none",
              "minimal",
              "low",
              "medium",
              "high",
              "xhigh",
              "max"
            ]
          },
          "parallel_tool_calls": {
            "type": "boolean",
            "nullable": true
          },
          "zdr": {
            "type": "boolean",
            "nullable": true,
            "description": "When true, restrict inference routing to routes with a known zero data retention policy, including native provider pins. Standard and unknown policies fail closed. False, null or omission adds no requirement and cannot disable account or API-key require_zdr. Request-level ZDR does not disable provider prompt caching, explicit gateway response_cache, state_id or tools; credential-level storage restrictions still apply. This does not provide end-to-end encryption or prove provider compliance."
          },
          "router": {
            "$ref": "#/components/schemas/AutoRouterOptions"
          }
        },
        "required": [
          "input"
        ],
        "not": {
          "required": [
            "model",
            "preset"
          ]
        },
        "type": "object"
      },
      "ResponsesResponse": {
        "properties": {
          "citations": {
            "description": "Sources from web search results",
            "items": {
              "$ref": "#/components/schemas/Citation"
            },
            "type": "array"
          },
          "id": {
            "description": "Unique response identifier. Cache hits receive a fresh ModelRelay response identifier.",
            "type": "string"
          },
          "execution_origin": {
            "description": "Whether this response was generated by a provider call or replayed from the exact response cache.",
            "enum": [
              "provider",
              "response_cache"
            ],
            "type": "string"
          },
          "model": {
            "$ref": "#/components/schemas/ModelId"
          },
          "output": {
            "items": {
              "$ref": "#/components/schemas/OutputItem"
            },
            "type": "array"
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderId"
          },
          "stop_reason": {
            "description": "Why generation stopped (stop, max_tokens, tool_use, etc.)",
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "execution_origin",
          "id",
          "output",
          "model",
          "usage"
        ],
        "type": "object"
      },
      "ResponseCache": {
        "additionalProperties": false,
        "description": "Opt-in Redis-backed exact response memoization for pure, non-streaming /responses requests. The policy is not forwarded to providers.",
        "properties": {
          "ttl_seconds": {
            "format": "int64",
            "maximum": 86400,
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "ttl_seconds"
        ],
        "type": "object"
      },
      "PromptCache": {
        "additionalProperties": false,
        "description": "Provider-side prompt reuse affinity. ModelRelay tenant-scopes the caller key before forwarding it; this does not memoize a response.",
        "properties": {
          "key": {
            "maxLength": 256,
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "key"
        ],
        "type": "object"
      },
      "ResponsesStreamEnvelope": {
        "properties": {
          "code": {
            "type": "string"
          },
          "cause": {
            "enum": [
              "validation",
              "authentication",
              "authorization",
              "rate_limit",
              "timeout",
              "canceled",
              "transport",
              "upstream_response",
              "invalid_response",
              "unavailable",
              "internal"
            ],
            "type": "string"
          },
          "complete_fields": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "content": {
            "type": "string"
          },
          "delta": {
            "type": "string"
          },
          "detail": {
            "description": "Provider-originated safe detail only",
            "type": "string"
          },
          "layer": {
            "enum": [
              "request",
              "routing",
              "modelrelay",
              "provider_integration",
              "upstream"
            ],
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "model": {
            "$ref": "#/components/schemas/ModelId"
          },
          "patch": {
            "items": {
              "$ref": "#/components/schemas/JSONPatchOperation"
            },
            "type": "array"
          },
          "payload": {
            "additionalProperties": true,
            "type": "object"
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderId"
          },
          "provider_request_id": {
            "type": "string"
          },
          "request_id": {
            "type": "string"
          },
          "status": {
            "description": "Numeric HTTP status on errors; incomplete on empty token-limit completions.",
            "oneOf": [
              { "type": "integer" },
              { "type": "string", "enum": ["incomplete"] }
            ]
          },
          "incomplete_details": {
            "type": "object",
            "required": ["reason"],
            "properties": {
              "reason": { "type": "string", "enum": ["max_output_tokens"] }
            }
          },
          "status_code": {
            "type": "integer"
          },
          "retryable": {
            "type": "boolean"
          },
          "stop_reason": {
            "type": "string"
          },
          "stream_mode": {
            "enum": [
              "text-delta",
              "structured-patch"
            ],
            "type": "string"
          },
          "stream_version": {
            "enum": [
              "v2"
            ],
            "type": "string"
          },
          "type": {
            "enum": [
              "start",
              "update",
              "completion",
              "error",
              "keepalive",
              "tool_use_start",
              "tool_use_delta",
              "tool_use_stop"
            ],
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "type"
        ],
        "type": "object"
      },
      "SQLPolicy": {
        "properties": {
          "aggregations": {
            "$ref": "#/components/schemas/SQLPolicyAggregations"
          },
          "columns": {
            "$ref": "#/components/schemas/SQLPolicyColumns"
          },
          "dialect": {
            "enum": [
              "sqlite",
              "postgres",
              "mysql",
              "sqlserver"
            ],
            "type": "string"
          },
          "fts": {
            "$ref": "#/components/schemas/SQLPolicyFTS"
          },
          "joins": {
            "$ref": "#/components/schemas/SQLPolicyJoins"
          },
          "limits": {
            "$ref": "#/components/schemas/SQLPolicyLimits"
          },
          "ordering": {
            "$ref": "#/components/schemas/SQLPolicyOrdering"
          },
          "read_only": {
            "type": "boolean"
          },
          "schema_hints": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "subqueries": {
            "$ref": "#/components/schemas/SQLPolicySubqueries"
          },
          "tables": {
            "$ref": "#/components/schemas/SQLPolicyTables"
          }
        },
        "required": [
          "dialect",
          "read_only"
        ],
        "type": "object"
      },
      "SQLPolicyAggregations": {
        "properties": {
          "allowed": {
            "type": "boolean"
          },
          "functions": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "SQLPolicyColumns": {
        "properties": {
          "allowed": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "hidden": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "SQLPolicyFTS": {
        "properties": {
          "default_order": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "enabled": {
            "type": "boolean"
          },
          "match_required": {
            "type": "boolean"
          },
          "rank_expr": {
            "type": "string"
          },
          "table": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "SQLPolicyJoins": {
        "properties": {
          "allowed_patterns": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "max_joins": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "SQLPolicyLimits": {
        "properties": {
          "default_limit": {
            "type": "integer"
          },
          "max_limit": {
            "type": "integer"
          },
          "timeout_ms": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "SQLPolicyOrdering": {
        "properties": {
          "inject": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "require": {
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "SQLPolicySubqueries": {
        "properties": {
          "allowed": {
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "SQLPolicyTables": {
        "properties": {
          "allowlist": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "denylist": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "SQLProfile": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "policy": {
            "$ref": "#/components/schemas/SQLPolicy"
          },
          "project_id": {
            "format": "uuid",
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "SQLProfileInput": {
        "properties": {
          "name": {
            "type": "string"
          },
          "policy": {
            "$ref": "#/components/schemas/SQLPolicy"
          }
        },
        "required": [
          "name",
          "policy"
        ],
        "type": "object"
      },
      "SQLProfileUpdate": {
        "properties": {
          "name": {
            "type": "string"
          },
          "policy": {
            "$ref": "#/components/schemas/SQLPolicy"
          }
        },
        "required": [
          "name",
          "policy"
        ],
        "type": "object"
      },
      "SQLValidateOverrides": {
        "properties": {
          "limit": {
            "description": "Override row limit for validation",
            "format": "int64",
            "type": "integer"
          },
          "timeout_ms": {
            "description": "Override timeout in milliseconds",
            "format": "int64",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "SQLValidateRequest": {
        "description": "Validate a SQL query against a policy or profile",
        "properties": {
          "overrides": {
            "$ref": "#/components/schemas/SQLValidateOverrides"
          },
          "policy": {
            "$ref": "#/components/schemas/SQLPolicy"
          },
          "profile_id": {
            "format": "uuid",
            "type": "string"
          },
          "sql": {
            "description": "SQL query to validate",
            "type": "string"
          }
        },
        "required": [
          "sql"
        ],
        "type": "object"
      },
      "SQLValidateResponse": {
        "description": "SQL validation result",
        "properties": {
          "limit": {
            "type": "integer"
          },
          "normalized_sql": {
            "type": "string"
          },
          "order_by": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "read_only": {
            "type": "boolean"
          },
          "tables": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "timeout_ms": {
            "type": "integer"
          },
          "valid": {
            "type": "boolean"
          }
        },
        "required": [
          "valid",
          "normalized_sql",
          "read_only"
        ],
        "type": "object"
      },
      "Sha256Hash": {
        "description": "SHA-256 hash (64 hex characters).",
        "maxLength": 64,
        "minLength": 64,
        "pattern": "^[a-f0-9]{64}$",
        "type": "string"
      },
      "StateHandleCreateRequest": {
        "properties": {
          "ttl_seconds": {
            "description": "TTL in seconds for the state handle. Maximum is 1 year (31536000 seconds).",
            "format": "int64",
            "maximum": 31536000,
            "minimum": 1,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "StateHandleListResponse": {
        "properties": {
          "next_cursor": {
            "type": "string"
          },
          "state_handles": {
            "items": {
              "$ref": "#/components/schemas/StateHandleResponse"
            },
            "type": "array"
          }
        },
        "required": [
          "state_handles"
        ],
        "type": "object"
      },
      "StateHandleResponse": {
        "properties": {
          "created_at": {
            "type": "string"
          },
          "customer_id": {
            "format": "uuid",
            "type": "string"
          },
          "expires_at": {
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "project_id": {
            "format": "uuid",
            "type": "string"
          }
        },
        "required": [
          "id",
          "project_id",
          "created_at"
        ],
        "type": "object"
      },
      "Subscription": {
        "properties": {
          "billing_provider": {
            "$ref": "#/components/schemas/BillingProvider"
          },
          "billing_subscription_id": {
            "description": "Billing subscription ID from the provider",
            "type": "string"
          },
          "cancel_at_period_end": {
            "description": "Whether the subscription will end after the current billing period instead of renewing",
            "type": "boolean"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "current_period_end": {
            "description": "End of the current billing period",
            "format": "date-time",
            "type": "string"
          },
          "current_period_start": {
            "description": "Start of the current billing period",
            "format": "date-time",
            "type": "string"
          },
          "customer_id": {
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "project_id": {
            "format": "uuid",
            "type": "string"
          },
          "subscription_status": {
            "$ref": "#/components/schemas/SubscriptionStatusKind"
          },
          "tier_code": {
            "$ref": "#/components/schemas/TierCode"
          },
          "tier_id": {
            "format": "uuid",
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "SubscriptionStatus": {
        "description": "Subscription status for a customer.",
        "properties": {
          "active": {
            "description": "Whether the subscription is currently active",
            "type": "boolean"
          },
          "current_period_end": {
            "description": "End of the current billing period",
            "format": "date-time",
            "type": "string"
          },
          "current_period_start": {
            "description": "Start of the current billing period",
            "format": "date-time",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/SubscriptionStatusKind"
          },
          "subscription_id": {
            "description": "Stripe subscription ID",
            "type": "string"
          }
        },
        "required": [
          "active"
        ],
        "type": "object"
      },
      "SubscriptionStatusKind": {
        "description": "Subscription status (active, past_due, canceled, etc.)",
        "enum": [
          "active",
          "trialing",
          "past_due",
          "canceled",
          "unpaid",
          "incomplete",
          "incomplete_expired",
          "paused"
        ],
        "x-enum-varnames": [
          "SubscriptionStatusKindActive",
          "SubscriptionStatusKindTrialing",
          "SubscriptionStatusKindPastDue",
          "SubscriptionStatusKindCanceled",
          "SubscriptionStatusKindUnpaid",
          "SubscriptionStatusKindIncomplete",
          "SubscriptionStatusKindIncompleteExpired",
          "SubscriptionStatusKindPaused"
        ],
        "type": "string",
        "x-rust-type": {
          "crate": "modelrelay",
          "path": "modelrelay::SubscriptionStatusKind",
          "version": "0.1"
        }
      },
      "Tier": {
        "properties": {
          "billing_mode": {
            "$ref": "#/components/schemas/TierBillingMode"
          },
          "billing_price_ref": {
            "description": "Billing provider price reference for this tier",
            "type": "string"
          },
          "billing_provider": {
            "$ref": "#/components/schemas/BillingProvider"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "display_name": {
            "description": "Human-readable tier name",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "models": {
            "items": {
              "$ref": "#/components/schemas/TierModel"
            },
            "minItems": 1,
            "type": "array"
          },
          "overage_enabled": {
            "description": "Whether subscription usage beyond the included spend limit may use the billing profile wallet. Defaults to false. PAYGO tiers must set this to false.",
            "type": "boolean"
          },
          "price_amount_cents": {
            "description": "Subscription price amount in cents",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "price_currency": {
            "description": "Currency code for the price (e.g., 'usd')",
            "type": "string"
          },
          "price_interval": {
            "$ref": "#/components/schemas/PriceInterval"
          },
          "project_id": {
            "format": "uuid",
            "type": "string"
          },
          "spend_limit_cents": {
            "description": "Spend ceiling in cents for a billing window (e.g., 2000 = $20/month). Absent or null means the tier has no ceiling; 0 is a real ceiling that permits no spend. A ceiling is effective-dated: changing it governs the next billing window, never one already open.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer",
            "nullable": true
          },
          "tier_code": {
            "$ref": "#/components/schemas/TierCode"
          },
          "trial_days": {
            "description": "Number of trial days for new subscriptions",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "promo_credits_cents": {
            "description": "One-time promotional credits in cents applied when a customer first subscribes to the tier.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "presets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TierPreset"
            },
            "description": "Named role-aware model routing choices for this tier (optional)."
          }
        },
        "type": "object"
      },
      "TierBillingMode": {
        "description": "Billing mode for a tier. 'subscription' uses monthly spend limits; 'paygo' uses prepaid balances.",
        "enum": [
          "subscription",
          "paygo"
        ],
        "type": "string"
      },
      "TierCode": {
        "description": "Tier code identifier (e.g., free, pro, enterprise).",
        "maxLength": 64,
        "minLength": 1,
        "pattern": "^[a-z][a-z0-9_-]*$",
        "type": "string"
      },
      "TierCreate": {
        "properties": {
          "billing_mode": {
            "$ref": "#/components/schemas/TierBillingMode"
          },
          "billing_provider": {
            "$ref": "#/components/schemas/BillingProvider"
          },
          "display_name": {
            "description": "Human-readable tier name",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "models": {
            "items": {
              "$ref": "#/components/schemas/TierModelCreate"
            },
            "minItems": 1,
            "type": "array"
          },
          "overage_enabled": {
            "description": "Whether subscription usage beyond the included spend limit may use the billing profile wallet. Defaults to false. PAYGO tiers must set this to false.",
            "type": "boolean"
          },
          "price_amount_cents": {
            "description": "Subscription price amount in cents (paid tiers)",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "price_interval": {
            "$ref": "#/components/schemas/PriceInterval"
          },
          "spend_limit_cents": {
            "description": "Spend ceiling in cents for a billing window (e.g., 2000 = $20/month). Absent or null means the tier has no ceiling; 0 is a real ceiling that permits no spend. A ceiling is effective-dated: changing it governs the next billing window, never one already open.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer",
            "nullable": true
          },
          "tier_code": {
            "$ref": "#/components/schemas/TierCode"
          },
          "trial_days": {
            "description": "Number of trial days for new subscriptions (paid tiers)",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "promo_credits_cents": {
            "description": "One-time promotional credits in cents applied when a customer first subscribes to the tier.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "tier_code",
          "display_name",
          "models"
        ],
        "type": "object"
      },
      "TierModel": {
        "properties": {
          "capabilities": {
            "description": "Workflow-critical capability flags for the model",
            "items": {
              "$ref": "#/components/schemas/ModelCapability"
            },
            "type": "array"
          },
          "context_window": {
            "description": "Maximum supported context window in tokens (if known)",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "deprecated": {
            "description": "Whether the model is deprecated",
            "type": "boolean"
          },
          "description": {
            "description": "Human-friendly description of what the model is good at",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "is_default": {
            "description": "Whether this is the default model for the tier",
            "type": "boolean"
          },
          "max_output_tokens": {
            "description": "Maximum supported output tokens (if known)",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "model_display_name": {
            "description": "Human-friendly model name resolved from pricing (e.g., 'GPT-4o Mini')",
            "type": "string"
          },
          "model_id": {
            "$ref": "#/components/schemas/ModelId"
          },
          "model_cost_projection_available": {
            "description": "Whether the authoritative full-card rates are exactly representable by the legacy cents-per-million display fields. False means the scalar cost fields are unavailable, not free.",
            "type": "boolean"
          },
          "tier_id": {
            "format": "uuid",
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "model_input_cost_millicents": {
            "description": "Provider input rate in millicents per million tokens. Absent when the route has no exact scalar projection.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "model_output_cost_millicents": {
            "description": "Provider output rate in millicents per million tokens. Absent when the route has no exact scalar projection.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "id",
          "tier_id",
          "model_id",
          "model_display_name",
          "description",
          "capabilities",
          "context_window",
          "max_output_tokens",
          "deprecated",
          "model_cost_projection_available",
          "is_default",
          "created_at",
          "updated_at"
        ],
        "type": "object"
      },
      "TierModelCreate": {
        "description": "Model to add to a tier. Pricing is derived from the model_pricing table.",
        "properties": {
          "is_default": {
            "default": false,
            "type": "boolean"
          },
          "model_id": {
            "$ref": "#/components/schemas/ModelId"
          }
        },
        "required": [
          "model_id"
        ],
        "type": "object"
      },
      "TierUpdate": {
        "properties": {
          "billing_provider": {
            "$ref": "#/components/schemas/BillingProvider"
          },
          "display_name": {
            "description": "Human-readable tier name",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "models": {
            "items": {
              "$ref": "#/components/schemas/TierModelCreate"
            },
            "minItems": 1,
            "type": "array"
          },
          "overage_enabled": {
            "description": "Whether subscription usage beyond the included spend limit may use the billing profile wallet. Defaults to false. PAYGO tiers must set this to false.",
            "type": "boolean"
          },
          "price_amount_cents": {
            "description": "Subscription price amount in cents (paid tiers)",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "price_interval": {
            "$ref": "#/components/schemas/PriceInterval"
          },
          "spend_limit_cents": {
            "description": "Spend ceiling in cents for a billing window (e.g., 2000 = $20/month). Absent or null means the tier has no ceiling; 0 is a real ceiling that permits no spend. A ceiling is effective-dated: changing it governs the next billing window, never one already open.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer",
            "nullable": true
          },
          "tier_code": {
            "$ref": "#/components/schemas/TierCode"
          },
          "trial_days": {
            "description": "Number of trial days for new subscriptions (paid tiers)",
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "promo_credits_cents": {
            "description": "One-time promotional credits in cents applied when a customer first subscribes to the tier.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "tier_code",
          "display_name"
        ],
        "type": "object"
      },
      "Tool": {
        "properties": {
          "code_execution": {
            "additionalProperties": true,
            "type": "object"
          },
          "function": {
            "properties": {
              "description": {
                "type": "string"
              },
              "name": {
                "$ref": "#/components/schemas/ToolName"
              },
              "parameters": {
                "additionalProperties": true,
                "type": "object"
              },
              "strict": {
                "type": "boolean",
                "nullable": true
              }
            },
            "type": "object"
          },
          "image_generation": {
            "description": "Configuration for server-side image generation tool",
            "properties": {
              "model": {
                "description": "Image generation model ID (e.g., gemini-2.5-flash-image)",
                "type": "string"
              }
            },
            "required": [
              "model"
            ],
            "type": "object"
          },
          "type": {
            "enum": [
              "function",
              "web",
              "x_search",
              "code_execution",
              "image_generation"
            ],
            "type": "string"
          },
          "web": {
            "additionalProperties": true,
            "type": "object"
          },
          "x_search": {
            "additionalProperties": true,
            "type": "object"
          }
        },
        "required": [
          "type"
        ],
        "type": "object"
      },
      "ToolCall": {
        "properties": {
          "function": {
            "properties": {
              "arguments": {
                "description": "JSON string of function arguments",
                "type": "string"
              },
              "name": {
                "$ref": "#/components/schemas/ToolName"
              }
            },
            "type": "object"
          },
          "id": {
            "$ref": "#/components/schemas/ToolCallId"
          },
          "type": {
            "enum": [
              "function",
              "web",
              "x_search",
              "code_execution",
              "image_generation"
            ],
            "type": "string"
          }
        },
        "required": [
          "id",
          "type"
        ],
        "type": "object"
      },
      "ToolCallDelta": {
        "description": "Incremental tool call data during streaming",
        "properties": {
          "function": {
            "properties": {
              "arguments": {
                "description": "Partial JSON string",
                "type": "string"
              },
              "name": {
                "$ref": "#/components/schemas/ToolName"
              }
            },
            "type": "object"
          },
          "id": {
            "$ref": "#/components/schemas/ToolCallId"
          },
          "index": {
            "format": "uint32",
            "minimum": 0,
            "type": "integer"
          },
          "type": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "ToolCallId": {
        "description": "Unique identifier for a tool call. Treated as an opaque string and must be preserved exactly.",
        "maxLength": 256,
        "minLength": 1,
        "type": "string"
      },
      "ToolChoice": {
        "properties": {
          "function": {
            "$ref": "#/components/schemas/ToolName"
          },
          "type": {
            "enum": [
              "auto",
              "required",
              "none"
            ],
            "type": "string",
            "x-enum-varnames": [
              "ToolChoiceTypeAuto",
              "ToolChoiceTypeRequired",
              "ToolChoiceTypeNone"
            ]
          }
        },
        "required": [
          "type"
        ],
        "type": "object"
      },
      "ToolHookConfig": {
        "properties": {
          "allow_mutation": {
            "type": "boolean"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "endpoint_url": {
            "format": "uri",
            "type": "string"
          },
          "fail_behavior": {
            "enum": [
              "fail_closed",
              "fail_open"
            ],
            "type": "string"
          },
          "hook_type": {
            "enum": [
              "pre_tool_use",
              "post_tool_use",
              "tool_execute"
            ],
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "project_id": {
            "format": "uuid",
            "type": "string"
          },
          "timeout_ms": {
            "format": "int32",
            "type": "integer"
          },
          "tools_allowlist": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "ToolHookConfigInput": {
        "properties": {
          "allow_mutation": {
            "type": "boolean"
          },
          "enabled": {
            "type": "boolean"
          },
          "endpoint_url": {
            "format": "uri",
            "type": "string"
          },
          "fail_behavior": {
            "enum": [
              "fail_closed",
              "fail_open"
            ],
            "type": "string"
          },
          "hook_type": {
            "enum": [
              "pre_tool_use",
              "post_tool_use",
              "tool_execute"
            ],
            "type": "string"
          },
          "timeout_ms": {
            "format": "int32",
            "type": "integer"
          },
          "tools_allowlist": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "hook_type",
          "endpoint_url"
        ],
        "type": "object"
      },
      "ToolHookConfigUpdate": {
        "properties": {
          "allow_mutation": {
            "type": "boolean"
          },
          "enabled": {
            "type": "boolean"
          },
          "endpoint_url": {
            "format": "uri",
            "type": "string"
          },
          "fail_behavior": {
            "enum": [
              "fail_closed",
              "fail_open"
            ],
            "type": "string"
          },
          "rotate_secret": {
            "type": "boolean"
          },
          "timeout_ms": {
            "format": "int32",
            "type": "integer"
          },
          "tools_allowlist": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "ToolHookEvent": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "hook_config_id": {
            "format": "uuid",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "latency_ms": {
            "format": "int32",
            "type": "integer"
          },
          "request_id": {
            "type": "string"
          },
          "response_body": {
            "type": "string"
          },
          "response_status": {
            "format": "int32",
            "type": "integer"
          },
          "status": {
            "enum": [
              "success",
              "blocked",
              "timeout",
              "error"
            ],
            "type": "string",
            "x-enum-varnames": [
              "Success",
              "Blocked",
              "Timeout",
              "Error"
            ]
          },
          "tool_call_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "ToolHookTestResult": {
        "properties": {
          "error": {
            "type": "string"
          },
          "latency_ms": {
            "format": "int32",
            "type": "integer"
          },
          "response_body": {
            "type": "string"
          },
          "response_status": {
            "format": "int32",
            "type": "integer"
          },
          "status": {
            "enum": [
              "success",
              "blocked",
              "timeout",
              "error"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "ToolName": {
        "description": "Tool identifier. For tools.v0 client tools, use dot-separated lowercase segments (e.g. fs.search).",
        "maxLength": 128,
        "minLength": 1,
        "pattern": "^[a-z][a-z0-9_]*(\\\\.[a-z][a-z0-9_]*)*$",
        "type": "string"
      },
      "Usage": {
        "description": "Provider token usage with explicit observation fidelity. Every counter is present; zero is an observed zero, not a missing category.",
        "properties": {
          "input_tokens": {
            "default": 0,
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "cache_read_input_tokens": {
            "default": 0,
            "description": "Input-token subset served from a provider prompt cache.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "cache_write_input_tokens": {
            "default": 0,
            "description": "Input-token subset written to a provider prompt cache.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "output_tokens": {
            "default": 0,
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "reasoning_tokens": {
            "default": 0,
            "description": "Output-token subset consumed by model reasoning.",
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "observation_basis": {
            "description": "Provider token observation fidelity. unavailable and incomplete usage cannot settle reservations; estimated_categories has a complete input/output vector but lacks one or more optional category-presence facts; exact explicitly observes every supported category.",
            "type": "string",
            "enum": [
              "unavailable",
              "incomplete",
              "estimated_categories",
              "exact"
            ],
            "x-enum-varnames": [
              "UsageObservationUnavailable",
              "UsageObservationIncomplete",
              "UsageObservationEstimatedCategories",
              "UsageObservationExact"
            ]
          },
          "total_tokens": {
            "default": 0,
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "input_tokens",
          "output_tokens",
          "total_tokens",
          "reasoning_tokens",
          "cache_read_input_tokens",
          "cache_write_input_tokens",
          "observation_basis"
        ],
        "type": "object"
      },
      "User": {
        "properties": {
          "email": {
            "format": "email",
            "type": "string"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "project_id": {
            "format": "uuid",
            "type": "string"
          }
        },
        "type": "object"
      },
      "WebhookConfig": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "endpoint_url": {
            "format": "uri",
            "type": "string"
          },
          "events": {
            "items": {
              "enum": [
                "customer.created",
                "customer.updated",
                "customer.deleted",
                "usage.threshold_exceeded",
                "request.completed",
                "billing.subscription_changed",
                "account.admission_blocked"
              ],
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "format": "uuid",
            "type": "string"
          },
          "project_id": {
            "format": "uuid",
            "type": "string"
          },
          "signing_secret": {
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "WebhookConfigInput": {
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "endpoint_url": {
            "format": "uri",
            "type": "string"
          },
          "events": {
            "items": {
              "enum": [
                "customer.created",
                "customer.updated",
                "customer.deleted",
                "usage.threshold_exceeded",
                "request.completed",
                "billing.subscription_changed",
                "account.admission_blocked"
              ],
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "endpoint_url",
          "events"
        ],
        "type": "object"
      },
      "WebhookConfigUpdate": {
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "endpoint_url": {
            "format": "uri",
            "type": "string"
          },
          "events": {
            "items": {
              "enum": [
                "customer.created",
                "customer.updated",
                "customer.deleted",
                "usage.threshold_exceeded",
                "request.completed",
                "billing.subscription_changed",
                "account.admission_blocked"
              ],
              "type": "string"
            },
            "type": "array"
          },
          "rotate_secret": {
            "type": "boolean"
          }
        },
        "required": [
          "endpoint_url",
          "events"
        ],
        "type": "object"
      },
      "WebhookTestResult": {
        "properties": {
          "error": {
            "type": "string"
          },
          "latency_ms": {
            "format": "int32",
            "type": "integer"
          },
          "response_body": {
            "type": "string"
          },
          "response_status": {
            "format": "int32",
            "type": "integer"
          },
          "status": {
            "enum": [
              "delivered",
              "failed"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "ResponsesBatchItem": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ResponsesRequest"
          },
          {
            "type": "object",
            "not": {
              "required": [
                "response_cache"
              ]
            },
            "properties": {
              "id": {
                "type": "string"
              }
            },
            "required": [
              "id"
            ]
          }
        ],
        "description": "Single request item for batch responses.",
        "type": "object"
      },
      "ResponsesBatchUsage": {
        "type": "object",
        "properties": {
          "total_input_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "total_output_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "total_cache_read_input_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "total_cache_write_input_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "total_requests": {
            "type": "integer",
            "minimum": 0
          },
          "successful_requests": {
            "type": "integer",
            "minimum": 0
          },
          "failed_requests": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "total_input_tokens",
          "total_output_tokens",
          "total_cache_read_input_tokens",
          "total_cache_write_input_tokens",
          "total_requests",
          "successful_requests",
          "failed_requests"
        ]
      },
      "RLMExecutionRoleEvidence": {
        "additionalProperties": false,
        "properties": {
          "model": {
            "type": "string"
          },
          "reasoning_effort": {
            "type": "string"
          },
          "max_output_tokens": {
            "format": "int64",
            "type": "integer"
          },
          "max_input_tokens": {
            "description": "Optional host-owned admission ceiling on request-represented input. When present it exceeds the provider-framing allowance.",
            "format": "int64",
            "minimum": 4097,
            "type": "integer"
          }
        },
        "required": [
          "model",
          "max_output_tokens"
        ],
        "type": "object"
      },
      "RLMExecutionLimitsEvidence": {
        "description": "The effective v2 execution limits authorized for this run.",
        "additionalProperties": false,
        "properties": {
          "max_subcalls": {
            "type": "integer"
          },
          "max_depth": {
            "type": "integer"
          },
          "timeout_ms": {
            "type": "integer"
          },
          "max_concurrency": {
            "type": "integer"
          },
          "max_total_tokens": {
            "format": "int64",
            "type": "integer"
          },
          "max_settled_spend_microcents": {
            "description": "Optional host-owned settled-spend ceiling; it may tighten but never widen the token-derived bound.",
            "format": "int64",
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "max_subcalls",
          "max_depth",
          "timeout_ms",
          "max_concurrency",
          "max_total_tokens"
        ],
        "type": "object"
      },
      "RLMProfileLimits": {
        "description": "Limits stored in an immutable profile revision. v2 profiles use max_total_tokens; legacy v1 fields remain readable only so clients can migrate them and are not accepted for execution.",
        "additionalProperties": false,
        "properties": {
          "max_subcalls": {
            "type": "integer"
          },
          "max_depth": {
            "type": "integer"
          },
          "timeout_ms": {
            "type": "integer"
          },
          "max_concurrency": {
            "type": "integer"
          },
          "max_total_tokens": {
            "format": "int64",
            "type": "integer"
          },
          "max_settled_spend_microcents": {
            "description": "Optional host-owned settled-spend ceiling; it may tighten but never widen the token-derived bound.",
            "format": "int64",
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "max_subcalls",
          "max_depth",
          "timeout_ms",
          "max_concurrency"
        ],
        "type": "object"
      },
      "RLMExecutionProfileEvidence": {
        "additionalProperties": false,
        "properties": {
          "version": {
            "type": "string"
          },
          "selector": {
            "type": "string"
          },
          "revision_id": {
            "type": "string"
          },
          "revision_content_hash": {
            "type": "string"
          },
          "effective_fingerprint": {
            "type": "string"
          },
          "lifecycle": {
            "type": "string",
            "enum": [
              "experimental",
              "candidate",
              "default",
              "retired"
            ]
          },
          "root": {
            "$ref": "#/components/schemas/RLMExecutionRoleEvidence"
          },
          "subcall": {
            "$ref": "#/components/schemas/RLMExecutionRoleEvidence"
          },
          "limits": {
            "$ref": "#/components/schemas/RLMExecutionLimitsEvidence"
          },
          "policy_revision": {
            "type": "string"
          },
          "root_artifact_ref": {
            "$ref": "#/components/schemas/RLMArtifactRef"
          }
        },
        "required": [
          "version",
          "selector",
          "revision_id",
          "revision_content_hash",
          "effective_fingerprint",
          "lifecycle",
          "root",
          "subcall",
          "limits"
        ],
        "type": "object"
      },
      "ExecutionGrantResolveRequest": {
        "additionalProperties": false,
        "description": "Content-free request to resolve an existing immutable tier-scoped RLM execution profile before local Droste preflight.",
        "properties": {
          "preset": {
            "$ref": "#/components/schemas/PresetCode"
          },
          "temperature": {
            "type": "number"
          },
          "stop": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "seed": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          }
        },
        "required": [
          "preset",
          "seed"
        ],
        "type": "object"
      },
      "ExecutionGrantSampling": {
        "properties": {
          "temperature": {
            "type": "number"
          },
          "stop": {
            "type": "object",
            "properties": {
              "availability": {
                "type": "string",
                "enum": [
                  "available",
                  "unavailable"
                ]
              },
              "count": {
                "type": "integer"
              },
              "digest": {
                "type": "string"
              },
              "reason": {
                "type": "string"
              }
            },
            "required": [
              "availability"
            ]
          },
          "seed": {
            "$ref": "#/components/schemas/RLMSeedFact"
          }
        },
        "required": [
          "stop",
          "seed"
        ],
        "type": "object"
      },
      "ExecutionGrantResolveResponse": {
        "properties": {
          "profile": {
            "$ref": "#/components/schemas/RLMExecutionProfileEvidence"
          },
          "root_artifact": {
            "$ref": "#/components/schemas/RLMRootArtifact"
          },
          "sampling": {
            "$ref": "#/components/schemas/ExecutionGrantSampling"
          },
          "pricing": {
            "$ref": "#/components/schemas/RLMExecutionPricingEvidence"
          },
          "max_settled_spend_microcents": {
            "type": "integer",
            "format": "int64",
            "minimum": 1,
            "description": "Natural maximum in microcents (1 cent = 1,000,000 microcents), derived with checked integer arithmetic from the immutable pricing and execution budgets. Grant creation may tighten this to the positive allowance actually reserved."
          }
        },
        "required": [
          "profile",
          "sampling",
          "pricing",
          "max_settled_spend_microcents"
        ],
        "type": "object"
      },
      "ExecutionGrantCreateRequest": {
        "additionalProperties": false,
        "description": "Create a durable execution grant after local Droste preflight. Prompt, query, context, corpus, task, and chunk strategy are intentionally absent.",
        "properties": {
          "preset": {
            "$ref": "#/components/schemas/PresetCode"
          },
          "temperature": {
            "type": "number"
          },
          "stop": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "seed": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "scaffold_manifest": {
            "$ref": "#/components/schemas/RLMScaffoldManifest"
          },
          "expected_revision_id": {
            "type": "string"
          },
          "expected_revision_content_hash": {
            "type": "string"
          },
          "expected_effective_fingerprint": {
            "type": "string"
          }
        },
        "required": [
          "preset",
          "seed",
          "scaffold_manifest",
          "expected_revision_id",
          "expected_revision_content_hash",
          "expected_effective_fingerprint"
        ],
        "type": "object"
      },
      "ExecutionGrantCreateResponse": {
        "description": "A one-time execution credential and its immutable resolved authority. The credential is never returned by later reads.",
        "properties": {
          "grant_id": {
            "type": "string",
            "format": "uuid"
          },
          "credential": {
            "type": "string",
            "format": "password"
          },
          "credential_expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "execution_deadline": {
            "type": "string",
            "format": "date-time"
          },
          "spec_fingerprint": {
            "type": "string"
          },
          "profile": {
            "$ref": "#/components/schemas/RLMExecutionProfileEvidence"
          },
          "root_callback_path": {
            "type": "string"
          },
          "subcall_callback_path": {
            "type": "string"
          },
          "batch_callback_path": {
            "type": "string"
          },
          "max_settled_spend_microcents": {
            "type": "integer",
            "format": "int64",
            "minimum": 1,
            "description": "Effective immutable spend authority reserved for this grant. It is positive and never exceeds the natural maximum returned by resolve."
          }
        },
        "required": [
          "grant_id",
          "credential",
          "credential_expires_at",
          "execution_deadline",
          "spec_fingerprint",
          "profile",
          "root_callback_path",
          "subcall_callback_path",
          "batch_callback_path",
          "max_settled_spend_microcents"
        ],
        "type": "object"
      },
      "RLMCheckpointScaffoldRequirements": {
        "description": "Trusted checkpoint requirements that Droste validates against its actual scaffold before the first model inference.",
        "additionalProperties": false,
        "properties": {
          "manifest_id": {
            "type": "string"
          },
          "required": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "type": "object"
      },
      "RLMArtifactRef": {
        "description": "Immutable content-free identity of one trained-root artifact revision. artifact_id names an artifact family and may repeat across revisions; the full reference and enclosing profile content hash are authoritative.",
        "additionalProperties": false,
        "properties": {
          "artifact_id": {
            "type": "string"
          },
          "revision": {
            "type": "string"
          },
          "digest": {
            "type": "string",
            "pattern": "^sha256:[0-9a-fA-F]{64}$"
          }
        },
        "required": [
          "artifact_id",
          "revision",
          "digest"
        ],
        "type": "object"
      },
      "RLMRootArtifact": {
        "description": "Content-addressed trained-root artifact provenance bound into an RLM profile revision.",
        "additionalProperties": false,
        "properties": {
          "artifact_id": {
            "type": "string"
          },
          "revision": {
            "type": "string"
          },
          "digest": {
            "type": "string"
          },
          "base_model": {
            "type": "string"
          },
          "tokenizer": {
            "type": "string"
          },
          "chat_template": {
            "type": "string"
          },
          "serving_backend": {
            "type": "string"
          },
          "serving_model": {
            "type": "string"
          },
          "serving_revision": {
            "type": "string"
          },
          "composition": {
            "type": "string"
          },
          "evaluation_ref": {
            "type": "string"
          },
          "lifecycle": {
            "type": "string",
            "enum": [
              "experimental",
              "candidate",
              "default",
              "retired"
            ],
            "x-enum-varnames": [
              "RLMRootArtifactLifecycleExperimental",
              "RLMRootArtifactLifecycleCandidate",
              "RLMRootArtifactLifecycleDefault",
              "RLMRootArtifactLifecycleRetired"
            ]
          },
          "checkpoint_scaffold_requirements": {
            "$ref": "#/components/schemas/RLMCheckpointScaffoldRequirements"
          }
        },
        "required": [
          "artifact_id",
          "revision",
          "digest",
          "base_model",
          "tokenizer",
          "chat_template",
          "serving_backend",
          "serving_model",
          "serving_revision",
          "evaluation_ref",
          "lifecycle",
          "checkpoint_scaffold_requirements"
        ],
        "type": "object"
      },
      "RLMProfileRevision": {
        "description": "Content-addressed immutable RLM execution profile stored with a tier preset. v1 remains readable for hash verification and migration, but only v2 is executable.",
        "additionalProperties": false,
        "properties": {
          "version": {
            "type": "string"
          },
          "revision_id": {
            "type": "string"
          },
          "selector": {
            "type": "string"
          },
          "lifecycle": {
            "type": "string",
            "enum": [
              "experimental",
              "candidate",
              "default",
              "retired"
            ]
          },
          "root": {
            "$ref": "#/components/schemas/RLMExecutionRoleEvidence"
          },
          "subcall": {
            "$ref": "#/components/schemas/RLMExecutionRoleEvidence"
          },
          "limits": {
            "$ref": "#/components/schemas/RLMProfileLimits"
          },
          "policy_revision": {
            "type": "string"
          },
          "root_artifact": {
            "$ref": "#/components/schemas/RLMRootArtifact"
          },
          "content_hash": {
            "type": "string"
          }
        },
        "required": [
          "version",
          "revision_id",
          "selector",
          "lifecycle",
          "root",
          "subcall",
          "limits",
          "content_hash"
        ],
        "type": "object"
      },
      "RLMExactRoleAccountingEvidence": {
        "description": "Failure-inclusive exact-microcent accounting for one RLM model role. The usage aggregate is basis-neutral; usage_by_basis is the observation provenance authority. Zero cost never means missing evidence.",
        "additionalProperties": false,
        "properties": {
          "requests": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "successes": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "failures": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "usage_by_basis": {
            "$ref": "#/components/schemas/RLMUsageByBasis"
          },
          "usage_available": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "usage_unavailable": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "latency_ms": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "provider_cost_microcents": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "platform_fee_microcents": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "customer_charge_microcents": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "settlement_available": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "settlement_unavailable": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "requests",
          "successes",
          "failures",
          "usage",
          "usage_by_basis",
          "usage_available",
          "usage_unavailable",
          "latency_ms",
          "provider_cost_microcents",
          "platform_fee_microcents",
          "customer_charge_microcents",
          "settlement_available",
          "settlement_unavailable"
        ],
        "type": "object"
      },
      "RLMUsageObservationLine": {
        "description": "Aggregate token counters for callback attempts sharing one authenticated observation basis. attempts carries presence because an observed token vector may be all zeroes.",
        "additionalProperties": false,
        "properties": {
          "attempts": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "attempts",
          "usage"
        ],
        "type": "object"
      },
      "RLMUsageByBasis": {
        "description": "Disjoint observation-provenance lines. Historical v4 aggregates project to estimated_categories and never synthesize reasoning tokens.",
        "additionalProperties": false,
        "properties": {
          "exact": {
            "$ref": "#/components/schemas/RLMUsageObservationLine"
          },
          "estimated_categories": {
            "$ref": "#/components/schemas/RLMUsageObservationLine"
          },
          "incomplete": {
            "$ref": "#/components/schemas/RLMUsageObservationLine"
          },
          "unavailable": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "exact",
          "estimated_categories",
          "incomplete",
          "unavailable"
        ],
        "type": "object"
      },
      "RLMStringFact": {
        "description": "An observed string or an explicit reason the fact is unavailable.",
        "additionalProperties": false,
        "properties": {
          "availability": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "value": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "availability"
        ],
        "type": "object"
      },
      "RLMReturnedModelFact": {
        "description": "Provider-returned model aggregate for one admitted RLM callback role. It is available only when every admitted item reported the same non-empty model.",
        "additionalProperties": false,
        "properties": {
          "availability": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "value": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[!-~]+$"
          },
          "reason": {
            "type": "string",
            "enum": [
              "not_observed",
              "missing_observation",
              "conflicting_observations",
              "missing_and_conflicting_observations"
            ],
            "x-enum-varnames": [
              "RLMReturnedModelReasonNotObserved",
              "RLMReturnedModelReasonMissingObservation",
              "RLMReturnedModelReasonConflictingObservations",
              "RLMReturnedModelReasonMissingAndConflictingObservations"
            ]
          }
        },
        "required": [
          "availability"
        ],
        "type": "object"
      },
      "ResponseExecutionStringFact": {
        "description": "An observed string or an explicit reason the fact is unavailable.",
        "additionalProperties": false,
        "properties": {
          "availability": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "value": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "availability"
        ],
        "type": "object"
      },
      "ResponseExecutionIntegerFact": {
        "description": "An observed non-negative integer or an explicit reason the fact is unavailable.",
        "additionalProperties": false,
        "properties": {
          "availability": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "value": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "availability"
        ],
        "type": "object"
      },
      "ResponseExecutionTokenUsage": {
        "description": "Final provider token usage. All counts remain present for failed calls and zero is an observed zero, not missing settlement.",
        "additionalProperties": false,
        "properties": {
          "input_tokens": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "output_tokens": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "total_tokens": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "cache_read_input_tokens": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "cache_write_input_tokens": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "reasoning_tokens": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "observation_basis": {
            "description": "Provider token observation fidelity. unavailable and incomplete usage cannot be settled; estimated_categories has a complete input/output vector with one or more optional category-presence facts unavailable; exact has every supported category explicitly observed.",
            "type": "string",
            "enum": [
              "unavailable",
              "incomplete",
              "estimated_categories",
              "exact"
            ],
            "x-enum-varnames": [
              "ResponseUsageUnavailable",
              "ResponseUsageIncomplete",
              "ResponseUsageEstimatedCategories",
              "ResponseUsageExact"
            ]
          }
        },
        "required": [
          "input_tokens",
          "output_tokens",
          "total_tokens",
          "cache_read_input_tokens",
          "cache_write_input_tokens",
          "reasoning_tokens",
          "observation_basis"
        ],
        "type": "object"
      },
      "ResponseResolveRequest": {
        "description": "Strict content-free request for resolving one concrete direct Responses route. Prompt, input, sampling, reasoning, tools, session, and spend fields are not accepted.",
        "additionalProperties": false,
        "properties": {
          "zdr": {"type": "boolean", "nullable": true, "description": "Require a ZDR inference route for this preview; cannot override credential requirements."},
          "model": {
            "type": "string",
            "minLength": 1
          },
          "provider": {
            "description": "A provider slug to pin, or a provider routing object to preview the route it selects.",
            "oneOf": [
              {
                "type": "string",
                "minLength": 1
              },
              {
                "$ref": "#/components/schemas/ProviderPreference"
              }
            ]
          }
        },
        "required": [
          "model"
        ],
        "type": "object"
      },
      "ResponseResolveResponse": {
        "description": "The authorized concrete route and canonical frozen pricing representation. No provider call, usage, settlement, or execution evidence is created.",
        "additionalProperties": false,
        "properties": {
          "resolved_model": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "reasoning_efforts": {
            "description": "Reasoning-effort values supported by the resolved provider route. Empty when the route exposes no explicit reasoning control.",
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "none",
                "minimal",
                "low",
                "medium",
                "high",
                "xhigh",
                "max"
              ]
            }
          },
          "pricing": {
            "$ref": "#/components/schemas/ResponseExecutionPricing"
          }
        },
        "required": [
          "resolved_model",
          "provider",
          "reasoning_efforts",
          "pricing"
        ],
        "type": "object"
      },
      "RateCardContextBandSnapshot": {
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "min_input_tokens": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0
          }
        },
        "required": [
          "id",
          "min_input_tokens"
        ],
        "type": "object"
      },
      "RateCardTokenDimension": {
        "additionalProperties": false,
        "properties": {
          "class": {
            "type": "string",
            "enum": [
              "uncached_input",
              "cache_read_input",
              "cache_write_unspecified_input",
              "cache_write_5m_input",
              "cache_write_1h_input",
              "output"
            ]
          },
          "modality": {
            "type": "string",
            "enum": [
              "text",
              "image",
              "audio",
              "video",
              "document"
            ]
          }
        },
        "required": [
          "class",
          "modality"
        ],
        "type": "object"
      },
      "RateCardToolDimension": {
        "additionalProperties": false,
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "web_search",
              "social_search",
              "web_fetch",
              "code_execution",
              "file_search",
              "image_generation"
            ]
          },
          "unit": {
            "type": "string",
            "enum": [
              "invocation",
              "second",
              "minute",
              "image",
              "container_session"
            ]
          }
        },
        "required": [
          "kind",
          "unit"
        ],
        "type": "object"
      },
      "RateCardTokenRateSnapshot": {
        "additionalProperties": false,
        "properties": {
          "band": {
            "type": "string",
            "minLength": 1
          },
          "dimension": {
            "$ref": "#/components/schemas/RateCardTokenDimension"
          },
          "rate_per_million_units": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0
          }
        },
        "required": [
          "band",
          "dimension",
          "rate_per_million_units"
        ],
        "type": "object"
      },
      "RateCardToolRateSnapshot": {
        "additionalProperties": false,
        "properties": {
          "band": {
            "type": "string",
            "minLength": 1
          },
          "dimension": {
            "$ref": "#/components/schemas/RateCardToolDimension"
          },
          "rate_per_million_units": {
            "type": "integer",
            "format": "uint64",
            "minimum": 0
          }
        },
        "required": [
          "band",
          "dimension",
          "rate_per_million_units"
        ],
        "type": "object"
      },
      "RateCardSnapshot": {
        "description": "Complete immutable provider/model pricing matrix. Every declared dimension has an explicit rate in every context band; zero is a real price.",
        "additionalProperties": false,
        "properties": {
          "version": {
            "type": "string",
            "enum": [
              "v1"
            ]
          },
          "provider": {
            "type": "string",
            "minLength": 1
          },
          "model": {
            "type": "string",
            "minLength": 1
          },
          "processing_class": {
            "type": "string",
            "enum": [
              "standard",
              "batch",
              "flex",
              "priority",
              "provisioned"
            ]
          },
          "revision": {
            "type": "string",
            "minLength": 1
          },
          "context_bands": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/RateCardContextBandSnapshot"
            }
          },
          "token_dimensions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/RateCardTokenDimension"
            }
          },
          "tool_dimensions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RateCardToolDimension"
            }
          },
          "token_rates": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/RateCardTokenRateSnapshot"
            }
          },
          "tool_rates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RateCardToolRateSnapshot"
            }
          },
          "content_hash": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          }
        },
        "required": [
          "version",
          "provider",
          "model",
          "processing_class",
          "revision",
          "context_bands",
          "token_dimensions",
          "tool_dimensions",
          "token_rates",
          "tool_rates",
          "content_hash"
        ],
        "type": "object"
      },
      "ResponseExecutionPricing": {
        "description": "Frozen content-free pricing provenance. Project owners receive the complete rate card, typed configured rate basis, effective execution cost basis, and exact fee PPM; customer bearer tokens receive the content hash without the owner's cost basis. Effective cost-basis fields are present on execution evidence and may be unavailable with a typed current provider-observation reason. Unavailable pricing never invents zero rates or a zero fee.",
        "additionalProperties": false,
        "properties": {
          "availability": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "source": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "card": {
            "$ref": "#/components/schemas/RateCardSnapshot"
          },
          "rate_basis_kind": {
            "type": "string",
            "enum": [
              "configured_contract_rate",
              "public_list_estimate"
            ]
          },
          "rate_basis_reason": {
            "type": "string",
            "enum": [
              "public_list_rate"
            ]
          },
          "cost_basis_kind": {
            "type": "string",
            "enum": [
              "provider_reported_amount",
              "configured_contract_rate",
              "public_list_estimate",
              "unavailable"
            ],
            "x-enum-varnames": [
              "ResponseCostBasisProviderReported",
              "ResponseCostBasisConfiguredContract",
              "ResponseCostBasisPublicListEstimate",
              "ResponseCostBasisUnavailable"
            ]
          },
          "cost_basis_reason": {
            "type": "string",
            "enum": [
              "public_list_rate",
              "missing_service_tier",
              "missing_modality_breakdown",
              "missing_cache_category_breakdown",
              "missing_cache_ttl_breakdown",
              "unpriced_tool",
              "missing_context_band",
              "provider_amount_absent",
              "usage_unavailable",
              "incomplete_usage",
              "incomplete_core_token_counts",
              "unsupported_dimension"
            ],
            "x-enum-varnames": [
              "ResponseCostReasonPublicListRate",
              "ResponseCostReasonMissingServiceTier",
              "ResponseCostReasonMissingModalityBreakdown",
              "ResponseCostReasonMissingCacheCategoryBreakdown",
              "ResponseCostReasonMissingCacheTTLBreakdown",
              "ResponseCostReasonUnpricedTool",
              "ResponseCostReasonMissingContextBand",
              "ResponseCostReasonProviderAmountAbsent",
              "ResponseCostReasonUsageUnavailable",
              "ResponseCostReasonIncompleteUsage",
              "ResponseCostReasonIncompleteCoreTokenCounts",
              "ResponseCostReasonUnsupportedDimension"
            ]
          },
          "platform_fee_rate_ppm": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "maximum": 1000000
          },
          "reason": {
            "type": "string"
          },
          "content_hash": {
            "type": "string"
          }
        },
        "required": [
          "availability",
          "content_hash"
        ],
        "type": "object"
      },
      "ResponseExecutionTerminalFailure": {
        "description": "Content-free typed terminal failure attribution. Error prose, prompts, outputs, tools, traces, and code are excluded.",
        "additionalProperties": false,
        "properties": {
          "request_id": {
            "type": "string"
          },
          "layer": {
            "type": "string",
            "enum": [
              "request",
              "routing",
              "modelrelay",
              "provider_integration",
              "upstream"
            ]
          },
          "cause": {
            "type": "string",
            "enum": [
              "validation",
              "authentication",
              "authorization",
              "rate_limit",
              "timeout",
              "canceled",
              "transport",
              "upstream_response",
              "invalid_response",
              "unavailable",
              "internal"
            ]
          },
          "status_code": {
            "type": "integer"
          },
          "code": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          },
          "provider_request_id": {
            "type": "string"
          }
        },
        "required": [
          "request_id",
          "layer",
          "cause",
          "status_code",
          "code",
          "retryable"
        ],
        "type": "object"
      },
      "ResponseExecutionSettlement": {
        "description": "Settlement joined to the immutable usage UUID. Monetary values are exact integer microcents (1 cent = 1,000,000 microcents) and are absent when availability is unavailable. Customer bearer tokens receive settled_cost_microcents but not provider or platform-fee cost basis.",
        "additionalProperties": false,
        "properties": {
          "availability": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "usage_record_id": {
            "type": "string",
            "format": "uuid"
          },
          "provider_cost_microcents": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "platform_fee_microcents": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "settled_cost_microcents": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "availability"
        ],
        "type": "object"
      },
      "ResponseExecutionEvidence": {
        "description": "Authenticated content-free immutable evidence for one direct unary or streaming Responses execution.",
        "additionalProperties": false,
        "properties": {
          "version": {
            "type": "string",
            "enum": [
              "modelrelay.response-execution-evidence-view.v5"
            ]
          },
          "execution_id": {
            "type": "string",
            "format": "uuid"
          },
          "request_id": {
            "type": "string"
          },
          "evidence_digest": {
            "type": "string"
          },
          "streaming": {
            "type": "boolean"
          },
          "requested_model": {
            "$ref": "#/components/schemas/ResponseExecutionStringFact"
          },
          "resolved_model": {
            "type": "string"
          },
          "returned_model": {
            "$ref": "#/components/schemas/ResponseExecutionStringFact"
          },
          "reasoning_effort": {
            "$ref": "#/components/schemas/ResponseExecutionStringFact"
          },
          "max_output_tokens": {
            "$ref": "#/components/schemas/ResponseExecutionIntegerFact"
          },
          "provider": {
            "type": "string"
          },
          "execution_origin": {
            "type": "string",
            "enum": [
              "provider",
              "response_cache"
            ]
          },
          "serving_revision": {
            "$ref": "#/components/schemas/ResponseExecutionStringFact"
          },
          "usage": {
            "$ref": "#/components/schemas/ResponseExecutionTokenUsage"
          },
          "latency_ms": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "routing_attempts": {
            "description": "Provider dispatch outcomes in order, including failed unbilled attempts before the serving route.",
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "provider": { "type": "string" },
                "outcome": { "type": "string", "enum": ["succeeded", "failed"], "x-enum-varnames": ["RoutingAttemptSucceeded", "RoutingAttemptFailed"] },
                "reason": { "type": "string" }
              },
              "required": ["provider", "outcome"]
            }
          },
          "provider_status_code": {
            "type": "integer"
          },
          "terminal_status": {
            "type": "string",
            "enum": [
              "succeeded",
              "failed"
            ]
          },
          "terminal_failure": {
            "$ref": "#/components/schemas/ResponseExecutionTerminalFailure"
          },
          "pricing": {
            "$ref": "#/components/schemas/ResponseExecutionPricing"
          },
          "settlement": {
            "$ref": "#/components/schemas/ResponseExecutionSettlement"
          },
          "recorded_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "version",
          "execution_id",
          "request_id",
          "evidence_digest",
          "streaming",
          "requested_model",
          "resolved_model",
          "returned_model",
          "reasoning_effort",
          "max_output_tokens",
          "provider",
          "execution_origin",
          "serving_revision",
          "usage",
          "latency_ms",
          "provider_status_code",
          "terminal_status",
          "pricing",
          "settlement",
          "recorded_at"
        ],
        "type": "object"
      },
      "RLMSeedFact": {
        "description": "Run-specific rollout identity/attribution fact. Unavailable does not mean seed zero.",
        "additionalProperties": false,
        "properties": {
          "availability": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "value": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "availability"
        ],
        "type": "object"
      },
      "RLMProfileIdentityFact": {
        "description": "Stored profile identity. Ad hoc execution records an explicit unavailable reason rather than fabricating a revision.",
        "additionalProperties": false,
        "properties": {
          "availability": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "selector": {
            "type": "string"
          },
          "revision_id": {
            "type": "string"
          },
          "revision_content_hash": {
            "type": "string"
          },
          "effective_fingerprint": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "availability"
        ],
        "type": "object"
      },
      "RLMCorrelatedFailure": {
        "description": "Content-free typed failure attribution. Error prose, prompts, outputs, and traces are intentionally excluded.",
        "additionalProperties": false,
        "properties": {
          "request_id": {
            "type": "string"
          },
          "batch_id": {
            "type": "string"
          },
          "item_id": {
            "type": "string"
          },
          "layer": {
            "type": "string",
            "enum": [
              "request",
              "routing",
              "modelrelay",
              "provider_integration",
              "upstream"
            ]
          },
          "cause": {
            "type": "string",
            "enum": [
              "validation",
              "authentication",
              "authorization",
              "rate_limit",
              "timeout",
              "canceled",
              "transport",
              "upstream_response",
              "invalid_response",
              "unavailable",
              "internal"
            ]
          },
          "status_code": {
            "type": "integer"
          },
          "code": {
            "type": "string"
          },
          "retryable": {
            "type": "boolean"
          },
          "provider_request_id": {
            "type": "string"
          }
        },
        "required": [
          "layer",
          "cause",
          "status_code",
          "code",
          "retryable"
        ],
        "type": "object"
      },
      "RLMCorrelatedFailuresFact": {
        "description": "Typed failures plus an explicit completeness fact. Values can contain known failures even when the complete callback artifact was unavailable.",
        "additionalProperties": false,
        "properties": {
          "availability": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RLMCorrelatedFailure"
            }
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "availability",
          "values"
        ],
        "type": "object"
      },
      "RLMRetrievedExecutionEvidence": {
        "description": "Authenticated content-free immutable evidence for an RLM execution, including failed executions.",
        "additionalProperties": false,
        "properties": {
          "version": {
            "type": "string",
            "enum": [
              "modelrelay.rlm-execution-evidence-view.v4"
            ]
          },
          "grant_id": {
            "type": "string",
            "format": "uuid"
          },
          "evidence_digest": {
            "type": "string"
          },
          "spec_fingerprint": {
            "type": "string"
          },
          "max_settled_spend_microcents": {
            "type": "integer",
            "format": "int64",
            "minimum": 1,
            "description": "Authoritative exact settled-spend ceiling in microcents, carried from the execution grant that authorized the run."
          },
          "profile": {
            "$ref": "#/components/schemas/RLMProfileIdentityFact"
          },
          "policy_revision": {
            "$ref": "#/components/schemas/RLMStringFact"
          },
          "root_artifact_ref": {
            "$ref": "#/components/schemas/RLMArtifactRef"
          },
          "root": {
            "$ref": "#/components/schemas/RLMExecutionRoleEvidence"
          },
          "subcall": {
            "$ref": "#/components/schemas/RLMExecutionRoleEvidence"
          },
          "limits": {
            "$ref": "#/components/schemas/RLMExecutionLimitsEvidence"
          },
          "seed": {
            "$ref": "#/components/schemas/RLMSeedFact"
          },
          "pricing": {
            "$ref": "#/components/schemas/RLMExecutionPricingEvidence"
          },
          "root_accounting": {
            "$ref": "#/components/schemas/RLMExactRoleAccountingEvidence"
          },
          "subcall_accounting": {
            "$ref": "#/components/schemas/RLMExactRoleAccountingEvidence"
          },
          "root_returned_model": {
            "$ref": "#/components/schemas/RLMReturnedModelFact"
          },
          "subcall_returned_model": {
            "$ref": "#/components/schemas/RLMReturnedModelFact"
          },
          "terminal_status": {
            "$ref": "#/components/schemas/RLMStringFact"
          },
          "failure_code": {
            "$ref": "#/components/schemas/RLMStringFact"
          },
          "correlated_failures": {
            "$ref": "#/components/schemas/RLMCorrelatedFailuresFact"
          },
          "failure_evidence_digest": {
            "type": "string"
          },
          "recorded_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "version",
          "grant_id",
          "evidence_digest",
          "spec_fingerprint",
          "profile",
          "policy_revision",
          "root",
          "subcall",
          "limits",
          "seed",
          "pricing",
          "root_accounting",
          "subcall_accounting",
          "root_returned_model",
          "subcall_returned_model",
          "terminal_status",
          "failure_code",
          "correlated_failures",
          "recorded_at"
        ],
        "type": "object"
      },
      "RLMModelPricingEvidence": {
        "additionalProperties": false,
        "properties": {
          "model_id": {
            "type": "string"
          },
          "input_cost_per_million_millicents": {
            "description": "Uncached text input rate in millicents per million tokens.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "cache_read_input_cost_per_million_millicents": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "cache_write_input_cost_per_million_millicents": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "output_cost_per_million_millicents": {
            "description": "Text output rate in millicents per million tokens.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "input_cost_per_million_cents": {
            "description": "Legacy rate in whole cents per million tokens. Present only on evidence recorded before the cents projection was retired; absent afterwards, which is not the same as free.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "output_cost_per_million_cents": {
            "description": "Legacy rate in whole cents per million tokens. Present only on evidence recorded before the cents projection was retired; absent afterwards, which is not the same as free.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "model_id",
          "cache_read_input_cost_per_million_millicents",
          "cache_write_input_cost_per_million_millicents"
        ],
        "type": "object"
      },
      "RLMExecutionPricingEvidence": {
        "description": "Immutable pre-execution pricing representation. Unavailable facts carry a reason and still have a content hash.",
        "additionalProperties": false,
        "properties": {
          "availability": {
            "type": "string",
            "enum": [
              "available",
              "unavailable"
            ]
          },
          "root": {
            "$ref": "#/components/schemas/RLMModelPricingEvidence"
          },
          "subcall": {
            "$ref": "#/components/schemas/RLMModelPricingEvidence"
          },
          "platform_fee_percent": {
            "type": "number"
          },
          "source": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "content_hash": {
            "type": "string"
          }
        },
        "required": [
          "availability",
          "platform_fee_percent",
          "content_hash"
        ],
        "type": "object"
      },
      "RLMScaffoldManifest": {
        "description": "Losslessly preserved content-free Droste scaffold manifest. Droste is the sole authority for fields beyond the routing identity.",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string"
          },
          "schema_version": {
            "const": 2
          }
        },
        "required": [
          "id",
          "schema_version"
        ],
        "type": "object"
      },
      "CustomerMePresetRef": {
        "type": "object",
        "required": [
          "model_id",
          "model_display_name"
        ],
        "properties": {
          "model_id": {
            "type": "string"
          },
          "model_display_name": {
            "type": "string"
          }
        }
      },
      "CustomerMePreset": {
        "type": "object",
        "required": [
          "code",
          "display_name",
          "is_default",
          "kind"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable preset code. Send it in the request's preset field."
          },
          "display_name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "is_default": {
            "type": "boolean"
          },
          "kind": {
            "type": "string",
            "enum": [
              "single",
              "recursive"
            ]
          },
          "model": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CustomerMePresetRef"
              }
            ],
            "description": "Present only when kind is `single`."
          },
          "root": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CustomerMePresetRef"
              }
            ],
            "description": "Present only when kind is `recursive`: the program's root model."
          },
          "subcall": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CustomerMePresetRef"
              }
            ],
            "description": "Present only when kind is `recursive`: the program's subcall model."
          }
        },
        "description": "A preset in the customer-visible catalog. It used to publish a `roles` map with all four of root/subcall/utility/vision filled in -- the unset ones from root -- so a client reading `roles.utility` saw a model nobody had designated. Each variant now publishes only what it has."
      },
      "CustomerMeModel": {
        "type": "object",
        "required": [
          "model_id",
          "display_name",
          "capabilities",
          "is_default"
        ],
        "properties": {
          "model_id": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "capabilities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "is_default": {
            "type": "boolean"
          }
        }
      },
      "CustomerMeModels": {
        "type": "object",
        "required": [
          "presets",
          "models"
        ],
        "properties": {
          "presets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerMePreset"
            }
          },
          "models": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomerMeModel"
            }
          }
        }
      },
      "CustomerMeModelsResponse": {
        "type": "object",
        "required": [
          "models"
        ],
        "properties": {
          "models": {
            "$ref": "#/components/schemas/CustomerMeModels"
          }
        }
      },
      "TierPreset": {
        "type": "object",
        "required": [
          "preset_code",
          "display_name",
          "is_default",
          "execution"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "tier_id": {
            "type": "string",
            "format": "uuid"
          },
          "preset_code": {
            "type": "string",
            "description": "Preset code (alphanumeric, '-', '_'). Customers send it in the request's preset field."
          },
          "display_name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "execution": {
            "$ref": "#/components/schemas/TierPresetExecution"
          },
          "is_default": {
            "type": "boolean"
          },
          "sort_order": {
            "type": "integer",
            "format": "int32"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TierPresetPayload": {
        "type": "object",
        "required": [
          "preset_code",
          "display_name",
          "execution"
        ],
        "properties": {
          "preset_code": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "execution": {
            "$ref": "#/components/schemas/TierPresetExecutionRequest"
          },
          "is_default": {
            "type": "boolean"
          },
          "sort_order": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "TierPresetRLMProfileUpdateRequest": {
        "additionalProperties": false,
        "description": "Advances one existing tier preset to an immutable profile selected from the server's reviewed registry. The current execution expectation is checked under the same lock as the write. This request cannot create a preset or supply routes, limits, or revision JSON.",
        "properties": {
          "profile": {
            "description": "Name of a profile in the server's reviewed installer registry.",
            "minLength": 1,
            "type": "string"
          },
          "expect_current_kind": {
            "description": "Execution kind the targeted preset must have when locked.",
            "enum": [
              "single",
              "recursive"
            ],
            "type": "string",
            "x-enum-varnames": [
              "TierPresetRLMProfileExpectedKindSingle",
              "TierPresetRLMProfileExpectedKindRecursive"
            ]
          },
          "expect_current_model": {
            "description": "Concrete current model the targeted preset must use. For a recursive preset this is its root model.",
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "profile",
          "expect_current_kind",
          "expect_current_model"
        ],
        "type": "object"
      },
      "TierPresetRLMProfileUpdateResponse": {
        "additionalProperties": false,
        "description": "The reviewed immutable revision selected by the server and the targeted preset after installation.",
        "properties": {
          "changed": {
            "description": "False when the exact reviewed revision was already installed.",
            "type": "boolean"
          },
          "profile": {
            "type": "string"
          },
          "preset": {
            "$ref": "#/components/schemas/TierPreset"
          },
          "revision": {
            "$ref": "#/components/schemas/RLMProfileRevision"
          }
        },
        "required": [
          "changed",
          "profile",
          "preset",
          "revision"
        ],
        "type": "object"
      },
      "TierPresetsPutRequest": {
        "type": "object",
        "required": [
          "presets"
        ],
        "properties": {
          "presets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TierPresetPayload"
            },
            "description": "Complete desired preset set (replace-all; empty removes all presets)."
          }
        }
      },
      "TierPresetsResponse": {
        "type": "object",
        "required": [
          "presets"
        ],
        "properties": {
          "presets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TierPreset"
            }
          }
        }
      },
      "TierPresetExecution": {
        "description": "What a preset executes: exactly one variant. This replaced four role fields (root/subcall/utility/vision) whose unset entries silently fell back to root_model, so a client could not tell a designated model from an inherited one.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/TierPresetExecutionSingle"
          },
          {
            "$ref": "#/components/schemas/TierPresetExecutionRecursive"
          }
        ],
        "discriminator": {
          "propertyName": "kind",
          "mapping": {
            "single": "#/components/schemas/TierPresetExecutionSingle",
            "recursive": "#/components/schemas/TierPresetExecutionRecursive"
          }
        }
      },
      "TierPresetExecutionSingle": {
        "type": "object",
        "description": "A preset that runs one model.",
        "required": [
          "kind",
          "model"
        ],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "single"
            ]
          },
          "model": {
            "type": "string",
            "description": "Must be one of the tier's allowed models."
          }
        }
      },
      "TierPresetExecutionRecursive": {
        "type": "object",
        "description": "A preset that runs an immutable content-addressed recursive program. Not selectable on /responses -- create an execution grant to run it.",
        "required": [
          "kind",
          "revision"
        ],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "recursive"
            ]
          },
          "revision": {
            "$ref": "#/components/schemas/RLMProfileRevision"
          }
        }
      },
      "TierPresetExecutionRequest": {
        "description": "What a write may ask a preset to execute. A recursive request carries no revision: a profile's content hash is an unkeyed digest, proving the bytes are consistent rather than that anyone was granted the served checkpoint they name, so this path names the program already installed under that preset code and cannot introduce one. Installation is a separate operational step.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/TierPresetExecutionSingle"
          },
          {
            "$ref": "#/components/schemas/TierPresetExecutionRequestRecursive"
          }
        ],
        "discriminator": {
          "propertyName": "kind",
          "mapping": {
            "single": "#/components/schemas/TierPresetExecutionSingle",
            "recursive": "#/components/schemas/TierPresetExecutionRequestRecursive"
          }
        }
      },
      "TierPresetExecutionRequestRecursive": {
        "type": "object",
        "description": "Names the recursive program already installed on this preset code.",
        "required": [
          "kind"
        ],
        "additionalProperties": false,
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "recursive"
            ]
          }
        }
      },
      "PromptCachingCapabilities": {
        "type": "object",
        "description": "Provider prompt-cache controls for this route. Eligibility and cache hits depend on the upstream model and workload; inspect usage for actual cache reads and writes. This does not describe gateway response caching.",
        "required": [
          "automatic",
          "key_mode",
          "breakpoint_ttls"
        ],
        "properties": {
          "automatic": {
            "type": "boolean",
            "description": "Cache reads can occur without an explicit prompt_cache option; not a guarantee of eligibility or a hit."
          },
          "key_mode": {
            "type": "string",
            "enum": [
              "unknown",
              "ignored",
              "affinity",
              "breakpoint",
              "unsupported"
            ],
            "description": "Adapter handling of prompt_cache.key: unknown, accepted but ignored, forwarded as a routing hint, translated into a trailing breakpoint, or rejected by the provider adapter."
          },
          "breakpoint_ttls": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "5m",
                "1h"
              ]
            },
            "description": "Supported TTLs for caller-placed cache breakpoints; empty when none are supported."
          }
        }
      },
      "AutoRouterOptions": {
        "type": "object",
        "additionalProperties": false,
        "description": "Options for model auto or modelrelay/auto. Model restrictions are hard filters; no match returns NO_ELIGIBLE_MODELS.",
        "properties": {
          "allowed_models": {
            "type": "array",
            "maxItems": 1024,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256,
              "pattern": "^[^*]+\\*?$|^\\*$"
            }
          },
          "excluded_models": {
            "type": "array",
            "maxItems": 1024,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256,
              "pattern": "^[^*]+\\*?$|^\\*$"
            }
          },
          "cost_tier": {
            "$ref": "#/components/schemas/AutoRouterCostTier"
          }
        }
      },
      "AutoRouterPlugin": {
        "type": "object",
        "additionalProperties": false,
        "description": "Strict auto-router plugin for model auto or modelrelay/auto.",
        "properties": {
          "allowed_models": {
            "type": "array",
            "maxItems": 1024,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256,
              "pattern": "^[^*]+\\*?$|^\\*$"
            }
          },
          "excluded_models": {
            "type": "array",
            "maxItems": 1024,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 256,
              "pattern": "^[^*]+\\*?$|^\\*$"
            }
          },
          "cost_tier": {
            "$ref": "#/components/schemas/AutoRouterCostTier"
          },
          "id": {
            "type": "string",
            "enum": [
              "auto-router"
            ],
            "x-enum-varnames": [
              "AutoRouterPluginID"
            ]
          }
        },
        "required": [
          "id"
        ]
      },
      "AutoRouterCostTier": {
        "type": "string",
        "enum": [
          "low",
          "medium",
          "high"
        ],
        "default": "medium",
        "x-enum-varnames": [
          "AutoCostLow",
          "AutoCostMedium",
          "AutoCostHigh"
        ]
      }
    },
    "securitySchemes": {
      "apiKeyAuth": {
        "in": "header",
        "name": "X-ModelRelay-Api-Key",
        "type": "apiKey"
      },
      "bearerAuth": {
        "bearerFormat": "JWT",
        "scheme": "bearer",
        "type": "http"
      },
      "openAICompatAuth": {
        "bearerFormat": "mr_sk_*",
        "description": "ModelRelay secret API key sent as an Authorization bearer token.",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "description": "Control-plane and inference endpoints for ModelRelay projects, tiers, customers, billing, and LLM proxying.",
    "title": "ModelRelay API",
    "version": "0.7.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/account/balance": {
      "get": {
        "operationId": "getAccountBalance",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountBalanceResponse"
                }
              }
            },
            "description": "Account balance retrieved successfully"
          },
          "401": {
            "description": "Unauthorized"
          },
          "503": {
            "description": "Balance service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Get the authenticated account's PAYGO balance",
        "description": "Returns the current balance for the authenticated account. Accepts both bearer tokens and API keys."
      }
    },
    "/account/topup": {
      "post": {
        "operationId": "createAccountTopup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TopupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TopupResponse"
                }
              }
            },
            "description": "Top-up session created"
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "503": {
            "description": "Top-up service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a top-up session for the authenticated account"
      }
    },
    "/account/topups": {
      "get": {
        "operationId": "listAccountTopups",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "format": "int32",
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TopupHistoryResponse"
                }
              }
            },
            "description": "Top-up history"
          },
          "401": {
            "description": "Unauthorized"
          },
          "500": {
            "description": "Failed to list top-up sessions"
          },
          "503": {
            "description": "Top-up service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List recent top-up sessions for the authenticated account"
      }
    },
    "/account/topups/{topup_id}": {
      "get": {
        "operationId": "getAccountTopupSession",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TopupSessionResponse"
                }
              }
            },
            "description": "Top-up session details"
          },
          "400": {
            "description": "Invalid top-up ID"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Top-up session not found"
          },
          "500": {
            "description": "Failed to fetch top-up session"
          },
          "503": {
            "description": "Top-up service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get a top-up session by ID"
      },
      "parameters": [
        {
          "in": "path",
          "name": "topup_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ]
    },
    "/account/topups/crypto/config": {
      "get": {
        "operationId": "getAccountCryptoTopupConfig",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CryptoTopupConfigResponse"
                }
              }
            },
            "description": "Crypto top-up configuration"
          },
          "400": {
            "description": "Crypto top-up not configured"
          },
          "401": {
            "description": "Unauthorized"
          },
          "503": {
            "description": "Top-up service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get crypto top-up configuration for the authenticated account"
      }
    },
    "/account/topups/crypto/submit": {
      "post": {
        "operationId": "submitAccountCryptoTopup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CryptoTopupSubmitRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TopupSessionResponse"
                }
              }
            },
            "description": "Crypto transaction recorded"
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Top-up session not found"
          },
          "409": {
            "description": "Transaction hash already used"
          },
          "503": {
            "description": "Top-up service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Submit a crypto transaction for a top-up session"
      }
    },
    "/account/billing/auto-topup": {
      "delete": {
        "operationId": "disableAccountAutoTopup",
        "responses": {
          "204": {
            "description": "Auto top-up disabled"
          },
          "401": {
            "description": "Unauthorized"
          },
          "500": {
            "description": "Failed to disable auto top-up"
          },
          "503": {
            "description": "Auto top-up service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Disable auto top-up for the authenticated account"
      },
      "get": {
        "operationId": "getAccountAutoTopup",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutoTopupConfigResponse"
                }
              }
            },
            "description": "Auto top-up configuration"
          },
          "401": {
            "description": "Unauthorized"
          },
          "500": {
            "description": "Failed to get auto top-up configuration"
          },
          "503": {
            "description": "Auto top-up service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get auto top-up configuration for the authenticated account"
      },
      "put": {
        "operationId": "updateAccountAutoTopup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoTopupConfigRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutoTopupConfigResponse"
                }
              }
            },
            "description": "Auto top-up configuration updated"
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "503": {
            "description": "Auto top-up service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update auto top-up configuration for the authenticated account"
      }
    },
    "/account/billing/auto-topup/confirm": {
      "post": {
        "operationId": "confirmAccountAutoTopupSetup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoTopupConfirmRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutoTopupConfigResponse"
                }
              }
            },
            "description": "Auto top-up payment method stored"
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "503": {
            "description": "Auto top-up service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Confirm auto top-up setup intent"
      }
    },
    "/account/card-verification": {
      "get": {
        "operationId": "getAccountCardVerification",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardVerificationOutcome"
                }
              }
            },
            "description": "Card verification status"
          },
          "401": {
            "description": "Unauthorized"
          },
          "503": {
            "description": "Card verification unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get card verification status for the signup credit gate"
      },
      "post": {
        "operationId": "startAccountCardVerification",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardVerificationSession"
                }
              }
            },
            "description": "Card verification checkout session created"
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "409": {
            "description": "Card already verified"
          },
          "503": {
            "description": "Card verification unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Start a $0 card verification checkout session (Sybil gate for signup credits)"
      }
    },
    "/account/card-verification/confirm": {
      "post": {
        "operationId": "confirmAccountCardVerification",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CardVerificationConfirmRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CardVerificationOutcome"
                }
              }
            },
            "description": "Card verified; signup credit applied when eligible"
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Card verification not found"
          },
          "409": {
            "description": "Checkout session not completed"
          },
          "422": {
            "description": "Prepaid cards are not accepted"
          },
          "503": {
            "description": "Card verification unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Confirm a completed card verification checkout session"
      }
    },
    "/account/billing/auto-topup/setup": {
      "post": {
        "operationId": "createAccountAutoTopupSetup",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AutoTopupSetupResponse"
                }
              }
            },
            "description": "Setup intent created"
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "503": {
            "description": "Auto top-up service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a setup intent for auto top-up payment methods"
      }
    },
    "/auth/customer-token": {
      "post": {
        "description": "Used by trusted backends to mint short-lived customer-scoped bearer tokens\nfor data-plane access. Requires a secret API key (mr_sk_*).\nThe customer must already exist; use /customers endpoints to create customers first.\n",
        "operationId": "mintCustomerToken",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "customer_external_id": {
                    "description": "External customer identifier (provide exactly one of customer_id or customer_external_id)",
                    "type": "string"
                  },
                  "customer_id": {
                    "description": "Internal customer UUID (provide exactly one of customer_id or customer_external_id)",
                    "format": "uuid",
                    "type": "string"
                  },
                  "tier_code": {
                    "description": "Optional non-paid tier code for a new managed customer. Omit to assign the project's default Free tier. Paid tiers require checkout.",
                    "type": "string"
                  },
                  "ttl_seconds": {
                    "description": "Requested token TTL in seconds (server may cap this)",
                    "format": "uint32",
                    "minimum": 1,
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerTokenResponse"
                }
              }
            },
            "description": "Customer token issued"
          },
          "400": {
            "description": "Invalid request (missing or invalid customer selector)"
          },
          "401": {
            "description": "Invalid or missing secret key"
          },
          "404": {
            "description": "Customer not found"
          },
          "409": {
            "description": "Project default tier is not configured, the customer tier entitlement is invalid, or a paid tier was requested without checkout"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Mint a customer-scoped bearer token"
      }
    },
    "/auth/device": {
      "get": {
        "operationId": "getDeviceAuthorization",
        "summary": "Look up a device sign-in by user code (for the approval page)",
        "parameters": [
          {
            "in": "query",
            "name": "user_code",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The user code, in any case, with or without the dash"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceAuthorization"
                }
              }
            },
            "description": "Device sign-in state"
          },
          "401": {
            "description": "Account sign-in required"
          },
          "404": {
            "description": "No device sign-in matches the code"
          },
          "429": {
            "description": "Too many user-code attempts"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/auth/device/approve": {
      "post": {
        "operationId": "approveDeviceAuthorization",
        "summary": "Approve a device sign-in for the calling account",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceUserCodeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceAuthorization"
                }
              }
            },
            "description": "Device sign-in state"
          },
          "401": {
            "description": "Account sign-in required"
          },
          "404": {
            "description": "No device sign-in matches the code"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceAuthorization"
                }
              }
            },
            "description": "The device sign-in is no longer pending (current state in the body)"
          },
          "429": {
            "description": "Too many user-code attempts"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/auth/device/code": {
      "post": {
        "operationId": "createDeviceCode",
        "summary": "Start a device sign-in (RFC 8628 device authorization request)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "client_id": {
                    "description": "Optional client identifier; accepted and ignored",
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceCodeResponse"
                }
              }
            },
            "description": "Device and user codes issued"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/auth/device/deny": {
      "post": {
        "operationId": "denyDeviceAuthorization",
        "summary": "Deny a device sign-in",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceUserCodeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceAuthorization"
                }
              }
            },
            "description": "Device sign-in state"
          },
          "401": {
            "description": "Account sign-in required"
          },
          "404": {
            "description": "No device sign-in matches the code"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceAuthorization"
                }
              }
            },
            "description": "The device sign-in is no longer pending (current state in the body)"
          },
          "429": {
            "description": "Too many user-code attempts"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/auth/device/token": {
      "post": {
        "operationId": "pollDeviceToken",
        "summary": "Poll for the tokens of an approved device sign-in (RFC 8628 device access token request)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeviceTokenRequest"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/DeviceTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            },
            "description": "Approved: the same tokens as /auth/login, issued once"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceTokenError"
                }
              }
            },
            "description": "Pending, slowed down, denied, expired, or invalid"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/auth/login": {
      "post": {
        "operationId": "login",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "format": "email",
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            },
            "description": "Tokens issued"
          }
        },
        "summary": "Exchange credentials for tokens"
      }
    },
    "/auth/logout": {
      "post": {
        "operationId": "logout",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "refresh_token": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Session revoked"
          }
        },
        "summary": "Revoke a refresh token"
      }
    },
    "/auth/me": {
      "get": {
        "operationId": "getAuthenticatedUser",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/User"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Current user"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Fetch the authenticated user profile"
      }
    },
    "/auth/refresh": {
      "post": {
        "operationId": "refreshToken",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "refresh_token": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthTokens"
                }
              }
            },
            "description": "Tokens refreshed"
          }
        },
        "summary": "Refresh an access token"
      }
    },
    "/auth/register": {
      "post": {
        "operationId": "registerOwner",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "billing_provider": {
                    "$ref": "#/components/schemas/BillingProvider"
                  },
                  "email": {
                    "format": "email",
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            },
            "description": "User created"
          }
        },
        "summary": "Register a new owner account"
      }
    },
    "/customers": {
      "get": {
        "operationId": "listCustomers",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "customers": {
                      "items": {
                        "$ref": "#/components/schemas/CustomerWithSubscription"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Customer list"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "List customers"
      },
      "post": {
        "operationId": "createProjectCustomer",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/CustomerWithSubscription"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Customer created"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Create a customer"
      },
      "put": {
        "operationId": "upsertCustomer",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/CustomerWithSubscription"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Customer updated"
          },
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/CustomerWithSubscription"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Customer created"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Upsert a customer by external_id"
      }
    },
    "/customers/by-external-id/{external_id}": {
      "get": {
        "description": "Returns a customer by their external_id. Use this when you have the customer's external identifier (e.g., GitHub ID) but not their internal UUID.",
        "operationId": "getCustomerByExternalId",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/CustomerWithSubscription"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Customer"
          },
          "400": {
            "description": "external_id required"
          },
          "404": {
            "description": "Customer not found"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Get a customer by external_id"
      },
      "parameters": [
        {
          "description": "The customer's external identifier (e.g., GitHub ID)",
          "in": "path",
          "name": "external_id",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ]
    },
    "/customers/me": {
      "get": {
        "description": "Returns the current customer associated with the provided customer-scoped bearer token.\nIncludes the customer's subscription and tier when available.\n",
        "operationId": "getCustomerMe",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerMeResponse"
                }
              }
            },
            "description": "Customer details"
          },
          "401": {
            "description": "Unauthorized"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get the authenticated customer"
      }
    },
    "/customers/me/balance": {
      "get": {
        "operationId": "getCustomerMeBalance",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerBalanceResponse"
                }
              }
            },
            "description": "PAYGO balance"
          },
          "400": {
            "description": "Subscription is not PAYGO"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Customer or subscription not found"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get the authenticated customer's PAYGO balance"
      }
    },
    "/customers/me/balance/history": {
      "get": {
        "operationId": "getCustomerMeBalanceHistory",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "format": "int32",
              "maximum": 200,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerLedgerResponse"
                }
              }
            },
            "description": "Ledger entries"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Customer not found"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get the authenticated customer's PAYGO ledger history"
      }
    },
    "/customers/me/change-tier": {
      "post": {
        "description": "Allows customers to upgrade or downgrade their subscription tier. Supports paid-to-paid (with proration), free-to-paid (requires payment method on file), paid-to-free (cancels at period end and returns to the project's default Free tier), and free-to-free transitions.",
        "operationId": "changeCustomerMeTier",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChangeTierRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerMeChangeTierResponse"
                }
              }
            },
            "description": "Tier changed successfully"
          },
          "400": {
            "description": "Invalid request (missing tier_code or PAYGO subscription)"
          },
          "401": {
            "description": "Unauthorized"
          },
          "402": {
            "description": "No payment method on file (required for free-to-paid upgrade)"
          },
          "404": {
            "description": "Customer or tier not found"
          },
          "409": {
            "description": "Billing provider mismatch, missing pricing, scheduled subscription cancellation, or a paid-to-free target other than the project default tier"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Change the authenticated customer's subscription tier"
      }
    },
    "/customers/me/billing/portal": {
      "post": {
        "description": "Creates a Stripe billing portal session for the authenticated customer so they can self-manage their subscription (update payment method, cancel, view invoices). The Stripe customer is resolved from the customer's billing profile and is never accepted from request input.",
        "operationId": "createCustomerMeBillingPortal",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerMeBillingPortalRequest"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerMeBillingPortalResponse"
                }
              }
            },
            "description": "Billing portal session created successfully"
          },
          "400": {
            "description": "Invalid request (malformed body or invalid return_url)"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "No subscription to manage (no billing profile or no Stripe customer)"
          },
          "500": {
            "description": "Failed to create billing portal session"
          },
          "502": {
            "description": "Billing profile lookup failed"
          },
          "503": {
            "description": "Billing service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a billing portal session for the authenticated customer"
      }
    },
    "/customers/me/checkout": {
      "post": {
        "description": "Creates a Stripe checkout session using the customer-first flow. A Stripe Customer is created with the verified OAuth email before checkout, preventing email spoofing. The email field in the Stripe checkout will be locked to the authenticated user's email.",
        "operationId": "createCustomerMeCheckout",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerMeCheckoutRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutSessionResponse"
                }
              }
            },
            "description": "Checkout session created successfully"
          },
          "400": {
            "description": "Invalid request (missing or invalid tier_code, success_url, or cancel_url)"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Customer or tier not found"
          },
          "409": {
            "description": "Tier has no billing pricing configured"
          },
          "503": {
            "description": "Billing not configured"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a checkout session for the authenticated customer"
      }
    },
    "/customers/me/subscription": {
      "get": {
        "description": "Returns customer-visible subscription details for the authenticated customer bearer token.\nIncludes tier name and subscription price; does not include developer-private usage cost accounting.\n",
        "operationId": "getCustomerMeSubscription",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerMeSubscriptionResponse"
                }
              }
            },
            "description": "Subscription details"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Customer or tier not found"
          },
          "500": {
            "description": "Internal server error"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get the authenticated customer's subscription"
      }
    },
    "/customers/me/topup": {
      "post": {
        "operationId": "createCustomerMeTopup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerTopupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerTopupResponse"
                }
              }
            },
            "description": "Checkout session created"
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Customer not found"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a PAYGO top-up checkout session for the authenticated customer"
      }
    },
    "/customers/me/usage": {
      "get": {
        "description": "Returns customer-visible usage metrics for the current billing window.\nIncludes request/token counts and (for paid tiers) remaining subscription credits.\nDoes not include any developer-private budgets (e.g., internal tier spend caps).\n",
        "operationId": "getCustomerMeUsage",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerMeUsageResponse"
                }
              }
            },
            "description": "Usage summary"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Customer not found"
          },
          "500": {
            "description": "Failed to calculate usage"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get the authenticated customer's usage"
      }
    },
    "/customers/{customer_id}": {
      "delete": {
        "operationId": "deleteProjectCustomer",
        "responses": {
          "204": {
            "description": "Customer deleted"
          },
          "404": {
            "description": "Customer not found"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Delete a customer"
      },
      "get": {
        "operationId": "getCustomer",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/CustomerWithSubscription"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Customer"
          },
          "404": {
            "description": "Customer not found"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Get a customer"
      },
      "parameters": [
        {
          "in": "path",
          "name": "customer_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ]
    },
    "/customers/{customer_id}/balance": {
      "get": {
        "operationId": "getCustomerBalance",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerBalanceResponse"
                }
              }
            },
            "description": "PAYGO balance"
          },
          "400": {
            "description": "Subscription is not PAYGO"
          },
          "404": {
            "description": "Customer or subscription not found"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Get a customer's PAYGO balance"
      },
      "parameters": [
        {
          "in": "path",
          "name": "customer_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ]
    },
    "/customers/{customer_id}/balance/history": {
      "get": {
        "operationId": "getCustomerBalanceHistory",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "format": "int32",
              "maximum": 200,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "offset",
            "required": false,
            "schema": {
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerLedgerResponse"
                }
              }
            },
            "description": "Ledger entries"
          },
          "404": {
            "description": "Customer not found"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Get a customer's PAYGO ledger history"
      },
      "parameters": [
        {
          "in": "path",
          "name": "customer_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ]
    },
    "/customers/{customer_id}/subscribe": {
      "parameters": [
        {
          "in": "path",
          "name": "customer_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "subscribeCustomer",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "cancel_url": {
                    "format": "uri",
                    "type": "string"
                  },
                  "success_url": {
                    "format": "uri",
                    "type": "string"
                  },
                  "tier_id": {
                    "format": "uuid",
                    "type": "string"
                  }
                },
                "required": [
                  "tier_id",
                  "success_url",
                  "cancel_url"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutSessionResponse"
                }
              }
            },
            "description": "Checkout session created"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Create a customer subscription checkout session"
      }
    },
    "/customers/{customer_id}/subscription": {
      "delete": {
        "operationId": "cancelCustomerSubscription",
        "responses": {
          "204": {
            "description": "Subscription canceled"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Cancel a customer's subscription"
      },
      "get": {
        "operationId": "getCustomerSubscription",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "subscription": {
                      "$ref": "#/components/schemas/Subscription"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Subscription details"
          },
          "404": {
            "description": "Subscription not found"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Get a customer's subscription"
      },
      "parameters": [
        {
          "in": "path",
          "name": "customer_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ]
    },
    "/customers/{customer_id}/topup": {
      "parameters": [
        {
          "in": "path",
          "name": "customer_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ],
      "post": {
        "operationId": "createCustomerTopup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerTopupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerTopupResponse"
                }
              }
            },
            "description": "Checkout session created"
          },
          "400": {
            "description": "Invalid request"
          },
          "404": {
            "description": "Customer not found"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Create a PAYGO top-up checkout session for a customer"
      }
    },
    "/images/generate": {
      "post": {
        "description": "Generate images using AI models. Returns URLs by default (requires storage configuration) or base64-encoded data when response_format is 'b64_json'.",
        "operationId": "generateImage",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageResponse"
                }
              }
            },
            "description": "Generated images"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Generate images from a text prompt"
      }
    },
    "/images/{image_id}": {
      "get": {
        "description": "Retrieve information about a specific image, including its pinned status and URL.",
        "operationId": "getImage",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImagePinResponse"
                }
              }
            },
            "description": "Image details"
          },
          "404": {
            "description": "Image not found"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Get image details"
      },
      "parameters": [
        {
          "description": "Image ID",
          "in": "path",
          "name": "image_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ]
    },
    "/images/{image_id}/pin": {
      "delete": {
        "description": "Unpin an image, setting it to expire after the default ephemeral period (7 days).",
        "operationId": "unpinImage",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImagePinResponse"
                }
              }
            },
            "description": "Image unpinned successfully"
          },
          "404": {
            "description": "Image not found"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Unpin an image"
      },
      "parameters": [
        {
          "description": "Image ID",
          "in": "path",
          "name": "image_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ],
      "post": {
        "description": "Pin an image to prevent it from expiring. Pinned images remain accessible permanently (subject to tier limits).",
        "operationId": "pinImage",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImagePinResponse"
                }
              }
            },
            "description": "Image pinned successfully"
          },
          "403": {
            "description": "Quota exceeded"
          },
          "404": {
            "description": "Image not found"
          },
          "410": {
            "description": "Image has expired"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Pin an image"
      }
    },
    "/models": {
      "get": {
        "description": "Returns all active models with rich metadata for building model selectors.",
        "operationId": "listModels",
        "parameters": [
          {
            "description": "Filter results to a specific provider",
            "in": "query",
            "name": "provider",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/ProviderId"
            }
          },
          {
            "description": "Filter results to models that support a capability",
            "in": "query",
            "name": "capability",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/ModelCapability"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelsResponse"
                }
              }
            },
            "description": "Models list"
          }
        },
        "summary": "List active models"
      }
    },
    "/models/{model_id}/endpoints": {
      "get": {
        "description": "Lists every route that serves the model, each priced at its own provider's rate card, in OpenRouter's endpoints-listing shape. Routes appear in default routing order. Also served at https://api.modelrelay.ai/v1/models/{model_id}/endpoints, where OpenRouter author/slug aliases (for example z-ai/glm-5.3-flash) are accepted too. Public; no authentication.",
        "operationId": "listModelEndpoints",
        "parameters": [
          {
            "description": "ModelRelay model ID.",
            "in": "path",
            "name": "model_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelEndpointsResponse"
                }
              }
            },
            "description": "The model's routes"
          },
          "404": {
            "description": "No servable route for this model"
          }
        },
        "summary": "List a model's provider endpoints"
      }
    },
    "/projects": {
      "get": {
        "operationId": "listProjects",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "projects": {
                      "items": {
                        "$ref": "#/components/schemas/Project"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Project list"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List projects for the authenticated owner"
      },
      "post": {
        "operationId": "createProject",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "billing_display_name": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "billing_logo_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "billing_statement_descriptor": {
                    "maxLength": 22,
                    "pattern": "^$|^.{5,22}$",
                    "type": "string"
                  },
                  "billing_support_url": {
                    "format": "uri",
                    "maxLength": 1165,
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "markup_percentage": {
                    "maximum": 100,
                    "minimum": 0,
                    "type": "number"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "project": {
                      "$ref": "#/components/schemas/Project"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Project created"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a project"
      }
    },
    "/projects/{id}": {
      "delete": {
        "operationId": "deleteProject",
        "responses": {
          "204": {
            "description": "Project deleted"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a project"
      },
      "get": {
        "operationId": "getProject",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "project": {
                      "$ref": "#/components/schemas/Project"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Project found"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get a project"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        }
      ],
      "put": {
        "operationId": "updateProject",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "billing_display_name": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "billing_logo_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "billing_mode": {
                    "$ref": "#/components/schemas/BillingMode"
                  },
                  "billing_statement_descriptor": {
                    "maxLength": 22,
                    "pattern": "^$|^.{5,22}$",
                    "type": "string"
                  },
                  "billing_support_url": {
                    "format": "uri",
                    "maxLength": 1165,
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "default_tier_id": {
                    "description": "Free tier assigned to new managed customers and restored when paid subscriptions end.",
                    "format": "uuid",
                    "type": "string"
                  },
                  "markup_percentage": {
                    "maximum": 100,
                    "minimum": 0,
                    "type": "number"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "project": {
                      "$ref": "#/components/schemas/Project"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Project updated"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a project"
      }
    },
    "/projects/{id}/customers": {
      "get": {
        "operationId": "listProjectCustomers",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "customers": {
                      "items": {
                        "$ref": "#/components/schemas/CustomerWithSubscription"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Customer list"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List customers for a project"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        }
      ],
      "post": {
        "operationId": "createCustomer",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/CustomerWithSubscription"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Customer created"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a customer"
      }
    },
    "/projects/{id}/customers/{customer_id}": {
      "delete": {
        "operationId": "deleteCustomer",
        "responses": {
          "204": {
            "description": "Customer deleted"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a customer"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "in": "path",
          "name": "customer_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ]
    },
    "/projects/{id}/sql-profiles": {
      "get": {
        "operationId": "listProjectSQLProfiles",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "profiles": {
                      "items": {
                        "$ref": "#/components/schemas/SQLProfile"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "SQL profile list"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List project SQL profiles"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        }
      ],
      "post": {
        "operationId": "createProjectSQLProfile",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SQLProfileInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "profile": {
                      "$ref": "#/components/schemas/SQLProfile"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "SQL profile created"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a project SQL profile"
      }
    },
    "/projects/{id}/sql-profiles/{profile_id}": {
      "delete": {
        "operationId": "deleteProjectSQLProfile",
        "responses": {
          "204": {
            "description": "SQL profile deleted"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a project SQL profile"
      },
      "get": {
        "operationId": "getProjectSQLProfile",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "profile": {
                      "$ref": "#/components/schemas/SQLProfile"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "SQL profile details"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get a project SQL profile"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "$ref": "#/components/parameters/SQLProfileID"
        }
      ],
      "put": {
        "operationId": "updateProjectSQLProfile",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SQLProfileUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "profile": {
                      "$ref": "#/components/schemas/SQLProfile"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "SQL profile updated"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a project SQL profile"
      }
    },
    "/projects/{id}/tiers": {
      "get": {
        "operationId": "listProjectTiers",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "tiers": {
                      "items": {
                        "$ref": "#/components/schemas/Tier"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Tier list"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List tiers for a project"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        }
      ],
      "post": {
        "operationId": "createTier",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TierCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "tier": {
                      "$ref": "#/components/schemas/Tier"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Tier created"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a tier"
      }
    },
    "/projects/{id}/tiers/{tier_id}": {
      "delete": {
        "operationId": "deleteTier",
        "responses": {
          "204": {
            "description": "Tier deleted"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a tier"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "in": "path",
          "name": "tier_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ],
      "put": {
        "operationId": "updateTier",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TierUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Tier updated"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a tier"
      }
    },
    "/projects/{id}/tool-hooks": {
      "get": {
        "operationId": "listProjectToolHooks",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "hooks": {
                      "items": {
                        "$ref": "#/components/schemas/ToolHookConfig"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Tool hook list"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List project tool hooks"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        }
      ],
      "post": {
        "operationId": "createProjectToolHook",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ToolHookConfigInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "hook": {
                      "$ref": "#/components/schemas/ToolHookConfig"
                    },
                    "signing_secret": {
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Tool hook created"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a project tool hook"
      }
    },
    "/projects/{id}/tool-hooks/{hook_id}": {
      "delete": {
        "operationId": "deleteProjectToolHook",
        "responses": {
          "204": {
            "description": "Tool hook deleted"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a project tool hook"
      },
      "get": {
        "operationId": "getProjectToolHook",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "hook": {
                      "$ref": "#/components/schemas/ToolHookConfig"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Tool hook details"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get a project tool hook"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "$ref": "#/components/parameters/ToolHookID"
        }
      ],
      "put": {
        "operationId": "updateProjectToolHook",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ToolHookConfigUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "hook": {
                      "$ref": "#/components/schemas/ToolHookConfig"
                    },
                    "signing_secret": {
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Tool hook updated"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a project tool hook"
      }
    },
    "/projects/{id}/tool-hooks/{hook_id}/events": {
      "get": {
        "operationId": "listProjectToolHookEvents",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "events": {
                      "items": {
                        "$ref": "#/components/schemas/ToolHookEvent"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Tool hook events"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List tool hook delivery events"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "$ref": "#/components/parameters/ToolHookID"
        }
      ]
    },
    "/projects/{id}/tool-hooks/{hook_id}/test": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "$ref": "#/components/parameters/ToolHookID"
        }
      ],
      "post": {
        "operationId": "testProjectToolHook",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ToolHookTestResult"
                }
              }
            },
            "description": "Tool hook test result"
          },
          "502": {
            "description": "Tool hook test failed"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Test a tool hook"
      }
    },
    "/projects/{id}/webhooks": {
      "get": {
        "operationId": "listProjectWebhooks",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "webhooks": {
                      "items": {
                        "$ref": "#/components/schemas/WebhookConfig"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Webhook list"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List project webhooks"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        }
      ],
      "post": {
        "operationId": "createProjectWebhook",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookConfigInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "webhook": {
                      "$ref": "#/components/schemas/WebhookConfig"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Webhook created"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Create a project webhook"
      }
    },
    "/projects/{id}/webhooks/{webhook_id}": {
      "delete": {
        "operationId": "deleteProjectWebhook",
        "responses": {
          "204": {
            "description": "Webhook deleted"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Delete a project webhook"
      },
      "get": {
        "operationId": "getProjectWebhook",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "webhook": {
                      "$ref": "#/components/schemas/WebhookConfig"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Webhook details"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get a project webhook"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "$ref": "#/components/parameters/WebhookID"
        }
      ],
      "put": {
        "operationId": "updateProjectWebhook",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookConfigUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "webhook": {
                      "$ref": "#/components/schemas/WebhookConfig"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Webhook updated"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Update a project webhook"
      }
    },
    "/projects/{id}/webhooks/{webhook_id}/events": {
      "get": {
        "operationId": "listProjectWebhookEvents",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "event_type",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "events": {
                      "items": {
                        "$ref": "#/components/schemas/OutboundWebhookEvent"
                      },
                      "type": "array"
                    },
                    "next_cursor": {
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Webhook events"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "List webhook delivery events"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "$ref": "#/components/parameters/WebhookID"
        }
      ]
    },
    "/projects/{id}/webhooks/{webhook_id}/test": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "$ref": "#/components/parameters/WebhookID"
        }
      ],
      "post": {
        "operationId": "testProjectWebhook",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "event_type": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookTestResult"
                }
              }
            },
            "description": "Webhook test result"
          },
          "502": {
            "description": "Webhook test failed"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Test a webhook"
      }
    },
    "/chat/completions": {
      "post": {
        "description": "Creates a text or tool-call completion using the OpenAI Chat Completions wire format. Streaming uses SSE. Requests share ModelRelay authorization, routing, execution, usage and billing; unsupported controls fail explicitly.",
        "operationId": "createChatCompletion",
        "parameters": [
          {
            "description": "Prompt-cache routing key, as prompt_cache_key. When both are sent they must match.",
            "in": "header",
            "name": "X-Session-Affinity",
            "required": false,
            "schema": {
              "maxLength": 256,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "example": "data: {\"object\":\"chat.completion.chunk\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"Hello\"},\"finish_reason\":null}]}\n\ndata: [DONE]\n\n"
              }
            },
            "headers": {
              "X-ModelRelay-Execution-Id": {
                "description": "Stable execution correlation ID for retrieving content-free pricing and settlement evidence.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "X-ModelRelay-Provider": {
                "description": "Slug of the provider whose route served the request, as accepted by provider.only.",
                "schema": {
                  "type": "string"
                }
              },
              "X-ModelRelay-Prompt-Cache-Key": {
                "description": "Handling of an explicitly supplied prompt-cache key. Reports request handling, not a cache hit. Absent without a key. not_dispatched means a gateway response-cache replay avoided the provider; superseded means caller-placed breakpoints took precedence.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "unknown",
                    "ignored",
                    "affinity",
                    "breakpoint",
                    "unsupported",
                    "not_dispatched",
                    "superseded"
                  ]
                }
              }
            },
            "description": "Chat completion"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAICompatibleErrorResponse"
                }
              }
            },
            "headers": {
              "X-ModelRelay-Execution-Id": {
                "description": "Stable execution correlation ID when the failure occurred after execution preflight. It is absent on preflight failures.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "X-ModelRelay-Provider": {
                "description": "Slug of the provider whose route served the request, as accepted by provider.only.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "OpenAI-SDK-decodable error preserving ModelRelay status and error code semantics"
          }
        },
        "security": [
          {
            "openAICompatAuth": []
          }
        ],
        "servers": [
          {
            "url": "https://api.modelrelay.ai/v1"
          }
        ],
        "summary": "Create an OpenAI-compatible chat completion"
      }
    },
    "/responses": {
      "post": {
        "description": "Creates a model response. Auth accepts secret API keys or bearer tokens. Bearer tokens may be owner session tokens (dashboard/server) or customer tokens; publishable keys are not allowed. Persistent tool state requires a state handle created via /state-handles.",
        "operationId": "createResponse",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponsesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponsesResponse"
                }
              }
            },
            "headers": {
              "X-ModelRelay-Execution-Id": {
                "description": "Stable execution correlation ID for retrieving content-free evidence after unary or streaming completion.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "X-ModelRelay-Provider": {
                "description": "Slug of the provider whose route served the request, as accepted by provider.only.",
                "schema": {
                  "type": "string"
                }
              },
              "X-ModelRelay-Prompt-Cache-Key": {
                "description": "Handling of an explicitly supplied prompt-cache key. Reports request handling, not a cache hit. Absent without a key. not_dispatched means a gateway response-cache replay avoided the provider; superseded means caller-placed breakpoints took precedence.",
                "schema": {
                  "type": "string",
                  "enum": [
                    "unknown",
                    "ignored",
                    "affinity",
                    "breakpoint",
                    "unsupported",
                    "not_dispatched",
                    "superseded"
                  ]
                }
              }
            },
            "description": "Response"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "headers": {
              "X-ModelRelay-Execution-Id": {
                "description": "Stable execution correlation ID when the failure occurred after execution preflight. It is absent on preflight failures.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "X-ModelRelay-Provider": {
                "description": "Slug of the provider whose route served the request, as accepted by provider.only.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Typed request, routing, ModelRelay-path, or upstream failure"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Create a response via the provider-agnostic API"
      }
    },
    "/responses/executions/{execution_id}/evidence": {
      "get": {
        "description": "Retrieves immutable content-free execution evidence joined to the exact settled usage record. The authenticated project owner may audit project and customer executions; customer-scoped callers may retrieve only their own scope and do not receive the project owner's provider-rate or provider-cost basis.",
        "operationId": "getResponseExecutionEvidence",
        "parameters": [
          {
            "in": "path",
            "name": "execution_id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseExecutionEvidence"
                }
              }
            },
            "description": "Immutable direct Responses execution evidence"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Invalid execution identifier"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Unauthorized"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Execution evidence not found in the authenticated scope"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Stored execution evidence or its usage linkage failed integrity verification"
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Customer ownership lookup failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Execution evidence storage is unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Get direct Responses execution evidence"
      }
    },
    "/responses/resolve": {
      "post": {
        "description": "Resolves one required concrete model and optional provider through the same authentication, customer/tier authorization, routing, and canonical pricing path used by direct Responses execution. This operation does not invoke a provider or create usage, settlement, session, or execution evidence state.",
        "operationId": "resolveResponse",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponseResolveRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseResolveResponse"
                }
              }
            },
            "description": "Authorized direct Responses route and pricing provenance"
          },
          "default": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Typed validation, authentication, authorization, routing, or pricing failure"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Resolve a direct Responses route without execution"
      }
    },
    "/sql/validate": {
      "post": {
        "operationId": "validateSQL",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SQLValidateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SQLValidateResponse"
                }
              }
            },
            "description": "SQL validated"
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "SQL profile not found"
          }
        },
        "security": [
          {
            "apiKeyAuth": []
          },
          {
            "bearerAuth": []
          }
        ],
        "summary": "Validate a SQL query"
      }
    },
    "/state-handles": {
      "get": {
        "description": "List state handles for the current project or customer.",
        "operationId": "listStateHandles",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "format": "int32",
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StateHandleListResponse"
                }
              }
            },
            "description": "State handles"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "List state handles"
      },
      "post": {
        "description": "Create a state handle for persistent /responses tool state.",
        "operationId": "createStateHandle",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StateHandleCreateRequest"
              }
            }
          },
          "required": false
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StateHandleResponse"
                }
              }
            },
            "description": "State handle"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Create a state handle"
      }
    },
    "/state-handles/{state_id}": {
      "delete": {
        "operationId": "deleteStateHandle",
        "parameters": [
          {
            "in": "path",
            "name": "state_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "State handle deleted"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Delete a state handle"
      }
    },
    "/responses/batch": {
      "post": {
        "operationId": "createResponsesBatch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponsesBatchRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponsesBatchResponse"
                }
              }
            },
            "description": "Batch response results"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Create multiple responses concurrently (batch)"
      }
    },
    "/grants/resolve": {
      "post": {
        "description": "Resolve the existing immutable tier-scoped RLM profile once for local Droste scaffold preflight. Project API keys must supply X-ModelRelay-Customer-Id; customer bearer tokens carry their scope and must not supply the header. This endpoint accepts no task content or strategy.",
        "operationId": "resolveExecutionGrant",
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerScope"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExecutionGrantResolveRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resolved immutable execution authority",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecutionGrantResolveResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing or contradictory customer scope, or invalid/non-profile selector. CUSTOMER_SCOPE_REQUIRED is distinct from INVALID_INPUT.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated token is not a customer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "409": {
            "description": "Profile is not executable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Resolve an external RLM execution grant"
      }
    },
    "/grants": {
      "post": {
        "description": "Persist an immutable resolved run specification and create a durable, server-budgeted external execution grant under the same explicit customer authority used for resolution. Project API keys must supply X-ModelRelay-Customer-Id; customer bearer tokens must omit it. The short-lived callback credential is returned exactly once.",
        "operationId": "createExecutionGrant",
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerScope"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExecutionGrantCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Execution grant and one-time credential",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExecutionGrantCreateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing or contradictory customer scope, invalid profile, or invalid scaffold",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "402": {
            "description": "Account, tier, or wallet authorization cannot cover the immutable execution spend ceiling",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated token is not a customer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "409": {
            "description": "Resolved profile changed after preflight",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "503": {
            "description": "Execution grant storage unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Create an external RLM execution grant"
      }
    },
    "/grants/{grant_id}/finalize": {
      "post": {
        "description": "Close callback admission, freeze trusted role accounting and typed failures, and idempotently finalize immutable execution evidence under the lease's customer authority. Project API keys must reuse X-ModelRelay-Customer-Id; customer bearer tokens must omit it.",
        "operationId": "finalizeExecutionGrant",
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerScope"
          },
          {
            "in": "path",
            "name": "grant_id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Final immutable execution evidence",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RLMRetrievedExecutionEvidence"
                }
              }
            }
          },
          "400": {
            "description": "Missing or contradictory customer scope, or invalid execution identifier",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated token is not a customer token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "404": {
            "description": "Execution grant not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          },
          "409": {
            "description": "Admitted callbacks are still settling",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Finalize an external RLM execution grant"
      }
    },
    "/grants/{grant_id}/evidence": {
      "get": {
        "description": "Retrieve content-free immutable execution, pricing, role settlement, and typed correlated failure evidence for an RLM execution. The authenticated caller must own the project and, for customer tokens, the customer scope.",
        "operationId": "getRLMExecutionEvidence",
        "parameters": [
          {
            "$ref": "#/components/parameters/CustomerScope"
          },
          {
            "in": "path",
            "name": "grant_id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RLMRetrievedExecutionEvidence"
                }
              }
            },
            "description": "Immutable RLM execution evidence"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Contradictory customer scope or invalid execution identifier"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Unauthorized"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Execution evidence not found in the authenticated scope"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/APIError"
                }
              }
            },
            "description": "Stored execution evidence failed integrity verification"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Get RLM execution evidence"
      }
    },
    "/customers/me/models": {
      "get": {
        "description": "Returns the customer-visible model catalog for the authenticated customer's tier: selectable presets (named role-aware model routing choices) plus the concrete allowed models.\nDoes not include developer-private per-model cost accounting.\n",
        "operationId": "getCustomerMeModels",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerMeModelsResponse"
                }
              }
            },
            "description": "Model catalog"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Customer or tier not found"
          },
          "500": {
            "description": "Internal server error"
          },
          "503": {
            "description": "Service unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Get the authenticated customer's model catalog"
      }
    },
    "/projects/{id}/tiers/{tier_id}/presets": {
      "put": {
        "description": "Replaces the tier's full preset set (declarative replace-all; an empty list removes all presets). Every referenced model must be in the tier's allowed model list; preset codes must be selector-safe; at most one preset may be the default.\n",
        "operationId": "putTierPresets",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TierPresetsPutRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TierPresetsResponse"
                }
              }
            },
            "description": "Stored preset set"
          },
          "400": {
            "description": "Validation failure (unknown model, duplicate/invalid code, multiple defaults)"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Tier not found"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Replace a tier's model presets"
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "in": "path",
          "name": "tier_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        }
      ]
    },
    "/projects/{id}/tiers/{tier_id}/presets/{preset_code}/rlm-profile": {
      "parameters": [
        {
          "$ref": "#/components/parameters/ProjectID"
        },
        {
          "in": "path",
          "name": "tier_id",
          "required": true,
          "schema": {
            "format": "uuid",
            "type": "string"
          }
        },
        {
          "description": "Selector-safe code of the existing preset to advance.",
          "in": "path",
          "name": "preset_code",
          "required": true,
          "schema": {
            "minLength": 1,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]*$",
            "type": "string"
          }
        }
      ],
      "post": {
        "description": "Installs a profile from the server's reviewed registry on exactly one existing tier preset. The caller supplies no model routes, limits, revision JSON, or create policy. The expected current execution kind and concrete model are checked under the same transaction lock as the write.",
        "operationId": "updateTierPresetRLMProfile",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TierPresetRLMProfileUpdateRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TierPresetRLMProfileUpdateResponse"
                }
              }
            },
            "description": "Reviewed profile installed, or already current"
          },
          "400": {
            "description": "Invalid request, unknown reviewed profile, or disallowed profile target"
          },
          "401": {
            "description": "Unauthorized"
          },
          "404": {
            "description": "Project, tier, or preset not found"
          },
          "409": {
            "description": "Current-state expectation stale, model unavailable, or lifecycle incompatible"
          },
          "503": {
            "description": "Project catalog unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "summary": "Install a reviewed RLM profile on an existing tier preset"
      }
    }
  },
  "servers": [
    {
      "url": "https://api.modelrelay.ai/api/v1"
    }
  ]
}
