Skip to main content
Coding agents repeatedly send instructions, conversation history, code, and tool results. Long sessions can therefore cost much more than a single chat request. The useful levers are model choice, context size, output length, and caching when the selected model supports it.

Start with your own usage

Open Usage in Console and group requests by model or API key. Compare similar tasks rather than relying on a generic hourly estimate. Record at least:
  • input, output, and cached tokens
  • cost per completed task
  • failed or repeated requests
  • the model and API key used

Match the model to the work

The most expensive model does not need to handle every step. Use the Models page for current prices and capabilities. Test candidate models on the same representative task before changing a production tool.

Keep context intentional

  • Include the files and logs needed for the current task, not the whole repository by default.
  • Start a new conversation when old history no longer helps.
  • Let the agent search for code instead of pasting large directories into every prompt.
  • Keep reusable instructions short and remove duplicated rules.

Limit unnecessary output

Set max_tokens when the client supports it and the task has a predictable answer length:
A limit prevents accidental long responses, but it should still leave enough room for the task to finish.

Use caching only when it is documented

Some models charge less for cached input. Check the model’s price details before counting on a cache discount, and confirm cached-token usage in the response or Usage. Cache behavior and prices differ by model.

Separate projects with API keys

Use a different API key for each project or coding tool when you need separate limits and usage history. A key-level limit can stop one tool from consuming the full account balance.

Compare changes with real tasks

  1. Choose a small set of tasks that represents your normal work.
  2. Run the same tasks with each candidate model and the same context.
  3. Compare completion quality, retries, total tokens, and final cost in Usage.
The lowest price per token is not always the lowest cost per completed task. A cheaper request that needs several retries may cost more.

Tool setup

Claude Code

Connect Claude Code with the Anthropic-compatible API.

Codex CLI

Configure the TokenLab base URL and API key.

Cursor

Review the supported BYOK boundary before setup.

OpenCode

Add TokenLab as a custom provider.