DEV Community

APIVAI
APIVAI

Posted on

Roo Code with Claude and GPT: OpenAI Compatible vs Anthropic, and one model per mode

Disclosure: I run APIVAI, the gateway used in the examples below. The setup is the same for any endpoint that speaks both the OpenAI and Anthropic formats.

Roo Code is an open-source coding agent for VS Code. It shares its roots with Cline but adds modes (Code, Architect, Ask, Debug) and configuration profiles. Used together, they let planning, coding and quick questions each run on a different model. This post covers the two provider types that work with a gateway, how to set up profiles per mode, and the common errors.

OpenAI Compatible or Anthropic?

OpenAI Compatible Anthropic
Base URL https://api.apivai.com/v1 https://api.apivai.com (no /v1)
Models Claude and GPT Claude only
Picking a model Type the model ID Choose from Roo Code's list
Best for Mixing Claude and GPT, newest model IDs Long Claude sessions, with prompt caching

The prompt caching part is worth a note. Roo Code's Anthropic provider adds cache_control markers to the system prompt and recent messages, so repeated context is billed at the cache-read price, which is much lower than the full input price. An agent resends a lot of context on every step, so if you only use Claude, the Anthropic provider is usually cheaper.

Step 1: Set up OpenAI Compatible

  1. Open the Roo Code panel in VS Code, click the gear icon and go to Providers.
  2. Set API Provider to OpenAI Compatible.
  3. Fill in the fields below and save.
Field Value
Base URL https://api.apivai.com/v1
API Key your key
Model claude-sonnet-4-6 (or any ID from GET /v1/models)
Max Output Tokens 8192 or more (at least 4096)

The base URL ends in /v1 exactly once; Roo Code appends /chat/completions itself. Leave Context Window, Image Support and Computer Use at their defaults unless you have a reason to change them. The Input/Output Price fields only change the cost estimate Roo Code shows; they don't affect billing.

Roo Code uses native tool calling only, so the model must support function calling. The main Claude and GPT models do.

To see which model IDs your key can use:

curl https://api.apivai.com/v1/models \
  -H "Authorization: Bearer your-key"
Enter fullscreen mode Exit fullscreen mode

Step 2: Add an Anthropic profile (recommended if you only use Claude)

  1. In Providers, click the + next to the profile selector and name the profile, for example "APIVAI Claude".
  2. Set API Provider to Anthropic.
  3. Paste your 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 here. Roo Code passes this address to the Anthropic SDK, which appends /v1/messages on its own, so https://api.apivai.com/v1 turns into /v1/v1/messages and returns 404.

Step 3: Give each mode its own profile

Roo Code remembers which profile you last used in each mode, and its mode settings let you assign a profile to a mode explicitly. All profiles can share the same key.

Which model for which job

Mode Model Why
Architect (planning) claude-opus-5-5 A wrong plan wastes everything after it
Code / Debug claude-sonnet-4-6 or claude-sonnet-5-5 The everyday default
Ask claude-haiku-4-5 or gpt-6-luna Just questions; cheap and fast is enough

If a task keeps going in circles on Sonnet, switch that task to Opus rather than making Opus your default. GPT models only work through an OpenAI Compatible profile.

Common errors

  • 401 / invalid key: the key is incomplete or deleted. With the Anthropic provider, also check that Use custom base URL is ticked, or Roo Code sends your key to Anthropic directly.
  • 402 / insufficient_quota: the key's budget is used up, or what's left is too little for one request to an expensive model (Opus, Sonnet 4.6 hit this first, so Architect on Opus is the usual place to see it). Add budget to the key or switch to a cheaper model. A key stops working with a little still on it; that remainder isn't lost, and deleting the key returns it to your account balance.
  • 404: almost always /v1. OpenAI Compatible needs https://api.apivai.com/v1 (one /v1, no /chat/completions); Anthropic needs https://api.apivai.com without /v1.
  • Model not found: use the exact ID, such as claude-sonnet-4-6, not the display name. Check it against GET /v1/models.
  • Tool-calling errors: switch to a model that supports function calling.
  • Empty or cut-off replies: thinking is on by default and uses output tokens. Raise Max Output Tokens to 8192 (at least 4096).
  • 429: the default limit is 60 requests per minute per key. Long tasks can hit it; wait a moment or split work across several keys.

What it costs

At the time of writing, most Claude models on APIVAI are 56–62% below Anthropic's list prices and GPT models up to 86% below OpenAI's; for example, Claude Sonnet 4.6 is $1.15 / $5.74 per million input / output tokens against the official $3 / $15. It's prepaid and billed per token, with no subscription. The full table is at https://apivai.com/pricing.

Questions are welcome in the comments.

Top comments (0)