Guide

Use tokenflow in your coding agent

Claude Code and Codex both run on tokenflow without a proxy or plugin. Below is the exact setup we run against api.tokenflow.dev, including the settings that keep long sessions inside the model’s context.

Verified 6 October 2026 with Claude Code 2.1.291 and Codex CLI 0.160.1.

Your key

Export the API key we sent with your invitation in your shell profile. Both setups below read it from this variable.

~/.zshrc
export TOKENFLOW_API_KEY="tfk_…"

Claude Code

Claude Code speaks the Anthropic Messages API, which tokenflow serves natively. Add a shell function so your normal claude keeps talking to Anthropic and claude-tf talks to tokenflow.

1. Add a launcher

~/.zshrc
claude-tf() {
  ANTHROPIC_BASE_URL=https://api.tokenflow.dev \
  ANTHROPIC_AUTH_TOKEN="$TOKENFLOW_API_KEY" \
  ANTHROPIC_MODEL=qwen3.8-27b \
  ANTHROPIC_DEFAULT_OPUS_MODEL=qwen3.8-27b \
  ANTHROPIC_DEFAULT_SONNET_MODEL=qwen3.8-27b \
  ANTHROPIC_DEFAULT_HAIKU_MODEL=qwen3.8-27b \
  CLAUDE_CODE_SUBAGENT_MODEL=qwen3.8-27b \
  CLAUDE_CODE_MAX_CONTEXT_TOKENS=131072 \
  CLAUDE_CODE_AUTO_COMPACT_WINDOW=120000 \
  CLAUDE_CODE_DISABLE_THINKING=1 \
  CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
  claude "$@"
}

2. Cap the effort level

Add this to ~/.claude/settings.json. It only applies when the model is qwen3.8-27b, so your Claude sessions are unaffected.

~/.claude/settings.json
{
  "modelSettings": {
    "qwen3.8-27b": { "effortLevel": "medium", "maxEffortLevel": "medium" }
  }
}

3. Run it

terminal
claude-tf

Why these settings

  • Every model tier maps to one model. Claude Code sends background requests (titles, summaries, subagents) to its Haiku, Sonnet and Opus tiers. Pointing all of them at qwen3.8-27b keeps every request on tokenflow.
  • Context and compaction. The model has a 131,072-token context. Compacting at 120,000 leaves room for the reply, so long sessions don’t fail at the limit.
  • Effort capped at medium. Qwen3.8 accepts low, medium and xhigh, not high. Claude Code’s helper requests ignore --effort and default to high for models it doesn’t know; only maxEffortLevel clamps them. Passing your own --settings file replaces this cap.
  • Thinking off. Faster turns for agent work. This is the only thinking setting we test.
  • Claude Code may log unrecognized_model for qwen3.8-27b. It’s informational.

Codex

Codex uses the OpenAI Responses API, which tokenflow also serves. Put tokenflow in its own profile file so your default Codex setup stays as it is.

1. Create a profile

~/.codex/tokenflow.config.toml
model = "qwen3.8-27b"
model_provider = "tokenflow"
model_reasoning_effort = "none"
model_context_window = 131072
model_auto_compact_token_limit = 95000

[model_providers.tokenflow]
name = "tokenflow"
base_url = "https://api.tokenflow.dev/v1"
wire_api = "responses"
env_key = "TOKENFLOW_API_KEY"

2. Run it

terminal
codex --profile tokenflow

# non-interactive, e.g. in a script or CI job
codex exec --profile tokenflow "fix the failing test" </dev/null

Why these settings

  • Profile file, not a table. Codex 0.160 reads profiles from ~/.codex/<name>.config.toml and rejects the older [profiles.<name>] table in config.toml.
  • Context window set explicitly. Codex has no metadata for qwen3.8-27b and would otherwise assume a much larger window. Compacting at 95,000 keeps sessions well inside 131,072.
  • Reasoning effort none. Faster turns. Set "medium" to turn reasoning on.
  • </dev/null in scripts. Without a terminal, codex exec waits on standard input; closing it lets the run start.
  • The warning Model metadata for qwen3.8-27b not found is expected; the settings above supply what it needs.

Other tools

Any tool that lets you set an OpenAI- or Anthropic-compatible endpoint can use tokenflow. These are the three values to enter:

Base URLhttps://api.tokenflow.dev/v1 for OpenAI clients, https://api.tokenflow.dev for Anthropic clients
API keyYour tokenflow key, sent as Authorization: Bearer or x-api-key
Modelqwen3.8-27b, with a 131,072-token context

We’ve only listed the agents we test end to end. If you run tokenflow in another one, tell us at support@tokenflow.dev and we’ll add it.