{
  "components": {
    "responses": {
      "Gateway400": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayError"
            }
          }
        },
        "description": "Invalid request (invalid_request_error)."
      },
      "Gateway401": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayError"
            }
          }
        },
        "description": "Missing or invalid API key (authentication_error)."
      },
      "Gateway402": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayError"
            }
          }
        },
        "description": "Pay-as-you-go wallet cannot cover the request (Anthropic: billing_error; OpenAI: invalid_request_error, code insufficient_quota). A human tops up at /app/billing."
      },
      "Gateway403": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayError"
            }
          }
        },
        "description": "Model not in the key's plan, model not free for a free key, or account suspended (permission_error)."
      },
      "Gateway404": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayError"
            }
          }
        },
        "description": "Unknown or disabled model (not_found_error)."
      },
      "Gateway413": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayError"
            }
          }
        },
        "description": "Body larger than 32 MiB (Anthropic: request_too_large; OpenAI: invalid_request_error)."
      },
      "Gateway429": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayError"
            }
          }
        },
        "description": "Rate, concurrency, daily or promotion limit (rate_limit_error). Honour Retry-After; daily limits reset at 00:00 Asia/Ho_Chi_Minh."
      },
      "Gateway503": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayError"
            }
          }
        },
        "description": "Every upstream failed after failover (OpenAI shape: service_unavailable_error). Retry with backoff."
      },
      "Gateway529": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayError"
            }
          }
        },
        "description": "Every upstream overloaded (Anthropic shape: overloaded_error). Retry with backoff."
      }
    },
    "schemas": {
      "AgentMe": {
        "properties": {
          "key": {
            "additionalProperties": true,
            "description": "The calling key.",
            "properties": {
              "billingKind": {
                "description": "",
                "type": "string"
              },
              "effectivePlanId": {
                "description": "",
                "type": "string"
              },
              "id": {
                "description": "",
                "type": "string"
              },
              "limits": {
                "type": "object"
              },
              "name": {
                "description": "",
                "type": "string"
              },
              "planId": {
                "description": "",
                "type": "string"
              },
              "planName": {
                "description": "",
                "type": "string"
              },
              "prefix": {
                "description": "",
                "type": "string"
              },
              "usageToday": {
                "properties": {
                  "requests": {
                    "description": "",
                    "type": "integer"
                  },
                  "tokens": {
                    "description": "",
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            },
            "type": "object"
          },
          "models": {
            "description": "Model ids this key may call now.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "topupUrl": {
            "description": "https://quotax.sh/app/billing",
            "type": "string"
          },
          "user": {
            "properties": {
              "username": {
                "description": "",
                "type": "string"
              }
            },
            "type": "object"
          },
          "wallet": {
            "properties": {
              "balanceMicrousd": {
                "description": "",
                "type": "integer"
              },
              "balanceUsd": {
                "type": "number"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "AnthropicError": {
        "properties": {
          "error": {
            "properties": {
              "message": {
                "description": "",
                "type": "string"
              },
              "type": {
                "description": "authentication_error, billing_error, permission_error, not_found_error, rate_limit_error, overloaded_error, ...",
                "type": "string"
              }
            },
            "type": "object"
          },
          "request_id": {
            "description": "",
            "type": "string"
          },
          "type": {
            "const": "error"
          }
        },
        "type": "object"
      },
      "AnthropicModelList": {
        "properties": {
          "data": {
            "items": {
              "properties": {
                "created_at": {
                  "description": "",
                  "type": "string"
                },
                "display_name": {
                  "description": "",
                  "type": "string"
                },
                "id": {
                  "description": "",
                  "type": "string"
                },
                "max_input_tokens": {
                  "description": "",
                  "type": "integer"
                },
                "max_tokens": {
                  "description": "",
                  "type": "integer"
                },
                "type": {
                  "const": "model"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "first_id": {
            "description": "",
            "type": "string"
          },
          "has_more": {
            "description": "",
            "type": "boolean"
          },
          "last_id": {
            "description": "",
            "type": "string"
          }
        },
        "type": "object"
      },
      "Catalog": {
        "properties": {
          "models": {
            "items": {
              "additionalProperties": true,
              "description": "Model.",
              "properties": {
                "capabilities": {
                  "properties": {
                    "reasoning": {
                      "description": "",
                      "type": "boolean"
                    },
                    "tools": {
                      "description": "",
                      "type": "boolean"
                    },
                    "vision": {
                      "description": "",
                      "type": "boolean"
                    }
                  },
                  "type": "object"
                },
                "contextWindow": {
                  "description": "",
                  "type": "integer"
                },
                "description": {
                  "description": "",
                  "type": "string"
                },
                "free": {
                  "description": "True when a Free-plan key can call this model right now at no cost.",
                  "type": "boolean"
                },
                "id": {
                  "description": "Use this in the model field.",
                  "type": "string"
                },
                "maxOutput": {
                  "description": "",
                  "type": "integer"
                },
                "name": {
                  "description": "",
                  "type": "string"
                },
                "ownedBy": {
                  "description": "",
                  "type": "string"
                },
                "price": {
                  "description": "USD per 1M tokens.",
                  "properties": {
                    "cacheRead": {
                      "type": "number"
                    },
                    "cacheWrite": {
                      "type": "number"
                    },
                    "input": {
                      "type": "number"
                    },
                    "output": {
                      "type": "number"
                    }
                  },
                  "type": "object"
                },
                "promo": {
                  "description": "Best active promotion for any plan: id, name, discountPct, endsAt (epoch ms), planIds.",
                  "type": [
                    "object",
                    "null"
                  ]
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "plans": {
            "items": {
              "additionalProperties": true,
              "description": "Plan.",
              "properties": {
                "id": {
                  "description": "",
                  "type": "string"
                },
                "kind": {
                  "description": "free, payg or subscription",
                  "type": "string"
                },
                "limits": {
                  "description": "rpm, concurrency, dailyRequests, dailyTokens, maxKeys (keys per account); 0 means unlimited.",
                  "type": "object"
                },
                "models": {
                  "description": "Allow-list of model ids; empty means no allow-list (a free-kind plan still only calls models with free: true).",
                  "items": {
                    "type": "string"
                  },
                  "type": "array"
                },
                "name": {
                  "description": "",
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "promotions": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "site": {
            "additionalProperties": true,
            "description": "Site settings.",
            "properties": {
              "apiBaseUrl": {
                "description": "",
                "type": "string"
              },
              "signupEnabled": {
                "description": "",
                "type": "boolean"
              },
              "vndPerUsd": {
                "description": "",
                "type": "integer"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "DeviceAuthorization": {
        "properties": {
          "device_code": {
            "description": "Secret; only for polling /api/agent/token.",
            "type": "string"
          },
          "expires_in": {
            "description": "Seconds (900).",
            "type": "integer"
          },
          "interval": {
            "description": "Seconds between polls (5).",
            "type": "integer"
          },
          "user_code": {
            "description": "XXXX-XXXX, show it to the human.",
            "type": "string"
          },
          "verification_uri": {
            "description": "https://quotax.sh/activate",
            "type": "string"
          },
          "verification_uri_complete": {
            "description": "Open this to approve; it carries the code.",
            "type": "string"
          }
        },
        "required": [
          "device_code",
          "user_code",
          "verification_uri",
          "verification_uri_complete",
          "expires_in",
          "interval"
        ],
        "type": "object"
      },
      "DeviceGrant": {
        "properties": {
          "clientIp": {
            "description": "Address the request came from.",
            "type": "string"
          },
          "clientName": {
            "description": "Name the agent sent (unverified).",
            "type": "string"
          },
          "createdAt": {
            "description": "Epoch ms.",
            "type": "integer"
          },
          "expiresAt": {
            "description": "Epoch ms.",
            "type": "integer"
          },
          "planId": {
            "description": "Requested plan.",
            "type": "string"
          },
          "status": {
            "description": "pending, approved, denied or consumed",
            "type": "string"
          },
          "userCode": {
            "description": "",
            "type": "string"
          }
        },
        "type": "object"
      },
      "DeviceToken": {
        "properties": {
          "anthropic_base_url": {
            "description": "https://quotax.sh",
            "type": "string"
          },
          "api_key": {
            "description": "qtx-... Shown once.",
            "type": "string"
          },
          "base_url": {
            "description": "https://quotax.sh",
            "type": "string"
          },
          "key_id": {
            "description": "",
            "type": "string"
          },
          "key_prefix": {
            "description": "Safe to display.",
            "type": "string"
          },
          "openai_base_url": {
            "description": "https://quotax.sh/v1",
            "type": "string"
          },
          "plan_id": {
            "description": "",
            "type": "string"
          }
        },
        "type": "object"
      },
      "Error": {
        "description": "Error envelope of the /api routes.",
        "properties": {
          "error": {
            "properties": {
              "code": {
                "description": "Machine-readable code.",
                "type": "string"
              },
              "message": {
                "description": "Human-readable message.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "GatewayError": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AnthropicError"
          },
          {
            "$ref": "#/components/schemas/OpenAIError"
          }
        ],
        "description": "Errors follow the protocol you called."
      },
      "OpenAIError": {
        "properties": {
          "error": {
            "properties": {
              "code": {
                "description": "invalid_api_key, insufficient_quota, model_not_found, rate_limit_exceeded or null.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "message": {
                "description": "",
                "type": "string"
              },
              "param": {
                "type": "null"
              },
              "type": {
                "description": "authentication_error, permission_error, not_found_error, rate_limit_error, service_unavailable_error, ...",
                "type": "string"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "OpenAIModelList": {
        "properties": {
          "data": {
            "items": {
              "properties": {
                "created": {
                  "description": "",
                  "type": "integer"
                },
                "id": {
                  "description": "",
                  "type": "string"
                },
                "object": {
                  "const": "model"
                },
                "owned_by": {
                  "description": "",
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "object": {
            "const": "list"
          }
        },
        "type": "object"
      },
      "Usage": {
        "properties": {
          "byModel": {
            "items": {
              "properties": {
                "costMicrousd": {
                  "description": "",
                  "type": "integer"
                },
                "model": {
                  "description": "",
                  "type": "string"
                },
                "requests": {
                  "description": "",
                  "type": "integer"
                },
                "tokens": {
                  "description": "",
                  "type": "integer"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "daily": {
            "items": {
              "properties": {
                "costMicrousd": {
                  "description": "",
                  "type": "integer"
                },
                "day": {
                  "description": "YYYY-MM-DD (Asia/Ho_Chi_Minh)",
                  "type": "string"
                },
                "requests": {
                  "description": "",
                  "type": "integer"
                },
                "tokens": {
                  "description": "",
                  "type": "integer"
                }
              },
              "type": "object"
            },
            "type": "array"
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "apiKeyAuth": {
        "description": "x-api-key: qtx-... (Anthropic SDKs). Takes precedence over Authorization.",
        "in": "header",
        "name": "x-api-key",
        "type": "apiKey"
      },
      "bearerAuth": {
        "description": "Authorization: Bearer qtx-... (OpenAI SDKs, Claude Code ANTHROPIC_AUTH_TOKEN).",
        "scheme": "bearer",
        "type": "http"
      },
      "sessionCookie": {
        "description": "Signed-in customer session of the website.",
        "in": "cookie",
        "name": "qtx_session",
        "type": "apiKey"
      }
    }
  },
  "externalDocs": {
    "description": "Docs (Markdown)",
    "url": "https://quotax.sh/docs.md"
  },
  "info": {
    "contact": {
      "url": "https://quotax.sh/agents/"
    },
    "description": "The /v1 routes are wire-compatible with the official Anthropic and OpenAI SDKs: use base URL https://quotax.sh for Anthropic SDKs and Claude Code, https://quotax.sh/v1 for OpenAI SDKs, Codex and most tools. Model ids come from GET /api/public/catalog (no key) or GET /v1/models (per key); never hardcode them. Errors on /v1 follow the protocol you called; /api routes use {\"error\":{\"code\",\"message\"}}. Agent guide: https://quotax.sh/skill.md.",
    "summary": "LLM gateway with Anthropic Messages, OpenAI Chat Completions and OpenAI Responses on one key.",
    "title": "quotax.sh API",
    "version": "1"
  },
  "openapi": "3.1.0",
  "paths": {
    "/api/agent/device": {
      "post": {
        "description": "Show verification_uri_complete and user_code to the human, then poll /api/agent/token every interval seconds. Limited to 20 starts per IP per 10 minutes.",
        "operationId": "startDeviceAuthorization",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "clientName": {
                    "description": "Shown to the approving human. Control and format characters are dropped, whitespace is collapsed and the name is cut to 60 characters; empty means \"AI agent\".",
                    "type": "string"
                  },
                  "planId": {
                    "description": "Requested plan; the human may change it.",
                    "enum": [
                      "free",
                      "payg"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceAuthorization"
                }
              }
            },
            "description": "Device authorization."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Error, see error.code."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Error, see error.code."
          }
        },
        "security": [],
        "summary": "Start the device-code key flow (RFC 8628 shaped)",
        "tags": [
          "Agent"
        ]
      }
    },
    "/api/agent/device/{userCode}": {
      "get": {
        "description": "Used by the signed-in human on https://quotax.sh/activate, not by agents.",
        "operationId": "getDeviceGrant",
        "parameters": [
          {
            "description": "XXXX-XXXX; case, dashes and spaces are ignored.",
            "in": "path",
            "name": "userCode",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceGrant"
                }
              }
            },
            "description": "Pending request."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "unauthenticated: sign in first."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "not_found: unknown or expired code."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "already_decided: the code was already approved or denied."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "too_many_attempts: too many unknown codes from this account; wait a few minutes."
          }
        },
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "summary": "Look up a device code (approval page)",
        "tags": [
          "Agent"
        ]
      }
    },
    "/api/agent/device/{userCode}/approve": {
      "post": {
        "description": "Creates the key on the signed-in account and hands it to the agent's next poll. replaceKeyId revokes one of the account's keys on the same plan first, so a full key limit can be reused; the revoke is undone if the new key cannot be created.",
        "operationId": "approveDeviceGrant",
        "parameters": [
          {
            "description": "XXXX-XXXX; case, dashes and spaces are ignored.",
            "in": "path",
            "name": "userCode",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "keyName": {
                    "description": "Key name, 1-60 characters. Default: the client name.",
                    "type": "string"
                  },
                  "planId": {
                    "description": "Plan of the new key.",
                    "enum": [
                      "free",
                      "payg"
                    ],
                    "type": "string"
                  },
                  "replaceKeyId": {
                    "description": "Optional id of an existing, non-deleted key of this account on the same plan as planId; it is revoked before the new key is created.",
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "keyPrefix": {
                      "description": "Safe to display.",
                      "type": "string"
                    },
                    "ok": {
                      "description": "",
                      "type": "boolean"
                    },
                    "planId": {
                      "description": "",
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Approved."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "plan_not_allowed, invalid_key_name, or replace_plan_mismatch (replaceKeyId is on another plan)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "unauthenticated: sign in first."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "not_found: unknown or expired code. key_not_found: replaceKeyId is unknown, deleted or not this account's."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "max_keys_reached: the plan's key limit is reached (replace a key, pick another plan, or delete a key at /app/keys). already_decided: the code was already approved or denied."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "too_many_attempts: too many unknown codes from this account; wait a few minutes."
          }
        },
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "summary": "Approve a device code and create its key (approval page)",
        "tags": [
          "Agent"
        ]
      }
    },
    "/api/agent/device/{userCode}/deny": {
      "post": {
        "operationId": "denyDeviceGrant",
        "parameters": [
          {
            "description": "XXXX-XXXX; case, dashes and spaces are ignored.",
            "in": "path",
            "name": "userCode",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "ok": {
                      "description": "",
                      "type": "boolean"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Denied."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "unauthenticated: sign in first."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "not_found: unknown or expired code."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "already_decided: the code was already approved or denied."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "too_many_attempts: too many unknown codes from this account; wait a few minutes."
          }
        },
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "summary": "Deny a device code (approval page)",
        "tags": [
          "Agent"
        ]
      }
    },
    "/api/agent/me": {
      "get": {
        "description": "Validates a key and reports what it can do. Use it at session start and after 402/403/429 errors.",
        "operationId": "agentMe",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentMe"
                }
              }
            },
            "description": "Account view."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Error, see error.code."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Error, see error.code."
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Key, plan, wallet and callable models",
        "tags": [
          "Agent"
        ]
      }
    },
    "/api/agent/token": {
      "post": {
        "description": "The key is returned exactly once; store it (e.g. ~/.config/quotax/env, mode 0600) without printing it. A lost answer cannot be fetched again: the human revokes that key at /app/keys and the flow starts over.",
        "operationId": "pollDeviceToken",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "device_code": {
                    "description": "From /api/agent/device.",
                    "type": "string"
                  }
                },
                "required": [
                  "device_code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeviceToken"
                }
              }
            },
            "description": "Issued key."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "authorization_pending: not approved yet, keep polling (the message names the approval URL; a long wait can mean the approver hit a key limit). slow_down: polled before the interval, add 5 s to it. access_denied: the human denied it, stop. expired_token: expired, already used or unknown, start again."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "slow_down: too many polls from this address; wait, then poll at the interval."
          }
        },
        "security": [],
        "summary": "Poll for the API key",
        "tags": [
          "Agent"
        ]
      }
    },
    "/api/agent/usage": {
      "get": {
        "operationId": "agentUsage",
        "parameters": [
          {
            "in": "query",
            "name": "days",
            "required": false,
            "schema": {
              "default": 7,
              "maximum": 90,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            },
            "description": "Daily and per-model usage."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Error, see error.code."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Error, see error.code."
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Usage of the key's account",
        "tags": [
          "Agent"
        ]
      }
    },
    "/api/public/catalog": {
      "get": {
        "description": "Enabled models with prices in USD per 1M tokens, active promotions, public plans and limits. The source of truth for model ids.",
        "operationId": "publicCatalog",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Catalog"
                }
              }
            },
            "description": "Catalog."
          }
        },
        "security": [],
        "summary": "Live catalog (no key)",
        "tags": [
          "Catalog"
        ]
      }
    },
    "/mcp": {
      "post": {
        "description": "Stateless. Public tools (quotax_list_models, quotax_client_config, quotax_docs) need no key; key tools (quotax_account, quotax_usage, quotax_test_model) need Authorization: Bearer qtx-... GET and DELETE answer 405.",
        "operationId": "mcp",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "description": "JSON-RPC 2.0 request.",
                "properties": {
                  "id": {
                    "description": "Request id."
                  },
                  "jsonrpc": {
                    "description": "2.0",
                    "type": "string"
                  },
                  "method": {
                    "description": "e.g. initialize, tools/list, tools/call",
                    "type": "string"
                  },
                  "params": {
                    "type": "object"
                  }
                },
                "required": [
                  "jsonrpc",
                  "method"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "description": "JSON-RPC messages as server-sent events.",
                  "type": "string"
                }
              }
            },
            "description": "JSON-RPC response."
          }
        },
        "security": [
          {},
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Remote MCP server (Streamable HTTP, JSON-RPC 2.0)",
        "tags": [
          "MCP"
        ]
      }
    },
    "/v1/chat/completions": {
      "post": {
        "description": "Same request and response as OpenAI's POST /v1/chat/completions. When streaming, request the final usage chunk with stream_options.include_usage.",
        "operationId": "createChatCompletion",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "description": "Chat Completions request.",
                "properties": {
                  "max_completion_tokens": {
                    "description": "",
                    "type": "integer"
                  },
                  "max_tokens": {
                    "description": "",
                    "type": "integer"
                  },
                  "messages": {
                    "items": {
                      "type": "object"
                    },
                    "type": "array"
                  },
                  "model": {
                    "description": "Model id from the catalog.",
                    "type": "string"
                  },
                  "stream": {
                    "description": "Stream the answer as server-sent events.",
                    "type": "boolean"
                  },
                  "stream_options": {
                    "properties": {
                      "include_usage": {
                        "description": "",
                        "type": "boolean"
                      }
                    },
                    "type": "object"
                  },
                  "tools": {
                    "items": {
                      "type": "object"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "model",
                  "messages"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Chat completion.",
                  "properties": {
                    "choices": {
                      "items": {
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "id": {
                      "description": "",
                      "type": "string"
                    },
                    "object": {
                      "description": "chat.completion",
                      "type": "string"
                    },
                    "usage": {
                      "type": "object"
                    }
                  },
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "description": "Server-sent events in the protocol's own format.",
                  "type": "string"
                }
              }
            },
            "description": "Success."
          },
          "400": {
            "$ref": "#/components/responses/Gateway400"
          },
          "401": {
            "$ref": "#/components/responses/Gateway401"
          },
          "402": {
            "$ref": "#/components/responses/Gateway402"
          },
          "403": {
            "$ref": "#/components/responses/Gateway403"
          },
          "404": {
            "$ref": "#/components/responses/Gateway404"
          },
          "413": {
            "$ref": "#/components/responses/Gateway413"
          },
          "429": {
            "$ref": "#/components/responses/Gateway429"
          },
          "503": {
            "$ref": "#/components/responses/Gateway503"
          },
          "529": {
            "$ref": "#/components/responses/Gateway529"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "OpenAI Chat Completions",
        "tags": [
          "Inference"
        ]
      }
    },
    "/v1/messages": {
      "post": {
        "description": "Same request and response as Anthropic's POST /v1/messages; any catalog model works, not only Claude.",
        "operationId": "createMessage",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "description": "Anthropic Messages request.",
                "properties": {
                  "max_tokens": {
                    "description": "Output token cap (required by Anthropic).",
                    "type": "integer"
                  },
                  "messages": {
                    "description": "Conversation turns.",
                    "items": {
                      "type": "object"
                    },
                    "type": "array"
                  },
                  "model": {
                    "description": "Model id from the catalog.",
                    "type": "string"
                  },
                  "stream": {
                    "description": "Stream the answer as server-sent events.",
                    "type": "boolean"
                  },
                  "system": {
                    "description": "System prompt (string or content blocks)."
                  },
                  "tools": {
                    "items": {
                      "type": "object"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "model",
                  "max_tokens",
                  "messages"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Anthropic Message.",
                  "properties": {
                    "content": {
                      "items": {
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "id": {
                      "description": "",
                      "type": "string"
                    },
                    "type": {
                      "description": "message",
                      "type": "string"
                    },
                    "usage": {
                      "type": "object"
                    }
                  },
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "description": "Server-sent events in the protocol's own format.",
                  "type": "string"
                }
              }
            },
            "description": "Success."
          },
          "400": {
            "$ref": "#/components/responses/Gateway400"
          },
          "401": {
            "$ref": "#/components/responses/Gateway401"
          },
          "402": {
            "$ref": "#/components/responses/Gateway402"
          },
          "403": {
            "$ref": "#/components/responses/Gateway403"
          },
          "404": {
            "$ref": "#/components/responses/Gateway404"
          },
          "413": {
            "$ref": "#/components/responses/Gateway413"
          },
          "429": {
            "$ref": "#/components/responses/Gateway429"
          },
          "503": {
            "$ref": "#/components/responses/Gateway503"
          },
          "529": {
            "$ref": "#/components/responses/Gateway529"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Anthropic Messages",
        "tags": [
          "Inference"
        ]
      }
    },
    "/v1/messages/count_tokens": {
      "post": {
        "description": "Exact when the model's first route is an Anthropic upstream, otherwise an estimate (4 characters per token). Not billed.",
        "operationId": "countTokens",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "description": "Same body as /v1/messages without max_tokens.",
                "properties": {
                  "messages": {
                    "items": {
                      "type": "object"
                    },
                    "type": "array"
                  },
                  "model": {
                    "description": "Model id.",
                    "type": "string"
                  }
                },
                "required": [
                  "model",
                  "messages"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "input_tokens": {
                      "description": "",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "input_tokens"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Token count."
          },
          "400": {
            "$ref": "#/components/responses/Gateway400"
          },
          "401": {
            "$ref": "#/components/responses/Gateway401"
          },
          "402": {
            "$ref": "#/components/responses/Gateway402"
          },
          "403": {
            "$ref": "#/components/responses/Gateway403"
          },
          "404": {
            "$ref": "#/components/responses/Gateway404"
          },
          "413": {
            "$ref": "#/components/responses/Gateway413"
          },
          "429": {
            "$ref": "#/components/responses/Gateway429"
          },
          "503": {
            "$ref": "#/components/responses/Gateway503"
          },
          "529": {
            "$ref": "#/components/responses/Gateway529"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Count input tokens (Anthropic shape)",
        "tags": [
          "Inference"
        ]
      }
    },
    "/v1/models": {
      "get": {
        "description": "Lists only the models the key's plan allows right now (free keys see only models that are free now). Anthropic shape when an anthropic-version or x-api-key header is sent, otherwise OpenAI shape.",
        "operationId": "listModels",
        "parameters": [
          {
            "description": "Any value selects the Anthropic list shape.",
            "in": "header",
            "name": "anthropic-version",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/OpenAIModelList"
                    },
                    {
                      "$ref": "#/components/schemas/AnthropicModelList"
                    }
                  ]
                }
              }
            },
            "description": "Model list."
          },
          "400": {
            "$ref": "#/components/responses/Gateway400"
          },
          "401": {
            "$ref": "#/components/responses/Gateway401"
          },
          "402": {
            "$ref": "#/components/responses/Gateway402"
          },
          "403": {
            "$ref": "#/components/responses/Gateway403"
          },
          "404": {
            "$ref": "#/components/responses/Gateway404"
          },
          "413": {
            "$ref": "#/components/responses/Gateway413"
          },
          "429": {
            "$ref": "#/components/responses/Gateway429"
          },
          "503": {
            "$ref": "#/components/responses/Gateway503"
          },
          "529": {
            "$ref": "#/components/responses/Gateway529"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "Models this key may call now",
        "tags": [
          "Catalog"
        ]
      }
    },
    "/v1/responses": {
      "post": {
        "description": "Same request and response as OpenAI's POST /v1/responses (used by Codex). Send the full conversation in input; do not rely on previous_response_id.",
        "operationId": "createResponse",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "description": "Responses request.",
                "properties": {
                  "input": {
                    "description": "String or input items."
                  },
                  "instructions": {
                    "description": "System instructions.",
                    "type": "string"
                  },
                  "max_output_tokens": {
                    "description": "",
                    "type": "integer"
                  },
                  "model": {
                    "description": "Model id from the catalog.",
                    "type": "string"
                  },
                  "stream": {
                    "description": "Stream the answer as server-sent events.",
                    "type": "boolean"
                  },
                  "tools": {
                    "items": {
                      "type": "object"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "model",
                  "input"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Response object.",
                  "properties": {
                    "id": {
                      "description": "",
                      "type": "string"
                    },
                    "object": {
                      "description": "response",
                      "type": "string"
                    },
                    "output": {
                      "items": {
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "usage": {
                      "type": "object"
                    }
                  },
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "description": "Server-sent events in the protocol's own format.",
                  "type": "string"
                }
              }
            },
            "description": "Success."
          },
          "400": {
            "$ref": "#/components/responses/Gateway400"
          },
          "401": {
            "$ref": "#/components/responses/Gateway401"
          },
          "402": {
            "$ref": "#/components/responses/Gateway402"
          },
          "403": {
            "$ref": "#/components/responses/Gateway403"
          },
          "404": {
            "$ref": "#/components/responses/Gateway404"
          },
          "413": {
            "$ref": "#/components/responses/Gateway413"
          },
          "429": {
            "$ref": "#/components/responses/Gateway429"
          },
          "503": {
            "$ref": "#/components/responses/Gateway503"
          },
          "529": {
            "$ref": "#/components/responses/Gateway529"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyAuth": []
          }
        ],
        "summary": "OpenAI Responses",
        "tags": [
          "Inference"
        ]
      }
    }
  },
  "servers": [
    {
      "url": "https://quotax.sh"
    }
  ],
  "tags": [
    {
      "description": "Anthropic- and OpenAI-compatible model calls.",
      "name": "Inference"
    },
    {
      "description": "Models, prices, promotions and plans.",
      "name": "Catalog"
    },
    {
      "description": "Device-code key flow and key-authenticated account reads.",
      "name": "Agent"
    },
    {
      "description": "Remote MCP server.",
      "name": "MCP"
    }
  ]
}
