Roo CodeIntegrationCoding agents

Roo Code Setup with Claude and GPT via a Custom API Key

(prices in the text follow the live price list)

Short answer

To use Roo Code with APIVAI, open Roo Code's settings, go to Providers, set API Provider to OpenAI Compatible, enter https://api.apivai.com/v1 as the Base URL, paste your APIVAI key into API Key and type a model ID such as claude-sonnet-4-6 or gpt-5.5. For Claude only, you can instead choose the Anthropic provider, tick Use custom base URL and enter https://api.apivai.com without /v1, because Roo Code's Anthropic client adds /v1/messages itself. As of 2026-10-07, Claude Sonnet 4.6 costs $1.04 / $5.22 per million input / output tokens through APIVAI, against the official $3.00 / $15.00. You pay per token from a prepaid balance, with no subscription.

What is Roo Code, and why use your own API key?

Roo Code is an open-source AI coding agent for VS Code. It works in modes, such as Code, Architect and Ask, reads and edits files in your project, and runs commands with your approval. Roo Code does not include a model: you connect an API provider, and every step of a task is a request billed by that provider.

APIVAI gives you one key for Claude and GPT models, billed per token below official list prices from a balance you top up yourself. The same key works in the OpenAI format and in the Anthropic format, so it fits both of Roo Code's relevant provider options, and you can give each Roo Code mode its own model without managing several accounts.

Which API Provider should you choose in Roo Code?

OpenAI CompatibleAnthropic
Base URLhttps://api.apivai.com/v1https://api.apivai.com (no /v1)
ModelsClaude and GPTClaude only
How you pick the modelType the model IDChoose from Roo Code's list
Best forMixing Claude and GPT, newest model IDsLong Claude sessions

Pick OpenAI Compatible if you want GPT models, or a Claude ID that Roo Code's built-in list does not show yet. Pick Anthropic if you only use Claude: Roo Code's Anthropic provider adds cache_control markers to the system prompt and recent messages, so repeated context can be read from cache at $0.10 per million tokens for Claude Sonnet 4.6 instead of the full input price. Cache writes cost $1.31 per million. With profiles (below) you can keep both and switch per mode.

How do you set up Roo Code with APIVAI step by step?

Step 1: Create an APIVAI key

  1. Sign up at apivai.com with your email.
  2. Top up from $10 by card, crypto, Alipay or WeChat Pay. There is no free trial or subscription.
  3. In the Dashboard, create a key and copy it. Give it a budget limit if you want a hard cap on what Roo Code can spend.

Step 2: Configure the OpenAI Compatible provider

  1. In VS Code, open the Roo Code panel, click the gear icon and open Providers.
  2. In API Provider, choose OpenAI Compatible.
  3. Fill in the fields below and save.
FieldValue
API ProviderOpenAI Compatible
Base URLhttps://api.apivai.com/v1
API KeyYour APIVAI key
Modelclaude-sonnet-4-6 (or any ID from GET /v1/models)
Max Output Tokens8192 or more (at least 4096)
Input Price / Output PriceOptional: $1.04 / $5.22 for Claude Sonnet 4.6

The Base URL ends in /v1 exactly once; Roo Code adds /chat/completions to it. The model settings also include Context Window, Image Support and Computer Use; leave them at their defaults unless you have a reason to change them. The price fields only change the cost estimate Roo Code displays; real charges are on the Dashboard.

Roo Code uses native tool calling only, so the model must support function calling. APIVAI passes tool calls through on /v1/chat/completions, and the Claude and GPT models recommended below support them.

Check which IDs your key can use:

curl https://api.apivai.com/v1/models \
  -H "Authorization: Bearer YOUR_APIVAI_KEY"

Models are added and retired over time, so copy IDs from this list or from the pricing page.

Step 3 (optional): Add an Anthropic profile for Claude

  1. In Providers, click the + button next to the profile selector and name the new profile, for example "APIVAI Claude".
  2. Set API Provider to Anthropic.
  3. Paste your APIVAI key into Anthropic API Key.
  4. Tick Use custom base URL and enter https://api.apivai.com.
  5. Choose a Claude model from the Model dropdown.

