{
  "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"
      },
      "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"
      },
      "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.",
            "type": "string"
          },
          "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"
        ],
        "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"
          },
          "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_cents": {
            "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_cents": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderId"
          },
          "training_cutoff": {
            "description": "Training cutoff in YYYY-MM format",
            "type": "string"
          }
        },
        "required": [
          "model_id",
          "provider",
          "display_name",
          "description",
          "capabilities",
          "context_window",
          "max_output_tokens",
          "training_cutoff",
          "deprecated",
          "deprecation_message",
          "model_cost_projection_available"
        ],
        "type": "object"
      },
      "ContextTokenRate": {
        "properties": {
          "band": {
            "type": "string"
          },
          "min_input_tokens": {
            "format": "uint64",
            "minimum": 0,
            "type": "integer"
          },
          "input_cost_per_million_cents": {
            "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_cents": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "band",
          "min_input_tokens",
          "input_cost_per_million_cents",
          "cache_read_input_cost_per_million_millicents",
          "cache_write_input_cost_per_million_millicents",
          "output_cost_per_million_cents"
        ],
        "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"
        ],
        "type": "string"
      },
      "ModelId": {
        "description": "LLM model identifier (e.g., claude-sonnet-5, gpt-4o).",
        "maxLength": 128,
        "minLength": 1,
        "type": "string"
      },
      "ModelsResponse": {
        "properties": {
          "models": {
            "items": {
              "$ref": "#/components/schemas/Model"
            },
            "type": "array"
          }
        },
        "required": [
          "models"
        ],
        "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_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"
        ],
        "type": "string"
      },
      "RequestId": {
        "description": "Unique identifier for an LLM request within a workflow run.",
        "format": "uuid",
        "type": "string"
      },
      "ChatCompletionRequest": {
        "additionalProperties": false,
        "description": "Initial non-streaming, text-only OpenAI Chat Completions compatibility request. Unsupported fields are rejected. max_tokens is a legacy alias for max_completion_tokens; requests containing both are rejected.",
        "not": {
          "anyOf": [
            {
              "required": [
                "max_completion_tokens",
                "max_tokens"
              ]
            },
            {
              "required": [
                "temperature",
                "reasoning_effort"
              ]
            }
          ]
        },
        "properties": {
          "max_completion_tokens": {
            "description": "Maximum completion token budget. Translated to ModelRelay max_output_tokens.",
            "format": "uint32",
            "minimum": 1,
            "type": "integer"
          },
          "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"
          },
          "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"
          },
          "stream": {
            "const": false,
            "description": "Streaming is not supported in the initial compatibility surface; omit this field or set it to false.",
            "type": "boolean"
          },
          "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"
          },
          "top_p": {
            "description": "Nucleus sampling probability.",
            "maximum": 1,
            "minimum": 0,
            "type": "number"
          },
          "logprobs": {
            "description": "Return raw token log-probability facts when supported by the resolved provider.",
            "type": "boolean"
          },
          "top_logprobs": {
            "description": "Number of alternative token facts; requires logprobs=true.",
            "maximum": 20,
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "ChatCompletionModelId": {
        "description": "ModelRelay model identifier or tier-supported model selector.",
        "type": "string"
      },
      "ChatCompletionRequestMessage": {
        "description": "Role-specific non-streaming, text-only Chat Completions input message.",
        "discriminator": {
          "mapping": {
            "assistant": "#/components/schemas/ChatCompletionAssistantRequestMessage",
            "developer": "#/components/schemas/ChatCompletionDeveloperRequestMessage",
            "system": "#/components/schemas/ChatCompletionSystemRequestMessage",
            "user": "#/components/schemas/ChatCompletionUserRequestMessage"
          },
          "propertyName": "role"
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/ChatCompletionDeveloperRequestMessage"
          },
          {
            "$ref": "#/components/schemas/ChatCompletionSystemRequestMessage"
          },
          {
            "$ref": "#/components/schemas/ChatCompletionUserRequestMessage"
          },
          {
            "$ref": "#/components/schemas/ChatCompletionAssistantRequestMessage"
          }
        ]
      },
      "ChatCompletionRequestMessageContent": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "items": {
              "$ref": "#/components/schemas/ChatCompletionTextPart"
            },
            "minItems": 1,
            "type": "array"
          }
        ]
      },
      "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/ChatCompletionRequestMessageContent"
          },
          "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": {
            "$ref": "#/components/schemas/ChatCompletionRequestMessageContent"
          },
          "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": {
            "description": "Assistant completion replay metadata. Only null or an empty array is accepted and ignored; tool calls are unsupported.",
            "items": {
              "additionalProperties": false,
              "type": "object"
            },
            "maxItems": 0,
            "nullable": true,
            "type": "array"
          }
        },
        "required": [
          "role",
          "content"
        ],
        "type": "object"
      },
      "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"
          },
          "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"
            ],
            "type": "string",
            "x-enum-varnames": [
              "ChatCompletionFinishReasonStop",
              "ChatCompletionFinishReasonLength",
              "ChatCompletionFinishReasonContentFilter"
            ]
          },
          "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"
          },
          "role": {
            "const": "assistant",
            "type": "string"
          }
        },
        "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"
          }
        },
        "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. It must cover the conservative serialized-request estimate plus the 4096-token provider-framing allowance, cannot be combined with state_id or file/multimodal input, and is validated against the selected model's context window before authorizing every reachable pricing band. This is not forwarded as a provider short/long-context selector; omit it to authorize conservatively across the full context window.",
            "format": "int32",
            "minimum": 4097,
            "type": "integer"
          },
          "model": {
            "$ref": "#/components/schemas/ModelId"
          },
          "output_format": {
            "$ref": "#/components/schemas/OutputFormat"
          },
          "provider": {
            "$ref": "#/components/schemas/ProviderId"
          },
          "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"
            ]
          }
        },
        "required": [
          "input"
        ],
        "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": {
            "type": "integer"
          },
          "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"
          },
          "model_input_cost_cents": {
            "description": "Provider input cost in cents per million tokens when model_cost_projection_available is true. Omitted when the scalar projection is unavailable.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "model_output_cost_cents": {
            "description": "Provider output cost in cents per million tokens when model_cost_projection_available is true. Omitted when the scalar projection is unavailable.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "tier_id": {
            "format": "uuid",
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "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"
              }
            },
            "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"
              ],
              "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"
              ],
              "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"
              ],
              "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"
          }
        },
        "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"
          }
        },
        "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"
          }
        },
        "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": {
          "model": {
            "type": "string"
          },
          "temperature": {
            "type": "number"
          },
          "stop": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "seed": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          }
        },
        "required": [
          "model",
          "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": "Authoritative exact maximum in microcents (1 cent = 1,000,000 microcents), derived with checked integer arithmetic from the immutable pricing and execution budgets."
          }
        },
        "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": {
          "model": {
            "type": "string"
          },
          "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": [
          "model",
          "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
          }
        },
        "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": {
          "model": {
            "type": "string",
            "minLength": 1
          },
          "provider": {
            "type": "string",
            "minLength": 1
          }
        },
        "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"
          },
          "pricing": {
            "$ref": "#/components/schemas/ResponseExecutionPricing"
          }
        },
        "required": [
          "resolved_model",
          "provider",
          "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
          },
          "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_cents": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          },
          "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_cents": {
            "format": "int64",
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "model_id",
          "input_cost_per_million_cents",
          "cache_read_input_cost_per_million_millicents",
          "cache_write_input_cost_per_million_millicents",
          "output_cost_per_million_cents"
        ],
        "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 selector. Use as model \"preset:<code>\" on requests."
          },
          "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",
          "reasoning_efforts",
          "is_default"
        ],
        "properties": {
          "model_id": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "capabilities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "reasoning_efforts": {
            "type": "array",
            "description": "Reasoning-effort request values supported by this model. Empty when ModelRelay omits reasoning controls and preserves the provider default.",
            "items": {
              "type": "string",
              "enum": [
                "none",
                "minimal",
                "low",
                "medium",
                "high",
                "xhigh",
                "max"
              ],
              "x-enum-varnames": [
                "CustomerMeReasoningNone",
                "CustomerMeReasoningMinimal",
                "CustomerMeReasoningLow",
                "CustomerMeReasoningMedium",
                "CustomerMeReasoningHigh",
                "CustomerMeReasoningXHigh",
                "CustomerMeReasoningMax"
              ]
            }
          },
          "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": "Selector-safe code (alphanumeric, '-', '_'). Customers select it as model \"preset:<code>\"."
          },
          "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"
          }
        }
      },
      "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"
            ]
          }
        }
      }
    },
    "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/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/CustomerMeSubscriptionResponse"
                }
              }
            },
            "description": "Tier changed successfully"
          },
          "400": {
            "description": "Invalid request (missing tier_code, same tier, 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, 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"
      }
    },
    "/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 one non-streaming text completion using the OpenAI Chat Completions wire shape. The request is translated at the typed boundary and executed through ModelRelay's standard Responses preflight, routing, billing, usage, timeout, health, and error pipeline. Unknown fields, stream=true, tools, non-text modalities, unsupported roles, and unsupported model controls are rejected.",
        "operationId": "createChatCompletion",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              }
            },
            "headers": {
              "X-ModelRelay-Execution-Id": {
                "description": "Stable execution correlation ID for retrieving content-free pricing and settlement evidence.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              }
            },
            "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"
                }
              }
            },
            "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"
                }
              }
            },
            "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"
                }
              }
            },
            "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"
          }
        }
      ]
    }
  },
  "servers": [
    {
      "url": "https://api.modelrelay.ai/api/v1"
    }
  ]
}
