---
title: Use the Claude API with Roo Code
description: "Use the Claude API with Roo Code: pick the Anthropic provider, enable the custom base URL router.apitoken.sale, paste your key and code at 50% off."
url: https://apitoken.sale/docs/learn/claude-api-roo-code
language: en
---

# Use the Claude API with Roo Code

The Claude API works in Roo Code through the extension's native Anthropic provider: tick the custom-base-URL box, point it at the apiToken.sale gateway, and paste one prepaid key. This guide walks the exact provider settings, per-mode model pinning across Roo's Code, Architect and Ask modes, and the four errors you will actually hit.

## Connect Roo Code to the gateway in one profile

Roo Code ships a native Anthropic provider with an optional custom base URL, so wiring it to the discounted gateway is three fields, not a plugin or a proxy. Set the provider to Anthropic, point the base URL at https://router.apitoken.sale, paste your sk-pool-••• key — and every task runs on Claude at a flat 50% off official token rates.

1. Open Roo Code → Settings → Providers and create a new API configuration profile; name it something like "apiToken" so you can tell it apart from a direct-Anthropic profile later.
2. Set API Provider to Anthropic, tick the "Use custom base URL" checkbox and enter https://router.apitoken.sale — exactly that, with no trailing path.
3. Paste your apiToken.sale key (sk-pool-•••) into the API Key field. The key is sent as x-api-key, the standard Anthropic Messages header.
4. Save the profile, choose claude-sonnet-5 as the model, and run a small task — ask Roo to explain a file — to confirm the round trip before you hand it a real refactor.

```
# Roo Code → Settings → Providers (profile "apiToken")
API Provider : Anthropic
[x] Use custom base URL
Base URL     : https://router.apitoken.sale
API Key      : sk-pool-•••
Model        : claude-sonnet-5
```

## Anthropic provider or OpenAI-compatible — stay on the Anthropic lane

Roo Code also offers an "OpenAI Compatible" provider, and the same key answers on both protocols: Anthropic Messages at https://router.apitoken.sale and an OpenAI-shaped lane at https://router.apitoken.sale/v1 with Authorization: Bearer. For Claude, keep the Anthropic provider. Roo Code's Claude-specific controls — the prompt-caching toggle, extended-thinking options and the tool-use plumbing its agent loop depends on — are built against the Messages API shape, and you lose them on the generic lane.

```
# Only for tools without an Anthropic option:
API Provider : OpenAI Compatible
Base URL     : https://router.apitoken.sale/v1
API Key      : sk-pool-•••
Model ID     : claude-sonnet-5   # typed by hand, no dropdown
```

> On the OpenAI-compatible lane Roo Code does not fetch a model list — the model ID is a free-text field. A typo there surfaces as "model not found", not as an auth error, which sends people chasing the wrong problem.

## Pin a different Claude model to each Roo mode

Roo Code's API configuration profiles are not just for credentials: you can bind a profile to each mode and switch models with the mode. That turns the model choice from a global compromise into a per-mode decision, which is how you keep an agentic loop fast without paying Opus prices for every file read.

| Roo Code mode | Model to pin | Why |
| --- | --- | --- |
| Ask | claude-haiku-4-5 | Q&A about code is short, read-only work; the cheapest Claude is usually enough. |
| Code | claude-sonnet-5 | The everyday driver for edits, test runs and tool loops — near-Opus coding quality at a mid-tier rate. |
| Architect | claude-opus-4-8 | Planning is where a wrong call costs the most downstream; spend the strong model here. |
| Debug | claude-sonnet-5 | Shares the Code profile; promote a stubborn bug to claude-opus-4-8 manually when the loop stalls. |

Every supported Claude generation sits behind the same key and the same prepaid balance — Opus 4.8 and 4.7, Sonnet 5 and 4.6, Haiku 4.5 — so a profile per model costs nothing to maintain and nothing extra to fund.

## What an agentic loop does to your token bill

Roo Code does not chat; it loops. One task reads files, drafts a plan, edits, runs the result and re-checks — each iteration a full model call carrying the system prompt, tool schemas and conversation so far. That is precisely the workload where a per-token discount matters most: the identical session, 50% cheaper, with token-level visibility in the apiToken.sale dashboard so you can see which mode is spending.

> Turn Roo Code's prompt-caching option on. Roo resends the same large prefix — its system prompt, your rules files, the repo context — on every call in a loop, and cached input is billed at the cheaper official cache rates minus your discount. On long sessions the cache line is usually the biggest single saver.

Two ways to sanity-check the spend before a big task: estimate the tokens with the cost calculator, and confirm the exact per-model rates on the catalog page.

[Estimate a Roo Code session in the Claude API cost calculator](/tools/claude-api-cost-calculator)

[Per-model rates for every supported Claude model](/models)

## Troubleshoot the errors Roo Code actually throws

- 401 Unauthorized — the key or the base URL is wrong. Re-paste the key and check the base URL is exactly https://router.apitoken.sale; a stray trailing slash or a /v1 suffix on the Anthropic lane breaks routing.
- Model not found — the model ID is stale or mistyped. Use a current ID such as claude-sonnet-5, claude-opus-4-8 or claude-haiku-4-5.
- 429 rate limit — Roo fires tool calls in bursts. Raise the "Rate limit" setting (minimum seconds between requests) in provider settings instead of hammering retry.
- Context window overflow — long sessions accumulate file reads faster than you expect. Start a fresh task per unit of work rather than stretching one thread, or let Roo condense the context when it offers.

> Checkpoints are worth enabling on agentic edits: Roo snapshots the workspace before changes, so a bad loop is a one-click revert instead of a git archaeology session.

## Reuse the same key in Cline, Cursor and the SDKs

The key is not married to Roo Code. One key covers Roo Code, Cline, Cursor and the Anthropic and OpenAI SDKs simultaneously, all drawing on the same prepaid balance — so you can trial a different agent without a second account or a second top-up.

If you come from Cline, nothing conceptual changes: both are VS Code agents with an Anthropic provider that accepts a custom base URL, and the setup differs only in where the settings live. Roo Code adds mode-based profiles and finer auto-approval controls; Cline is the leaner single-mode agent. Pick the agent on workflow, not on the key — it works in both.

## Frequently asked questions

### Does Roo Code support a custom Anthropic base URL?

Yes. The Anthropic provider in Roo Code's settings has a "Use custom base URL" checkbox; enable it, set the URL to https://router.apitoken.sale and authenticate with your apiToken.sale key.

### Which Claude models can Roo Code use on this key?

Every supported Claude model — Opus 4.8 and 4.7, Sonnet 5 and 4.6, Haiku 4.5 — on one key and one prepaid balance, so you can pin different models to different Roo Code modes.

### Can Roo Code use a different model per mode?

Yes. API configuration profiles can be bound per mode, so Ask can run claude-haiku-4-5, Code claude-sonnet-5 and Architect claude-opus-4-8 without touching settings between tasks.

### Does prompt caching still work through the gateway?

Yes. Keep Roo Code's prompt-caching option enabled; cached input is billed at the cheaper official cache rates minus your flat 50% discount, which compounds on long agentic loops.

### Is Roo Code setup different from Cline?

Barely. Both are VS Code agents whose Anthropic provider accepts a custom base URL, so the same key and the same URL work in either; use whichever agent's workflow you prefer.

---
Get a key: https://apitoken.sale/register
More guides: https://apitoken.sale/docs/learn