Do not add /v1: Roo Code passes this address to the Anthropic SDK, which appends /v1/messages itself, so https://api.apivai.com/v1 would become /v1/v1/messages and return 404. See the Claude API proxy page for the Anthropic format.

Step 4: Give each mode its own profile

Roo Code remembers which configuration profile you last used with each mode, and its mode settings let you assign a profile to a mode explicitly. A sensible split: a Claude Opus 5.5 profile for Architect (planning), Claude Sonnet 4.6 for Code, and a cheap Claude Haiku 4.5 or GPT-6 Luna profile for Ask. All profiles can use the same APIVAI key.

Which model should you choose in Roo Code?

Prices per 1M input / output tokens as of 2026-10-07:

Model IDPrice (in / out)Good mode for it
claude-sonnet-4-6$1.04 / $5.22Code, Debug: the everyday default
claude-sonnet-5-5$0.69 / $3.47Code: newer Sonnet
claude-opus-5-5$1.39 / $6.96Architect, hardest bugs
claude-haiku-4-5$0.35 / $1.74Ask, small edits
gpt-6-sol$0.30 / $1.52GPT alternative for Code or review
gpt-6-luna$0.0144 / $0.0768Very cheap questions

GPT models need the OpenAI Compatible provider. If a task keeps going in circles on Sonnet, switch that task's profile to Opus rather than making Opus your default.

How much does Roo Code cost with APIVAI?

Each step of a Roo Code task resends the conversation and the files read so far, so input tokens dominate. Two worked examples:

  • One Code-mode task on Claude Sonnet 4.6: about 25 requests of 35,000 input and 2,000 output tokens each. Cost: $1.17 with APIVAI, $3.38 at official prices.
  • A working month of three such tasks a day for 22 days (1,650 requests): $77.29 with APIVAI, $223 at official prices. Moving 20 Ask questions a day to Claude Haiku 4.5 (8,000 input, 800 output tokens each, 440 a month) adds only $1.84.

These figures ignore prompt caching, which lowers the cost of repeated context when you use the Anthropic provider. Thinking tokens count as output tokens. Your real numbers per request are on the Dashboard. For a broader comparison, read Claude API pricing in 2026.

How do you fix common Roo Code errors?

  • 401 / invalid API key: the key is incomplete, deleted or over its budget limit; check the Dashboard. On the Anthropic provider, make sure Use custom base URL is ticked, or the key goes to Anthropic directly.
  • 404 Not Found: wrong /v1. OpenAI Compatible: https://api.apivai.com/v1, no trailing /chat/completions. Anthropic: https://api.apivai.com, no /v1.
  • Model not found: use the exact ID, such as claude-sonnet-4-6, not a display name. Compare with GET /v1/models.
  • Tool-calling errors: pick a model that supports function calling, such as those in the table above.
  • Empty or truncated replies: thinking is on by default and uses output tokens. Set Max Output Tokens to 8192 (at least 4096).
  • 429 Too Many Requests: the default limit is 60 requests per minute per key. Wait briefly, or ask support to raise it.

More on request formats is in the docs and on the OpenAI-compatible API page.

FAQ

Can I use Claude and GPT in Roo Code with one key?

Yes. One APIVAI key works for every model. Create one profile per model, or change the Model field in an OpenAI Compatible profile.

Should I use the OpenAI Compatible or the Anthropic provider?

Use OpenAI Compatible for GPT models and for any model ID missing from Roo Code's list. Use Anthropic for Claude-only work, where Roo Code requests prompt caching; enter the base URL without /v1.

Can different modes use different models?

Yes. Roo Code ties configuration profiles to modes, so Architect can use Opus while Code uses Sonnet, all on the same key.

Does APIVAI store my code?

No. Request and response content is not logged; only usage data such as model, tokens and cost is kept for billing.

Does the same setup work in Cline?

Almost exactly. See the Cline setup guide; the field names and URLs are the same.

Create an account, top up from $10 and paste your key into Roo Code.

Ready to start?

Get your API key in 30 seconds. Pay as you go for Claude and GPT.