Roo Code Base URL Configuration

How to Configure the Base URL in Roo Code for Custom API Endpoints

Configuring a custom base URL in Roo Code allows you to route AI requests through relay services, self-hosted model servers, or alternative API providers. This is essential for developers who need centralized API management, access from restricted regions, or integration with enterprise API gateways. This guide provides step-by-step instructions for configuring the base URL with various providers.

What Is the Base URL?

The base URL is the root endpoint that Roo Code sends API requests to. By default, each provider has its own base URL (e.g., https://api.openai.com/v1 for OpenAI). When you set a custom base URL, all requests are redirected to your specified endpoint instead. This endpoint must implement the same API format that Roo Code expects for the selected provider type.

Step-by-Step Configuration

  1. Click the Roo Code icon in the VS Code sidebar to open the panel.
  2. Click the settings icon (gear) at the top of the Roo Code panel.
  3. Select "OpenAI Compatible" from the API Provider dropdown. This is the most flexible option for custom base URLs.
  4. Enter your custom base URL in the Base URL field.
  5. Enter your API key in the API Key field.
  6. Enter the model identifier in the Model ID field.
  7. Click outside the fields to save. Configuration takes effect immediately.
// Example: Using claude4u.com relay service
Provider: OpenAI Compatible
Base URL: https://claude4u.com/v1
API Key:  cr_your-relay-api-key
Model ID: claude-sonnet-4-20250514
The Base URL should end with /v1 and should NOT include /chat/completions or any other endpoint path. Roo Code appends the appropriate endpoint path automatically based on the request type. Including the full path will result in a malformed URL.

Configuration for Popular Services

API Relay Service (claude4u.com)

A relay service provides unified access to multiple AI models through a single endpoint. This is the recommended setup for most developers:

Base URL: https://claude4u.com/v1
API Key:  cr_your-relay-key
Model ID: claude-sonnet-4-20250514

// Switch models by changing only the Model ID:
// claude-sonnet-4-20250514  - Claude Sonnet 4
// gemini-2.5-flash          - Google Gemini 2.5 Flash
// gemini-2.5-pro            - Google Gemini 2.5 Pro
// gpt-4o                    - OpenAI GPT-4o
Using a relay service like claude4u.com means you only need to configure Roo Code once. To switch between different AI models, simply change the Model ID without touching the Base URL or API Key. The relay service handles routing to the correct provider automatically.

Local Ollama Server

Base URL: http://localhost:11434/v1
API Key:  ollama  (any non-empty string works)
Model ID: llama3.1:latest

// Common Ollama models:
// deepseek-coder-v2:latest  - Good for coding
// qwen2.5-coder:latest      - Good for coding
// llama3.1:70b               - General purpose (requires 48GB+ VRAM)

Together AI

Base URL: https://api.together.xyz/v1
API Key:  your-together-api-key
Model ID: meta-llama/Llama-3.3-70B-Instruct-Turbo

Groq (Fast Inference)

Base URL: https://api.groq.com/openai/v1
API Key:  your-groq-api-key
Model ID: llama-3.3-70b-versatile

DeepSeek

Base URL: https://api.deepseek.com/v1
API Key:  your-deepseek-api-key
Model ID: deepseek-chat

Testing Your Configuration

After configuring the base URL, verify everything works correctly:

  1. Quick test: Open the Roo Code chat and send "Hello, what model are you?" to confirm connectivity and model identity.
  2. File operation test: Ask Roo Code to create a simple test file to verify write permissions work through the configured endpoint.
  3. Streaming test: Ask for a longer response and verify that tokens stream in real-time rather than arriving all at once.
// Terminal test with curl to verify the endpoint:
curl -X POST https://claude4u.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer cr_your-key" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "messages": [{"role": "user", "content": "Hello"}],
    "max_tokens": 50
  }'

Per-Mode Base URL Configuration

Roo Code allows different API configurations for different modes. This means you can use a powerful model for Code mode and a cheaper one for Ask mode:

  1. Open Roo Code settings.
  2. Switch to the mode you want to configure (e.g., Ask mode).
  3. Set the provider, base URL, API key, and model for that specific mode.
  4. Repeat for each mode that needs a different configuration.

Troubleshooting

Security Best Practices

Get Started with 轻舟 AI

Stable, fast AI API relay — supports Claude, OpenAI, Gemini and more

Sign Up Free