Roo Code: setting up an OpenAI-compatible API in VS CodeAn API for AI coding agents: one key, any OpenAI-compatible tool

Published

Roo Code: setting up an OpenAI-compatible API in VS Code

The short version: in Roo Code settings pick OpenAI Compatible, paste your Base URL, API key, and Model ID — and assign separate profiles to Architect, Code, Debug, and Ask modes so routine edits do not burn flagship tokens.

Right on this page

Get a Base URL and API key for Roo Code

The block generates your real credentials ready to paste into Roo Code. You can send a test request right here before opening VS Code.

Press it and get your base_url and API key.

No sign-up, no card.

Free. Your key appears right here.

What Roo Code is and how it differs from Cline

Roo Code (formerly Roo Cline) is an autonomous VS Code coding agent forked from Cline. Like Cline, it reads your repository, proposes file edits, and runs terminal commands step by step.

The key difference is built-in multi-mode routing (Architect, Code, Debug, Ask, plus custom modes) where every mode can bind its own API Configuration Profile. Instead of paying for a heavy reasoning model on every small edit, you pair each mode with the right series.

Roo Code per-mode API profile routingRoo CodeVS Code ExtensionArchitectgrokread-only planCodeautoedits + shellDebugdeepseekroot-causeAskgptcodebase Q&AOpenAI Compatible/v1/chat/completions7 vendors · 1 key
Each Roo Code mode binds to its own provider profile: all traffic uses one Base URL and key while switching only the Model ID.

Step 1. Install Roo Code in VS Code

  1. Open VS Code and switch to Extensions (Ctrl+Shift+X, or Cmd+Shift+X on macOS).
  2. Search for Roo Code and install it.
  3. Click the kangaroo icon in the sidebar to open the Roo Code panel.

Step 2. Get your Base URL and API key

The button above issues a Base URL like https://twelver.app/api/ai/<config-id>/v1 and an API key starting with sk-…. You can manage balance and usage on the Twelver Coding API page. The key is shown once — copy it right away.

Step 3. Configure OpenAI Compatible in Roo Code

Open Roo Code Settings (gear icon) → Providers. Use the interactive builder below to pick the right profile for each mode and copy the exact fields:

Roo Code profile builder

Pick an API profile for each Roo Code mode

Roo Code lets you bind a separate API Configuration Profile to every mode. Pick a mode to see the recommended series, live rates, and exact provider fields.

Recommended series
auto(Qwen3.7-Plus)

Day-to-day file edits, new modules, and terminal commands. Balanced series with reliable native tool calling.

Rate (input / output)
$0.65 in · $2.6 out ($ per 1M)
Fields for Settings → Providers
Profile Name
twelver-code
API Provider
OpenAI Compatible
Base URL
API Key
Model ID
auto
Context Window
128000

Twelver rates as of 1 December 2026. Set Context Window manually under Model Configuration so Roo Code condenses history on time.

Roo Code fieldValue
API ProviderOpenAI Compatible
Base URL
API Key
Model IDseries name, e.g. auto for Code mode
Context Window (Model Configuration)set manually (e.g. 128000) so Roo Code condenses history before hitting limits
Field names follow the Roo Code documentation. Before credentials are issued, the table shows clickable placeholders.

Base URL must end with /v1

Roo Code appends /chat/completions automatically. Leave out any trailing slash and never append /chat/completions by hand, otherwise requests return 404. The Enable Prompt Caching toggle is for Gemini on Google Gemini or OpenRouter and should stay off for standard OpenAI-compatible endpoints.

Before starting a long coding session, you can verify your Base URL, key, and series with one terminal call:

Template — this will not work as ischeck-roo-api.shThe highlighted parts are stand-ins. The button above issues them in seconds, no sign-up.
curl -s https://twelver.ru/api/ai/<your-config-id>/v1/chat/completions \
  -H "Authorization: Bearer sk-<your-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [{"role": "user", "content": "Reply with one word: ok"}]
  }'

Need help with profiles

Ask the AI to configure Roo Code for you

Opens a prefilled chat where the setup assistant generates your base_url and key, lists the exact fields for Architect, Code, and Debug profiles, and estimates token cost.

Which series to pick for Roo Code modes

The Model ID field takes a series name that tracks the vendor's current release, so you do not have to edit configs after model updates. Because Roo Code relies strictly on native tool calling (no XML fallback), avoid ultra-light flash tiers in Code mode and start with auto.

