Use Tokun with Aider

Connect Aider to Tokun using your API key and a supported model.

Overview

Aider connects to Tokun through its OpenAI-compatible provider. Your Aider workflow stays the same, and requests use Tokun's pricing and model routing.

Before you start

  • A Tokun API key (starts with sk-) from the API keys page.
  • A funded Tokun balance.
  • Aider, installed (for example, with pip install aider-chat).
  • A model ID, such as openai/gpt-5.5.

Quickstart

Aider reads its OpenAI-compatible provider from environment variables. Set these two, then 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

Set up with an AI assistant

Paste this prompt into your AI coding agent. It reads the setup guide at /llms.txt and sets up Aider for you. You only need to provide your API key.

text
Read https://tokun.sh/llms.txt and integrate Tokun into this project.
Prefer exact, step-by-step instructions? Paste this detailed prompt instead. It sets up 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.

Set up manually

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

Model IDs

Pass the model with Aider's openai/ prefix, such as openai/gpt-5.5 or openai/gpt-5.4-mini. litellm strips the prefix, and Tokun normalizes the bare ID. For an Anthropic model through the same API, use openai/claude-opus-4-8. An unknown ID returns an error and is never swapped for a different model.

Official model pools

Official model pools appear in the model catalog and use a pool ID such as flash-pool. Choose an available pool from the live catalog; pool names and members are configured by Tokun administrators.

When the pool enables member selection, use pool-id/member-name, replacing the model's lab prefix with the pool ID. The selected member is the only model that can execute; the pool's pricing mode still applies. When selection is disabled, this form returns 400.

  • Fixed token pricing uses the pool's input, output, cache and context-tier rates for every member, including a member you select yourself.
  • Actual model pricing uses the serving member's price, frozen before the request. A retry to another member uses that member's frozen price.
  • Fixed per-request pricing charges once after an upstream success response begins. Missing usage, a partial response or a client disconnect after that point still counts once. Failures before success and unsuccessful retries do not add charges.

Use a pool that lists the API format this client sends. Model pool settings in the live catalog control which members are shown and whether member selection is available.

Troubleshooting

The OpenAI base URL keeps /v1 (https://api.tokun.sh/v1). The openai/ in the model name is Aider and 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 on the Billing page.
Unknown model errorWrong model nameUse openai/<tokun-model>, such as openai/gpt-5.5.