> 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=<model-id>
export ANTHROPIC_DEFAULT_OPUS_MODEL=<model-id>
export ANTHROPIC_DEFAULT_SONNET_MODEL=<model-id>
export ANTHROPIC_DEFAULT_HAIKU_MODEL=<model-id>   # 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": "<model-id>",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "<model-id>",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "<model-id>",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "<model-id>",
    "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-id>"
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": { "<model-id>": { "name": "<model 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 |
