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.
Step 1. Install Roo Code in VS Code
- Open VS Code and switch to Extensions (
Ctrl+Shift+X, orCmd+Shift+Xon macOS). - Search for Roo Code and install it.
- 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.
Day-to-day file edits, new modules, and terminal commands. Balanced series with reliable native tool calling.
- 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 field | Value |
|---|---|
| API Provider | OpenAI Compatible |
| Base URL | |
| API Key | |
| Model ID | series name, e.g. auto for Code mode |
| Context Window (Model Configuration) | set manually (e.g. 128000) so Roo Code condenses history before hitting limits |
Base URL must end with /v1
/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:
check-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.
| Series | Model | Input / output ($ per 1M) | Best mode |
|---|---|---|---|
| gpt | GPT-6 Luna | 0.163 / 0.813 | Ask mode and quick codebase Q&A at the lowest input rate |
| qwen-flash | Qwen3.8-Flash | 0.244 / 0.764 | Cheapest input, but weak on multi-file edits and tool calling |
| zai-flash | GLM-5.3-Flash | 0.244 / 0.813 | Alternative to qwen-flash at the same rate |
| minimax | MiniMax M3.1 Flash | 0.244 / 0.975 | Small edits, long context |
| deepseek-flash | DeepSeek V4.1 Flash | 0.488 / 1.95 | Cheap high-volume calls |
| auto / qwen | Qwen3.7-Plus | 0.65 / 2.6 | Code mode — day-to-day file edits and terminal commands |
| xiaomi | MiMo V2.6 Pro | 0.707 / 1.41 | When "auto" falls short |
| gpt-terra | GPT-6.1 Terra | 1.63 / 8.13 | Balanced GPT series for complex edits |
| deepseek | DeepSeek V4 Pro | 2.15 / 6.44 | Debug mode — root-cause tracing; cheaper output than grok |
| zai | GLM-5.3 | 2.28 / 7.15 | Refactoring and long chains of edits |
| qwen-max | Qwen4-Max | 2.44 / 7.31 | Hard tasks, up to 1M tokens of context |
| grok | Grok 4.7 | 3.25 / 9.75 | Architect mode — system planning without touching files |
| gpt-sol | GPT-6.1 Sol | 3.25 / 16.25 | Higher accuracy in the GPT family |
| gpt-max | GPT-6 Astra | 16.25 / 81.25 | Sparingly, when nothing else solved it |
Vendors served and absent
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 monthautoQwen3.7-Plus$67.86 per monthdeepseekDeepSeek V4 Pro$217 per monthzaiGLM-5.3$231 per monthgrokGrok 4.7$328 per monthTwelver 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
| Symptom | Cause | Fix |
|---|---|---|
| 401 / Unauthorized | Wrong or truncated API key | The key is shown once — issue a new one in the widget above if lost |
| 404 Not Found | Extra path segment in Base URL or wrong config-id | Make sure Base URL ends with /v1 and has no trailing slash or /chat/completions |
| Model not found | Unknown series in Model ID | Check the series table above or query GET /v1/models |
| 400 / session cuts off mid-task | Context Window left unset in Model Configuration | Set Context Window manually (e.g. 128000) so Roo Code condenses history in time |
| Agent prints code in chat instead of editing files | Model struggles with native tool calling | Switch 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?
/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?
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?
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?
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?
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?
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