SeriesModelInput / output ($ per 1M)Best mode
gptGPT-6 Luna0.163 / 0.813Ask mode and quick codebase Q&A at the lowest input rate
qwen-flashQwen3.8-Flash0.244 / 0.764Cheapest input, but weak on multi-file edits and tool calling
zai-flashGLM-5.3-Flash0.244 / 0.813Alternative to qwen-flash at the same rate
minimaxMiniMax M3.1 Flash0.244 / 0.975Small edits, long context
deepseek-flashDeepSeek V4.1 Flash0.488 / 1.95Cheap high-volume calls
auto / qwenQwen3.7-Plus0.65 / 2.6Code mode — day-to-day file edits and terminal commands
xiaomiMiMo V2.6 Pro0.707 / 1.41When "auto" falls short
gpt-terraGPT-6.1 Terra1.63 / 8.13Balanced GPT series for complex edits
deepseekDeepSeek V4 Pro2.15 / 6.44Debug mode — root-cause tracing; cheaper output than grok
zaiGLM-5.32.28 / 7.15Refactoring and long chains of edits
qwen-maxQwen4-Max2.44 / 7.31Hard tasks, up to 1M tokens of context
grokGrok 4.73.25 / 9.75Architect mode — system planning without touching files
gpt-solGPT-6.1 Sol3.25 / 16.25Higher accuracy in the GPT family
gpt-maxGPT-6 Astra16.25 / 81.25Sparingly, when nothing else solved it
Rates verified on 1 December 2026. Live pricing on /l/en/twelver-coding-api.

Vendors served and absent

Twelver API exposes 15 series across seven vendors: GPT, DeepSeek, Qwen, Grok, GLM, MiMo, MiniMax. It does not serve Claude or Gemini. Many Roo Code tutorials default to Claude; swap it for auto in Code mode or grok / deepseek in Architect and Debug.

What running Roo Code costs

Roo Code itself is free — you only pay for tokens used by the provider. In coding agents, input tokens make up most of the bill because every step resends system instructions, tool schemas, and open file context. Estimate your monthly spend below:

Work out what the requests cost

Pick a workload or type your own numbers — the calculator multiplies them by each series’ rates. A token is roughly 4 characters of English text or code.

gptGPT-6 Luna$17.6 per month
request: $0.00591,000 requests: $5.87
autoQwen3.7-Plus$67.86 per month
request: $0.0231,000 requests: $22.62
deepseekDeepSeek V4 Pro$217 per month
request: $0.0721,000 requests: $72.23
zaiGLM-5.3$231 per month
request: $0.0771,000 requests: $76.98
grokGrok 4.7$328 per month
request: $0.1091,000 requests: $109

Twelver rates as of 1 December 2026; tokens are billed as actually used, caching and discounts not included. The arithmetic runs in your browser.

Fixing common Roo Code errors

SymptomCauseFix
401 / UnauthorizedWrong or truncated API keyThe key is shown once — issue a new one in the widget above if lost
404 Not FoundExtra path segment in Base URL or wrong config-idMake sure Base URL ends with /v1 and has no trailing slash or /chat/completions
Model not foundUnknown series in Model IDCheck the series table above or query GET /v1/models
400 / session cuts off mid-taskContext Window left unset in Model ConfigurationSet Context Window manually (e.g. 128000) so Roo Code condenses history in time
Agent prints code in chat instead of editing filesModel struggles with native tool callingSwitch your Code profile to auto, zai, or deepseek

Other coding agents

If you prefer a single Plan/Act loop without per-mode profiles, see the Cline setup guide. If you want one shared config across VS Code, JetBrains, and CLI, read Kilo Code setup. For a pure terminal agent, see opencode setup. Browse the full book at API for AI Agents.

Frequently asked questions

How do I connect Roo Code to an OpenAI-compatible API?
Open Roo Code Settings (gear icon) → Providers, choose OpenAI Compatible, enter a Base URL ending in /v1, your API key, and a Model ID such as auto. Set Context Window manually under Model Configuration.
What Base URL should I enter in Roo Code?
Use https://twelver.app/api/ai/<config-id>/v1 with no trailing slash. Roo Code appends /chat/completions itself, so adding it manually causes a 404 error.
How is Roo Code different from Cline?
Roo Code (formerly Roo Cline) is a fork of Cline with built-in Architect, Code, Debug, Ask, and custom modes. Each mode can use its own API Configuration Profile, letting you reserve expensive reasoning models for planning.
Which models work best for each Roo Code mode?
Use auto (0.65 / 2.6 $ per 1M) for Code, grok for Architect, deepseek for Debug, and gpt for fast Ask queries.
Do I need Prompt Caching or manual Context Window?
Set Context Window manually (for example 128000) in Model Configuration so Roo Code knows when to condense history. Prompt Caching is intended for Gemini on Google/OpenRouter and is not needed here.
How much does Roo Code cost to run?
The extension is free; you only pay per token. Input rates start at $0.163 per 1M tokens (gpt), and the recommended auto series for Code mode is 0.65 / 2.6 $ per 1M (input / output).

Try it yourself

Everything in this guide runs inside Twelver

One chat for text, images, video, music and voice — no separate services or subscriptions.

Open Twelver chat
Rate your experience