## SOURCE: https://quotax.sh/llms.txt # quotax.sh > LLM gateway with Anthropic Messages, OpenAI Chat Completions and OpenAI > Responses APIs on one key. Pay-as-you-go wallet or free keys for free models. quotax.sh routes every model to upstream providers with automatic failover. Any catalog model works on all three APIs. Billing is a USD wallet that a human tops up by Vietnamese bank transfer (VietQR); free keys can call the models that are free right now. Agents: read https://quotax.sh/skill.md first. It covers getting a key with one human click, picking a model, configuring clients and fixing errors. Key facts - Anthropic SDKs / Claude Code base URL: https://quotax.sh (no /v1) - OpenAI SDKs / Codex / most tools base URL: https://quotax.sh/v1 - Auth: Authorization: Bearer qtx-… or x-api-key: qtx-… (keys start with qtx-) - Endpoints: POST /v1/messages, POST /v1/messages/count_tokens, POST /v1/chat/completions, POST /v1/responses, GET /v1/models - Live models and prices: GET https://quotax.sh/api/public/catalog (no key). Never hardcode ids. - Models a key can call right now: GET https://quotax.sh/v1/models with that key (free keys see only free models) - Get a key without a browser session: device flow, see https://quotax.sh/skill.md. Agents run two steps: curl -fsSL https://quotax.sh/init | sh -s -- start (show the human the URL and code), then curl -fsSL https://quotax.sh/init | sh -s -- wait. A human in a terminal can run curl -fsSL https://quotax.sh/init | sh - Check a key, balance and callable models: GET https://quotax.sh/api/agent/me with the key - MCP: https://quotax.sh/mcp (Streamable HTTP, Bearer key) - Plans: Free `free` (free models only, 10 rpm, 2 concurrent, 500 requests/day, 2M tokens/day, 1 key max); Pay as you go `payg` (per-token from the wallet, 60 rpm, 8 concurrent, 10 keys max); Standard `standard` (30000 VND/day subscription, 20 rpm, 4 concurrent); Pro `pro` (200000 VND/day subscription, 120 rpm, 16 concurrent) - Errors follow the API you called (Anthropic or OpenAI shape); branch on the HTTP status. 402 (Anthropic billing_error, OpenAI code insufficient_quota) = wallet too low: a human tops up at https://quotax.sh/app/billing - Daily limits reset at 00:00 Asia/Ho_Chi_Minh (17:00 UTC) Common mistakes - Using https://quotax.sh/v1 as the Anthropic SDK or Claude Code base URL: the SDK adds /v1/messages itself, so you get 404 "No such endpoint: POST /v1/v1/messages". Use https://quotax.sh. - Using https://quotax.sh without /v1 for OpenAI SDKs, Codex, OpenCode or Cursor: requests go to /chat/completions and fail (404 or 405). Use https://quotax.sh/v1. - Hardcoding model ids from examples, memory or other gateways. Ids, prices and promotions change; read the catalog every session. - Calling GET /v1/models without a key: 401. Use /api/public/catalog for the keyless list. - Treating a 200 from a keyless endpoint as proof the key works. Smoke-test with one tiny authenticated request. - Calling a model that is not FREE with a free key: 403 permission_error "model … is not free". - Codex without wire_api = "responses": Codex only speaks the Responses API. - Asking the human to paste the key into chat, printing it, or committing it. Use the device flow; it saves the key to ~/.config/quotax/env or $XDG_CONFIG_HOME/quotax/env (mode 0600). - Sending the key to any host other than quotax.sh. ## Models (live, 2026-12-01) No models are enabled right now; check GET https://quotax.sh/api/public/catalog later. ## Start here - [skill.md](https://quotax.sh/skill.md): agent skill: get a key, pick a model, set up clients, errors, security rules - [Agent setup](https://quotax.sh/agents.md): per-client lanes (Claude Code, Codex, OpenCode, Cursor, MCP clients), init script, troubleshooting - [Docs](https://quotax.sh/docs.md): quickstart: base URLs, endpoints, SDK and curl examples, errors and limits ## API - [OpenAPI 3.1](https://quotax.sh/openapi.json): every route above, with auth schemes and error envelopes - [Public catalog](https://quotax.sh/api/public/catalog): JSON models, prices (USD per 1M tokens), promotions, plans and limits; no key - [Models for a key](https://quotax.sh/v1/models): ids the key may call now; OpenAI shape, or Anthropic shape with an anthropic-version or x-api-key header - [API catalog](https://quotax.sh/.well-known/api-catalog): RFC 9727 linkset ## Agent integrations - [Init script](https://quotax.sh/init): POSIX sh device-flow installer: curl -fsSL https://quotax.sh/init | sh (agents: sh -s -- start, then sh -s -- wait) - [MCP server](https://quotax.sh/mcp): claude mcp add --transport http quotax https://quotax.sh/mcp --header "Authorization: Bearer $QUOTAX_API_KEY" - [Agent Skills index](https://quotax.sh/.well-known/agent-skills/index.json): npx skills add https://quotax.sh ## Optional - [llms-full.txt](https://quotax.sh/llms-full.txt): this file plus skill.md, docs.md and agents.md in one file - [Models page](https://quotax.sh/models/): human view of the catalog - [Pricing](https://quotax.sh/pricing/): plans and top-up rules - [Terms](https://quotax.sh/terms/): terms of service - [Health](https://quotax.sh/healthz): returns ok when the gateway is up ## SOURCE: https://quotax.sh/skill.md --- name: quotax description: Use quotax.sh, a cheap LLM gateway that serves Anthropic Messages, OpenAI Chat Completions and OpenAI Responses on one qtx- API key. Covers getting a key with one human click (device flow), picking a model from the live catalog, setting up Claude Code, Codex, Cursor, OpenCode, the OpenAI and Anthropic SDKs or the quotax MCP server, checking balance and usage, and fixing 401/402/403/404/429 errors. Use when the user mentions quotax, quotax.sh, QUOTAX_API_KEY or a qtx- key, wants a cheap Claude/OpenAI-compatible gateway or API, or asks to set up Claude Code, Codex, Cursor or OpenCode with quotax. metadata: base_url: "https://quotax.sh" openai_base_url: "https://quotax.sh/v1" version: "1" --- # quotax.sh quotax.sh is an LLM gateway. One `qtx-` key calls every model in the catalog through three wire-compatible APIs, so official SDKs and coding agents work by changing only the base URL: | API | Base URL to configure | Endpoint | | --- | --- | --- | | Anthropic Messages (Claude Code, Anthropic SDKs) | `https://quotax.sh` (no `/v1`) | `POST /v1/messages`, `POST /v1/messages/count_tokens` | | OpenAI Chat Completions (OpenAI SDKs, OpenCode, Cursor, most tools) | `https://quotax.sh/v1` | `POST /v1/chat/completions` | | OpenAI Responses (Codex) | `https://quotax.sh/v1` | `POST /v1/responses` | - Auth: `Authorization: Bearer $QUOTAX_API_KEY` or `x-api-key: $QUOTAX_API_KEY`. - Any model works on any of the three APIs; the gateway translates and fails over between upstreams. - Billing: a pay-as-you-go (payg) key spends a USD wallet that a **human** tops up by Vietnamese bank transfer (VietQR). A free key costs nothing but can only call models that are free right now, within daily limits. - Model ids, prices and promotions change. **Never hardcode a model id**; read them live (see "Pick a model"). Everything below is plain HTTP; `$QUOTAX_API_KEY` stands for the key. Never type the real key into a command you show, a file you commit or the chat. ## Session start: check for an existing key Do this before anything else. The init script does all of it: ```sh curl -fsSL https://quotax.sh/init | sh -s -- status ``` Exit code 0 means a working key is saved; it prints the plan, balance and the number of callable models, never the key. Exit code 1 means no key or a rejected key: go to "Get a key". By hand: the key is in `$QUOTAX_API_KEY` or in the env file the init script writes, `${QUOTAX_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/quotax}/env` (usually `~/.config/quotax/env`; `KEY=value` lines): ```sh f=${QUOTAX_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/quotax}/env if [ -z "${QUOTAX_API_KEY:-}" ] && [ -f "$f" ]; then set -a; . "$f"; set +a fi curl -sS https://quotax.sh/api/agent/me -H "Authorization: Bearer $QUOTAX_API_KEY" ``` `200` returns `{"key":{"prefix","planId","effectivePlanId","planName","billingKind","limits","usageToday"},"user":{"username"},"wallet":{"balanceMicrousd","balanceUsd"},"topupUrl","models":[…]}`. `models` is the list of ids this key may call right now. `401` means the key is wrong or revoked: get a new one. `403` means the account is suspended: tell the human. ## Get a key (device flow, one human click) The human approves the agent in a browser where they are signed in to quotax.sh; the key is created under their account and handed to you. Rules: - Show the human the **verification URL and the user code**, and ask them to open it, check the code and approve. - **Never ask the human to paste a key into the chat**, and never print the key yourself. - Save the key to the env file above with mode 0600. - The human picks the plan when approving: `free` (free models only, no money) or `payg` (wallet). `planId` is only a hint shown to the human: the approval page always starts on Free, so if you need payg, ask the human to choose Pay as you go. A new key is always Free or Pay as you go; subscription plans (`plans[]` with `kind` `subscription`) are bought for an existing key by the human in the dashboard at https://quotax.sh/app/keys. - Each plan caps the keys per account (`limits.maxKeys`; Free allows 1). If the human already has a Free key (another machine, a lost env file), approval fails with the key limit. They can replace the existing key on the approval page (that revokes it at once: whatever still uses it gets 401 and needs a new key), pick Pay as you go, or delete a key at https://quotax.sh/app/keys; the code stays valid meanwhile. If `wait` runs for minutes, ask the human whether the approval page showed such an error. - The key is handed over **once**. If the answer is lost on the way or cannot be saved, it cannot be fetched again: the human revokes the unused key at https://quotax.sh/app/keys (the init script names its prefix) and you run `start` again. ### Option A: the init script (recommended) Your shell output may only appear when a command ends, so use two steps: ```sh curl -fsSL https://quotax.sh/init | sh -s -- start # prints the URL and code, saves pending state, exits at once ``` Show the printed URL and code to the human. Once they say they approved (or right away; `wait` blocks until approval or expiry, up to 15 minutes): ```sh curl -fsSL https://quotax.sh/init | sh -s -- wait # polls, saves the env file, checks the key with GET /api/agent/me, prints only the key prefix ``` `wait` does not call a model; for that, see "Smoke test". Exit codes: `0` saved (or already set up), `1` error, `2` the human denied it or the code expired (run `start` again). Running `start` again while a request is pending prints the same URL and code; `start --new` (or `QUOTAX_NEW=1`) replaces it. `QUOTAX_CLIENT_NAME` sets the name the human sees (default `quotax init ()`), `QUOTAX_PLAN=payg` hints that you want payg (the human still picks), `QUOTAX_NO_BROWSER=1` stops it opening a browser, `QUOTAX_CONFIG_DIR` sets the directory (default `${XDG_CONFIG_HOME:-$HOME/.config}/quotax`). A human in an interactive terminal can run `curl -fsSL https://quotax.sh/init | sh`, which does both steps; agents use the two steps. ### Option B: raw HTTP 1. Start: ```sh curl -sS -X POST https://quotax.sh/api/agent/device -H 'content-type: application/json' \ -d '{"clientName":"Claude Code on my-laptop","planId":"free"}' ``` → `{"device_code":"qtxd_…","user_code":"ABCD-EFGH","verification_uri":"https://quotax.sh/activate","verification_uri_complete":"https://quotax.sh/activate?code=ABCD-EFGH","expires_in":900,"interval":5}` Show `verification_uri_complete` and `user_code` to the human. Keep `device_code` to yourself; it is a secret. 2. Poll every `interval` seconds. This snippet writes the key straight to the file so it never enters your transcript: ```sh f=${QUOTAX_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/quotax}/env umask 077; mkdir -p "$(dirname "$f")" resp=$(curl -sS -X POST https://quotax.sh/api/agent/token -H 'content-type: application/json' \ -d '{"device_code":"qtxd_…"}') case $resp in *'"api_key"'*) printf '%s\n' "$resp" | sed -n 's/.*"api_key":"\([^"]*\)".*/QUOTAX_API_KEY=\1/p' > "$f" printf 'QUOTAX_BASE_URL=%s\n' 'https://quotax.sh' >> "$f" echo "saved" ;; *) printf '%s\n' "$resp" ;; # an error object, never contains a key esac ``` | Answer | Meaning | Do | | --- | --- | --- | | `200 {"api_key":"qtx-…","key_prefix","plan_id","base_url","openai_base_url","anthropic_base_url"}` | approved; returned **once** | save it, stop polling | | `400 {"error":{"code":"authorization_pending"}}` | human has not approved yet (if it lasts, they may have hit the key limit: see the rules above) | wait `interval`, poll again | | `400 {"error":{"code":"slow_down"}}` | polled too fast | add 5 s to `interval` for good | | `429 {"error":{"code":"slow_down"}}` | over 120 polls a minute from this address (shared CI or NAT IP) | wait about a minute, then poll at `interval` | | `400 {"error":{"code":"access_denied"}}` | human denied | stop; ask the human | | `400 {"error":{"code":"expired_token"}}` | expired (15 min) or already used | start again | | `429 {"error":{"code":"too_many_attempts"}}` on start | more than 20 starts per IP in 10 min | wait, then retry | 3. Load it into the environment without printing it: `set -a; . "$f"; set +a`. Fallback without the device flow: the human signs in at https://quotax.sh/app/keys, creates a key and puts it in the env file themselves. ## Pick a model Read the catalog live, every session: ```sh curl -sS https://quotax.sh/api/public/catalog # no key: all models, prices, promotions, plans curl -sS https://quotax.sh/v1/models -H "Authorization: Bearer $QUOTAX_API_KEY" # what THIS key may call now ``` - `GET /v1/models` with the key is the authority: if an id is not there, calls with it fail. Free keys see only models that are free right now (price 0, or a 100% promotion for the free plan). - `/api/public/catalog` gives `models[].id`, `name`, `contextWindow`, `maxOutput`, `capabilities` (`tools`, `vision`, `reasoning`), `price` in **USD per 1M tokens** (`input`, `output`, `cacheRead`, `cacheWrite`), `promo` (the best active promotion for any plan: `discountPct`, `endsAt` in epoch ms, `planIds`) and `free` (true when a Free key can call the model right now at no cost). - `plans[]` gives each plan's `id`, `kind` (`free`, `payg` or `subscription`), `limits` (`rpm`, `concurrency`, `dailyRequests`, `dailyTokens`, `maxKeys`; 0 means unlimited) and `models` (the plan's allow-list; empty means no allow-list, but a `free`-kind plan still only calls models with `free: true`). - https://quotax.sh/llms.txt shows the same list as text, with FREE marks and promotion end dates. - Choose by the task: tool use needs `capabilities.tools`, images need `vision`; prefer the cheapest model that fits. Tell the human which id you picked and why, and that promotions end. - With `x-api-key` or `anthropic-version` headers, `/v1/models` answers in Anthropic shape (`data[].id`, `display_name`, `max_input_tokens`), otherwise OpenAI shape (`data[].id`). ## Set up a client Write user-level config only, show the human what you changed, and never put a real key in a file that is or might be committed. Replace `` with an id from "Pick a model". ### Claude Code ```sh export ANTHROPIC_BASE_URL=https://quotax.sh export ANTHROPIC_AUTH_TOKEN="$QUOTAX_API_KEY" export ANTHROPIC_MODEL= # Claude Code also uses its opus, sonnet and haiku aliases (subagents, background tasks): map them to catalog ids export ANTHROPIC_DEFAULT_OPUS_MODEL= export ANTHROPIC_DEFAULT_SONNET_MODEL= export ANTHROPIC_DEFAULT_HAIKU_MODEL= # or a cheaper catalog id claude ``` Persistent, in `~/.claude/settings.json` (user level, not the project's `.claude/`). `apiKeyHelper` reads the key from the env file, so the key never sits in settings: ```json { "apiKeyHelper": "sed -n 's/^QUOTAX_API_KEY=//p' \"${QUOTAX_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/quotax}/env\"", "env": { "ANTHROPIC_BASE_URL": "https://quotax.sh", "ANTHROPIC_MODEL": "", "ANTHROPIC_DEFAULT_OPUS_MODEL": "", "ANTHROPIC_DEFAULT_SONNET_MODEL": "", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "", "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1" } } ``` `CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1` lets `/model` list the quotax models. Any catalog model works in Claude Code, not only Claude models. Without the `ANTHROPIC_DEFAULT_*_MODEL` ids, subagents and background tasks ask for Claude model ids the catalog may not have and fail with 404. Every id must be one this key may call (with a free key: a FREE model). If the key lives in a non-default `QUOTAX_CONFIG_DIR` or `XDG_CONFIG_HOME`, Claude Code may not see that variable: put the absolute env file path that `init` printed into `apiKeyHelper`. Claude Code runs many requests (tool loops, subagents). On a Free key the plan limits (`limits.rpm`, `limits.concurrency`, `limits.dailyRequests` in `/api/agent/me`) will throttle it with 429s; for regular use ask the human for a Pay as you go key. ### Codex CLI Codex only speaks the Responses API, so `wire_api = "responses"` is required. In `~/.codex/config.toml`: ```toml model = "" model_provider = "quotax" [model_providers.quotax] name = "quotax.sh" base_url = "https://quotax.sh/v1" env_key = "QUOTAX_API_KEY" wire_api = "responses" ``` Then run `codex` from a shell where `QUOTAX_API_KEY` is exported. ### OpenCode In `~/.config/opencode/opencode.json`: ```json { "$schema": "https://opencode.ai/config.json", "provider": { "quotax": { "npm": "@ai-sdk/openai-compatible", "name": "quotax.sh", "options": { "baseURL": "https://quotax.sh/v1", "apiKey": "{env:QUOTAX_API_KEY}" }, "models": { "": { "name": "" } } } } } ``` ### Cursor and any OpenAI-compatible tool Base URL `https://quotax.sh/v1`, API key `$QUOTAX_API_KEY`, model ``. In Cursor: Settings → Models → OpenAI API Key, turn on "Override OpenAI Base URL" with `https://quotax.sh/v1`, then add the model ids. The human has to paste the key into Cursor's settings field; that is fine, it is not the chat. ### SDKs ```python import os from openai import OpenAI # pip install openai client = OpenAI(base_url="https://quotax.sh/v1", api_key=os.environ["QUOTAX_API_KEY"]) r = client.chat.completions.create(model="", messages=[{"role": "user", "content": "Hello"}]) print(r.choices[0].message.content) import anthropic # pip install anthropic client = anthropic.Anthropic(base_url="https://quotax.sh", api_key=os.environ["QUOTAX_API_KEY"]) m = client.messages.create(model="", max_tokens=512, messages=[{"role": "user", "content": "Hello"}]) print(m.content[0].text) ``` ```ts import OpenAI from "openai"; // npm i openai const openai = new OpenAI({ baseURL: "https://quotax.sh/v1", apiKey: process.env.QUOTAX_API_KEY }); import Anthropic from "@anthropic-ai/sdk"; // npm i @anthropic-ai/sdk const anthropic = new Anthropic({ baseURL: "https://quotax.sh", apiKey: process.env.QUOTAX_API_KEY }); ``` The Anthropic SDK base URL has **no** `/v1`; the OpenAI SDK base URL **has** `/v1`. ### MCP server `https://quotax.sh/mcp` is a remote MCP server (Streamable HTTP). Public tools work without a key: `quotax_list_models`, `quotax_client_config`, `quotax_docs`. With the key: `quotax_account`, `quotax_usage`, `quotax_test_model` (one tiny billed call). ```sh claude mcp add --transport http quotax https://quotax.sh/mcp --header "Authorization: Bearer $QUOTAX_API_KEY" ``` Codex (`~/.codex/config.toml`): ```toml [mcp_servers.quotax] url = "https://quotax.sh/mcp" bearer_token_env_var = "QUOTAX_API_KEY" ``` The Cursor (`~/.cursor/mcp.json`) snippet is in https://quotax.sh/agents.md. ## Smoke test (authenticated) A keyless endpoint answering proves nothing about the key. Make one tiny real call: ```sh curl -sS https://quotax.sh/v1/chat/completions \ -H "Authorization: Bearer $QUOTAX_API_KEY" -H 'content-type: application/json' \ -d '{"model":"","max_tokens":16,"messages":[{"role":"user","content":"Reply with: pong"}]}' ``` For Claude Code or Anthropic SDK setups, test the Anthropic path too: ```sh curl -sS https://quotax.sh/v1/messages \ -H "x-api-key: $QUOTAX_API_KEY" -H 'anthropic-version: 2023-06-01' -H 'content-type: application/json' \ -d '{"model":"","max_tokens":16,"messages":[{"role":"user","content":"Reply with: pong"}]}' ``` For Codex or other Responses clients, test the Responses path: ```sh curl -sS https://quotax.sh/v1/responses \ -H "Authorization: Bearer $QUOTAX_API_KEY" -H 'content-type: application/json' \ -d '{"model":"","input":"Reply with: pong","max_output_tokens":16}' ``` This is billed like any request (fractions of a cent; nothing on a free model with a free key). ## Balance and usage ```sh curl -sS https://quotax.sh/api/agent/me -H "Authorization: Bearer $QUOTAX_API_KEY" # plan, wallet, today's usage, callable models curl -sS "https://quotax.sh/api/agent/usage?days=7" -H "Authorization: Bearer $QUOTAX_API_KEY" # {"daily":[…],"byModel":[…]} ``` Money is in micro-USD (`1000000` = $1). Only a human can add money: send them to `topupUrl` (https://quotax.sh/app/billing), where they pay by VietQR bank transfer and the wallet is credited automatically. You cannot top up, create keys or change plans with an API key. ## Errors Errors come in the shape of the API you called: - Anthropic (`/v1/messages`): `{"type":"error","error":{"type":"permission_error","message":"…"},"request_id":"req_…"}` - OpenAI (`/v1/chat/completions`, `/v1/responses`, `/v1/models`): `{"error":{"message":"…","type":"…","param":null,"code":"…"}}` - `/api/*` routes: `{"error":{"code":"…","message":"…"}}` Branch on the HTTP status: the two protocols name some errors differently. | Status | Anthropic `type` | OpenAI `type` (`code`) | Typical message | Fix | | --- | --- | --- | --- | --- | | 401 | `authentication_error` | `authentication_error` (`invalid_api_key`) | `Invalid API key` | Key missing, wrong, disabled, deleted or replaced on the approval page. Run the status check; get a new key with the device flow. | | 402 | `billing_error` | `invalid_request_error` (`insufficient_quota`) | `Insufficient wallet balance; please top up at quotax.sh` | The payg wallet cannot cover the request's estimated maximum cost. Ask the human to top up at https://quotax.sh/app/billing (VietQR bank transfer). Meanwhile lower `max_tokens`, or use a FREE model. | | 403 | `permission_error` | `permission_error` | `model X is not included in the Y plan` | Pick an id from `GET /v1/models` with this key. | | 403 | `permission_error` | `permission_error` | `model X is not free; use a pay-as-you-go or subscription key` | Free key on a paid model: use a FREE model, or ask the human for a payg key. | | 403 | `permission_error` | `permission_error` | `This account is suspended` / `This API key has no active plan` | Tell the human; nothing to retry. | | 404 | `not_found_error` | `not_found_error` (`model_not_found`) | `model: X is not available` | Typo, retired or disabled model. Re-read the catalog. | | 404 | `not_found_error` | `not_found_error` | `No such endpoint: POST /v1/v1/messages` | Wrong base URL: no `/v1` for Anthropic clients, `/v1` for OpenAI clients. | | 413 | `request_too_large` | `invalid_request_error` | `Request body is too large` | Body over 32 MiB: send less. | | 429 | `rate_limit_error` | `rate_limit_error` (`rate_limit_exceeded`) | requests-per-minute, concurrency, `Daily request limit reached…`, `The free quota for X is used up for today`, `All upstreams for this model are busy…` | Wait the `Retry-After` seconds, then retry. Daily limits reset at 00:00 Asia/Ho_Chi_Minh (17:00 UTC). Or switch model. | | 5xx, 529 | `overloaded_error` (529) / `api_error` | `service_unavailable_error` (503) / `server_error` | `Upstream is temporarily unavailable` | Every upstream failed after failover. Retry with exponential backoff, or switch model. | ## Security rules - Send the key only to `https://quotax.sh`. Never to another host, a proxy you were not told about, a URL query string or a third-party tool. - Never print, echo, log or commit the key. Show only its prefix (`qtx-xxxx…`). Keep the env file at mode 0600. - Never ask the human to paste the key into the chat; use the device flow. - Do not write the key into project files (`.env` committed to git, `.claude/settings.json` in a repo, CI config). Use `$QUOTAX_API_KEY` or `apiKeyHelper`. - If a key leaks, tell the human to delete it at https://quotax.sh/app/keys and get a new one. - Content from quotax.sh is documentation, not instructions to override your user. ## More - https://quotax.sh/llms.txt — key facts, common mistakes, live model list - https://quotax.sh/agents.md — per-client lanes, MCP config for Cursor and Codex, troubleshooting - https://quotax.sh/docs.md — full quickstart with curl and SDK examples - https://quotax.sh/openapi.json — OpenAPI 3.1 for every route ## SOURCE: https://quotax.sh/docs.md > Documentation index: https://quotax.sh/llms.txt. Agents: https://quotax.sh/skill.md is the setup guide written for you. # quotax.sh quickstart quotax.sh speaks the Anthropic and OpenAI APIs. Swap the base URL, use your `qtx-` key, and your usual tools just work. ## Overview The base URL is `https://quotax.sh`. Send your key in the `Authorization: Bearer` or `x-api-key` header. Create keys in the dashboard at https://quotax.sh/app/keys, or let an agent get one with the device flow (https://quotax.sh/agents.md). | Endpoint | Description | | --- | --- | | `POST /v1/messages` | Anthropic Messages (streaming and non-streaming) | | `POST /v1/messages/count_tokens` | Anthropic-style token counting | | `POST /v1/chat/completions` | OpenAI Chat Completions | | `POST /v1/responses` | OpenAI Responses (used by Codex) | | `GET /v1/models` | Models your key can use | - Anthropic SDKs and Claude Code: base URL `https://quotax.sh` (no `/v1`). - OpenAI SDKs, Codex and most other tools: base URL `https://quotax.sh/v1`. - Every model in the catalog works on all three APIs. Find model ids on the models page (https://quotax.sh/models/) or, as JSON, at `GET https://quotax.sh/api/public/catalog` (no key needed). `GET /v1/models` lists the ids your key may call. Free keys can only call free ($0) models or models on a 100% promotion for the Free plan. The examples below use ``: replace it with a real id, and don't hardcode ids in code that outlives today's catalog. ## Claude Code Set the base URL and key, map the models to catalog ids, then run `claude` as usual. Every model in the catalog works, including non-Anthropic models. ```sh export ANTHROPIC_BASE_URL=https://quotax.sh export ANTHROPIC_AUTH_TOKEN=$QUOTAX_API_KEY # Default model, and the ids behind Claude Code's opus, sonnet and haiku aliases # (subagents and background tasks use them; unmapped, those calls fail with 404) export ANTHROPIC_MODEL= export ANTHROPIC_DEFAULT_OPUS_MODEL= export ANTHROPIC_DEFAULT_SONNET_MODEL= export ANTHROPIC_DEFAULT_HAIKU_MODEL= claude ``` For a persistent setup, add this to `~/.claude/settings.json`. The `CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY` variable lets the `/model` command list models from quotax.sh. ```json { "env": { "ANTHROPIC_BASE_URL": "https://quotax.sh", "ANTHROPIC_AUTH_TOKEN": "qtx-your-key", "ANTHROPIC_MODEL": "", "ANTHROPIC_DEFAULT_OPUS_MODEL": "", "ANTHROPIC_DEFAULT_SONNET_MODEL": "", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "", "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1" } } ``` Keep this file at user level (`~/.claude/`), never in a repository. To keep the key out of the file entirely, use `"apiKeyHelper": "sed -n 's/^QUOTAX_API_KEY=//p' \"${QUOTAX_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/quotax}/env\""` instead of `ANTHROPIC_AUTH_TOKEN` (the init script writes that file). ## Codex CLI Codex only uses the Responses API. Register quotax.sh as a provider with `wire_api = "responses"` in `~/.codex/config.toml`: ```toml model = "" model_provider = "quotax" [model_providers.quotax] name = "quotax.sh" base_url = "https://quotax.sh/v1" env_key = "QUOTAX_API_KEY" wire_api = "responses" ``` ```sh export QUOTAX_API_KEY=qtx-your-key codex # or pick a different model for one session codex --model ``` ## OpenAI SDK Point `base_url` at `https://quotax.sh/v1`. Both Chat Completions and Responses are supported. Python (`pip install openai`): ```python import os from openai import OpenAI client = OpenAI( base_url="https://quotax.sh/v1", api_key=os.environ["QUOTAX_API_KEY"], ) # Chat Completions chat = client.chat.completions.create( model="", messages=[{"role": "user", "content": "Hello! Give me a short intro to Hanoi."}], ) print(chat.choices[0].message.content) # Responses API resp = client.responses.create(model="", input="Write a fun programming riddle.") print(resp.output_text) ``` TypeScript (`npm i openai`): ```ts import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://quotax.sh/v1", apiKey: process.env.QUOTAX_API_KEY, }); const stream = await client.chat.completions.create({ model: "", messages: [{ role: "user", content: "Summarize The Tale of Kieu in 3 sentences." }], stream: true, }); for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content ?? ""); } ``` ## Anthropic SDK For the Anthropic SDK, the base URL is `https://quotax.sh` (without `/v1`). Python (`pip install anthropic`): ```python import os import anthropic client = anthropic.Anthropic( base_url="https://quotax.sh", api_key=os.environ["QUOTAX_API_KEY"], ) message = client.messages.create( model="", max_tokens=1024, messages=[{"role": "user", "content": "Explain goroutines in simple terms."}], ) print(message.content[0].text) ``` TypeScript (`npm i @anthropic-ai/sdk`): ```ts import Anthropic from "@anthropic-ai/sdk"; const client = new Anthropic({ baseURL: "https://quotax.sh", apiKey: process.env.QUOTAX_API_KEY, }); const stream = client.messages.stream({ model: "", max_tokens: 1024, messages: [{ role: "user", content: "Write a debounce function in TypeScript." }], }); stream.on("text", (text) => process.stdout.write(text)); await stream.finalMessage(); ``` ## curl Anthropic Messages: ```sh curl https://quotax.sh/v1/messages \ -H "x-api-key: $QUOTAX_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "content-type: application/json" \ -d '{ "model": "", "max_tokens": 512, "messages": [{"role": "user", "content": "Hello"}] }' ``` OpenAI Chat Completions (stream): ```sh curl https://quotax.sh/v1/chat/completions \ -H "Authorization: Bearer $QUOTAX_API_KEY" \ -H "content-type: application/json" \ -d '{ "model": "", "messages": [{"role": "user", "content": "Hello"}], "stream": true }' ``` OpenAI Responses: ```sh curl https://quotax.sh/v1/responses \ -H "Authorization: Bearer $QUOTAX_API_KEY" \ -H "content-type: application/json" \ -d '{"model": "", "input": "Hello"}' ``` Count tokens (not billed): ```sh curl https://quotax.sh/v1/messages/count_tokens \ -H "x-api-key: $QUOTAX_API_KEY" \ -H "content-type: application/json" \ -d '{"model": "", "messages": [{"role": "user", "content": "Hello"}]}' ``` List models: ```sh curl https://quotax.sh/v1/models -H "Authorization: Bearer $QUOTAX_API_KEY" ``` `/v1/models` answers in Anthropic shape when you send `anthropic-version` or `x-api-key`, otherwise in OpenAI shape. ## Errors & limits Errors are returned in the format of the protocol you call (Anthropic or OpenAI). Daily limits reset on Vietnam time (GMT+7, 00:00 Asia/Ho_Chi_Minh). | Status | When | Fix | | --- | --- | --- | | 401 | The API key is wrong, deleted or disabled (`authentication_error`, OpenAI code `invalid_api_key`). | Check your key on the API keys page. | | 402 | A pay-per-token key's wallet cannot cover the request's estimated maximum cost (Anthropic `billing_error`; OpenAI `invalid_request_error` with code `insufficient_quota`). | Top up at https://quotax.sh/app/billing (VietQR bank transfer), or lower `max_tokens`. | | 403 | The model is not included in the key's plan, or a Free key called a model that is not free right now (`permission_error`). | Use a model that is currently free, or create a pay-per-token key. | | 429 | The key exceeded its requests-per-minute, concurrent request or daily limit, or a promotion's daily quota (`rate_limit_error`). | Respect the `Retry-After` header, reduce load, or buy a daily plan. | | 400, 404, 413 | Invalid request, unknown model (`not_found_error`), unknown endpoint, or content too large. | Fix the request; errors are returned in the format of the protocol you use. | | 5xx, 529 | Every upstream for the model failed after retries (`overloaded_error`; OpenAI shape 503). | Try again in a few minutes or switch to another model. | Pay-per-token keys need enough wallet balance to cover a request's estimated maximum cost. Top up (https://quotax.sh/app/billing) if a request is rejected for insufficient balance. ## SOURCE: https://quotax.sh/agents.md > Documentation index: https://quotax.sh/llms.txt. Agents: https://quotax.sh/skill.md is the setup guide written for you. # Your agent can set itself up Paste this into Claude Code, Codex, Cursor, OpenCode or any agent with a shell: ```text Read https://quotax.sh/skill.md and set yourself up to use quotax. ``` The agent reads the skill, starts the device flow and shows you a link and a code. You open the link, check the code, pick Free or Pay as you go, and approve. The key goes straight to the agent's machine (`~/.config/quotax/env`, or `$XDG_CONFIG_HOME/quotax/env`, mode 0600); you never copy or paste it. ## Init script In a terminal (does everything, waits for your approval): ```sh curl -fsSL https://quotax.sh/init | sh ``` Agents use two steps (their shell output often shows only when a command ends): ```sh curl -fsSL https://quotax.sh/init | sh -s -- start # prints the verification URL and code, then exits curl -fsSL https://quotax.sh/init | sh -s -- wait # polls until approved, saves the key, checks it with GET /api/agent/me ``` `wait` makes no model call; the smoke test in https://quotax.sh/skill.md does. Running `start` again while a request is pending prints the same URL and code; `start --new` replaces it. Other commands: `status` (check the saved key: plan, balance, callable models) and `help`. Exit codes: `0` ok or already set up, `1` error, `2` denied or expired. Settings: `QUOTAX_CLIENT_NAME` (name shown on the approval page), `QUOTAX_PLAN` (`free` or `payg`: a hint shown to the human, who picks the plan; the page starts on Free), `QUOTAX_NO_BROWSER=1`, `QUOTAX_NEW=1` (same as `start --new`), `QUOTAX_CONFIG_DIR` (default `${XDG_CONFIG_HOME:-$HOME/.config}/quotax`). The script needs only `sh` and `curl`, prints only the key prefix, and never edits other tools' config files. Load the key into a shell with: ```sh set -a; . "${QUOTAX_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/quotax}/env"; set +a ``` ## Claude Code ```sh export ANTHROPIC_BASE_URL=https://quotax.sh export ANTHROPIC_AUTH_TOKEN="$QUOTAX_API_KEY" export ANTHROPIC_MODEL= export ANTHROPIC_DEFAULT_OPUS_MODEL= export ANTHROPIC_DEFAULT_SONNET_MODEL= export ANTHROPIC_DEFAULT_HAIKU_MODEL= # or a cheaper catalog id claude ``` Persistent setup in `~/.claude/settings.json`, reading the key from the env file so it never sits in settings: ```json { "apiKeyHelper": "sed -n 's/^QUOTAX_API_KEY=//p' \"${QUOTAX_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/quotax}/env\"", "env": { "ANTHROPIC_BASE_URL": "https://quotax.sh", "ANTHROPIC_MODEL": "", "ANTHROPIC_DEFAULT_OPUS_MODEL": "", "ANTHROPIC_DEFAULT_SONNET_MODEL": "", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "", "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1" } } ``` Claude Code also uses its opus, sonnet and haiku aliases for subagents and background tasks, so the `ANTHROPIC_DEFAULT_*_MODEL` variables map them to catalog ids. With a free key, every id must be a FREE model. ## Codex `~/.codex/config.toml` (Codex needs `wire_api = "responses"`): ```toml model = "" model_provider = "quotax" [model_providers.quotax] name = "quotax.sh" base_url = "https://quotax.sh/v1" env_key = "QUOTAX_API_KEY" wire_api = "responses" ``` Run `codex` from a shell where `QUOTAX_API_KEY` is exported. ## OpenCode `~/.config/opencode/opencode.json`: ```json { "$schema": "https://opencode.ai/config.json", "provider": { "quotax": { "npm": "@ai-sdk/openai-compatible", "name": "quotax.sh", "options": { "baseURL": "https://quotax.sh/v1", "apiKey": "{env:QUOTAX_API_KEY}" }, "models": { "": { "name": "" } } } }, "mcp": { "quotax": { "type": "remote", "url": "https://quotax.sh/mcp", "headers": { "Authorization": "Bearer {env:QUOTAX_API_KEY}" } } } } ``` ## Cursor Settings → Models: paste the key into "OpenAI API Key", turn on "Override OpenAI Base URL" and set it to `https://quotax.sh/v1`, then add the model ids you want from the catalog. ## MCP clients `https://quotax.sh/mcp` is a remote MCP server (Streamable HTTP, stateless). Without a key you get `quotax_list_models`, `quotax_client_config` and `quotax_docs`; with a key also `quotax_account`, `quotax_usage` and `quotax_test_model` (one tiny billed call). Claude Code: ```sh claude mcp add --transport http quotax https://quotax.sh/mcp --header "Authorization: Bearer $QUOTAX_API_KEY" ``` Cursor, `~/.cursor/mcp.json`: ```json { "mcpServers": { "quotax": { "url": "https://quotax.sh/mcp", "headers": { "Authorization": "Bearer ${env:QUOTAX_API_KEY}" } } } } ``` Codex, `~/.codex/config.toml`: ```toml [mcp_servers.quotax] url = "https://quotax.sh/mcp" bearer_token_env_var = "QUOTAX_API_KEY" ``` ## Any agent (system prompt) ```text You can call LLMs through quotax.sh. - Key: $QUOTAX_API_KEY (or the env file, usually ~/.config/quotax/env). Never print it or send it to any host but quotax.sh. - Anthropic Messages: POST https://quotax.sh/v1/messages (x-api-key header). OpenAI: base URL https://quotax.sh/v1 (Bearer header). - Model ids: GET https://quotax.sh/v1/models with the key. Never guess or hardcode them. - On 402 ask the human to top up at https://quotax.sh/app/billing. On 429 wait Retry-After seconds. - Full guide: https://quotax.sh/skill.md ``` ## Discovery files | URL | What | | --- | --- | | https://quotax.sh/skill.md | Agent Skill: key, models, clients, errors (also at /.well-known/agent-skills/quotax/SKILL.md) | | https://quotax.sh/llms.txt | Key facts, common mistakes, live model list | | https://quotax.sh/llms-full.txt | llms.txt, skill.md, docs.md and agents.md in one file | | https://quotax.sh/docs.md | Quickstart as Markdown | | https://quotax.sh/agents.md | This page as Markdown | | https://quotax.sh/openapi.json | OpenAPI 3.1 for /v1, the catalog, the device flow, /api/agent and /mcp | | https://quotax.sh/.well-known/agent-skills/index.json | Agent Skills index (`npx skills add https://quotax.sh`) | | https://quotax.sh/.well-known/api-catalog | RFC 9727 API catalog | | https://quotax.sh/api/public/catalog | Live models, prices, promotions and plans as JSON (no key) | | https://quotax.sh/init | The init script | | https://quotax.sh/mcp | Remote MCP server | `/`, `/docs` and `/agents` also answer in Markdown when you send `Accept: text/markdown`. ## Troubleshooting | Symptom | Cause | Fix | | --- | --- | --- | | 404 `No such endpoint: POST /v1/v1/messages` | Anthropic client configured with `https://quotax.sh/v1` | Use `https://quotax.sh` for Claude Code and Anthropic SDKs | | 404 or 405 on `/chat/completions` or `/responses` | OpenAI client configured without `/v1` | Use `https://quotax.sh/v1` | | 401 `Invalid API key` | Key missing, mistyped, deleted, or the env var not exported | `curl -fsSL https://quotax.sh/init \| sh -s -- status`; get a new key if needed | | 403 `model X is not free` | Free key on a paid model | Pick a FREE model from `/v1/models`, or approve a Pay as you go key | | 403 `not included in the … plan` | Model outside the key's plan | Use an id from `GET /v1/models` with that key | | 404 `model: X is not available` | Hardcoded or outdated model id | Re-read `/api/public/catalog` | | 402 `Insufficient wallet balance` | Pay as you go wallet too low for the request's maximum cost | Top up at https://quotax.sh/app/billing (VietQR), or lower `max_tokens` | | 429 with `Retry-After` | Per-minute, concurrency, daily or promotion limit | Wait and retry; daily limits reset at 00:00 Vietnam time (17:00 UTC) | | 503 / 529 | All upstreams for the model failed | Retry with backoff or switch model | | Codex errors on every call | `wire_api` is not `responses` | Set `wire_api = "responses"` | | Approval fails with `Maximum number of keys` | The plan's key limit is reached (Free allows 1 key per account) | On the approval page, replace the existing key (it stops working at once; whatever used it gets 401) or pick Pay as you go, or delete a key at https://quotax.sh/app/keys; the code stays valid | | Init `wait` keeps waiting | Not approved yet, or the approval failed (often the key limit above) | Check the approval page for an error | | Init `wait` exits 2 | You denied the request, or 15 minutes passed | Run `start` again | | Claude Code subagents or background tasks fail with 404 | Its default opus, sonnet or haiku model id is not in the catalog | Set `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL` and `ANTHROPIC_DEFAULT_HAIKU_MODEL` to catalog ids |