Tokun

Use Tokun with Aider

Use Tokun as the model backend for Aider via its OpenAI-compatible provider — the same Aider workflow, billed at Tokun pricing with Tokun's model routing.

What this connects

Use Tokun as the model backend for Aider via its OpenAI-compatible provider — the same Aider workflow, billed at Tokun pricing with Tokun's model routing.

Before you start

  • A Tokun API key (starts with sk-) from the console.
  • A funded Tokun balance.
  • Aider installed, e.g. pip install aider-chat.
  • A chosen model id, e.g. openai/gpt-5.5.

Recommended quickstart

Aider reads its OpenAI-compatible provider from environment variables — set two and pass the model with Aider's openai/ prefix:

bash
export OPENAI_API_BASE="https://api.tokun.sh/v1"
export OPENAI_API_KEY="sk-..."      # your Tokun key
aider --model openai/gpt-5.5

Copy for AI agent

Working inside an AI coding agent? The shortest path is one line — paste this and your agent reads the full machine-readable guide at /llms.txt and does the Aider setup itself. You only supply your key:

text
Read https://tokun.sh/llms.txt and integrate Tokun into this project.
Want a fully-specified, deterministic block instead (exact steps, idempotent, fail-closed)? Paste the one below — it configures Aider specifically.
text
You are configuring Aider to use Tokun (OpenAI-compatible).

Tokun values:
- API key placeholder: TOKUN_API_KEY_HERE  (a Tokun key starts with sk-)
- Base URL: https://api.tokun.sh/v1
- Recommended model: openai/gpt-5.5

Apply via EITHER environment variables OR ~/.aider.conf.yml — the key names differ between the two:
- env vars:  OPENAI_API_BASE = https://api.tokun.sh/v1   and   OPENAI_API_KEY = <the user's Tokun sk- key>
- ~/.aider.conf.yml:  openai-api-base: https://api.tokun.sh/v1   and   openai-api-key: <the user's Tokun sk- key>
Then run: aider --model openai/gpt-5.5
Never print, log, or commit the full key.

Note: Aider/litellm reads "openai/<name>" as "OpenAI provider, model <name>", so "openai/gpt-5.5" sends the bare model name to Tokun, which normalizes it. If you are configuring the running shell, the env applies to NEW processes — start a fresh aider. If you cannot safely edit the profile, OUTPUT the export lines for the user.

Manual configuration

Prefer a config file? Set openai-api-base + openai-api-key in ~/.aider.conf.yml, or keep the env vars above. To roll back, unset them.

Model naming

Pass the model with Aider's openai/ prefix, e.g. openai/gpt-5.5 or openai/gpt-5.4-mini — litellm strips the prefix and Tokun normalizes the bare id. For an Anthropic model via the same surface, use openai/claude-opus-4-8. Unknown ids return an error rather than a substituted model.

Verify & troubleshoot

The OpenAI base URL keeps /v1 (https://api.tokun.sh/v1), and the openai/ in the model name is Aider/litellm's PROVIDER selector, not part of the Tokun model id — Tokun receives (and normalizes) the bare name.
SymptomLikely causeFix
401 / auth errorWrong or missing keyConfirm OPENAI_API_KEY is your Tokun sk- key.
402 / payment requiredEmpty Tokun balanceTop up in the console.
Unknown model errorWrong model nameUse openai/<tokun-model>, e.g. openai/gpt-5.5.