Cline OpenAI Compatible Setup

Configure Cline with OpenAI Compatible API: Step-by-Step Guide

Cline's OpenAI Compatible provider option is the most flexible way to connect to virtually any AI model. It works with relay services, self-hosted models, alternative providers, and any endpoint that implements the OpenAI chat completions API format. This guide provides detailed instructions for setting up and optimizing the OpenAI Compatible configuration in Cline.

Why Use OpenAI Compatible?

The OpenAI Compatible provider in Cline is not just for OpenAI models. It works with any API that follows the OpenAI chat completions format, which has become the industry standard. This includes:

Step-by-Step Configuration

  1. Open VS Code and click the Cline icon in the sidebar.
  2. Click the settings gear icon in the Cline panel.
  3. In the API Provider dropdown, select "OpenAI Compatible".
  4. Fill in the required fields as described below.

Configuration Fields Explained

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

// The Base URL should NOT include /chat/completions
// Cline appends the endpoint path automatically
A common mistake is including the full path like https://provider.com/v1/chat/completions in the Base URL field. Only include the base path up to and including /v1. Cline adds the rest of the URL automatically.

Configuration Examples for Popular Services

claude4u.com Relay Service

Base URL: https://claude4u.com/v1
API Key:  cr_your-relay-key
Model ID: claude-sonnet-4-20250514
// Also supports: gemini-2.5-flash, gemini-2.5-pro, gpt-4o, etc.

Local Ollama Server

Base URL: http://localhost:11434/v1
API Key:  ollama  (any non-empty string)
Model ID: deepseek-coder-v2:latest

Together AI

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

Groq

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 entering your configuration details, test the connection:

  1. Open the Cline chat panel.
  2. Send a simple message like Hello, what model are you?
  3. Verify that you receive a response and that the model identifies itself correctly.
  4. Try a coding task like Create a simple Python hello world script to confirm file editing works.
If you see a response but the model identification does not match what you configured, double-check the Model ID. Some relay services and providers map model names differently. Consult the provider's API documentation for exact model identifiers.

Advanced Configuration

Streaming

Cline uses streaming by default for real-time token display. Most OpenAI-compatible endpoints support streaming. If you experience issues with a provider that does not support streaming, check the Cline settings for a streaming toggle.

Custom Headers

Some providers require additional headers for authentication or routing. If your provider needs custom headers, you may need to configure them through environment variables or proxy settings. Common examples include:

# For Azure OpenAI:
# The API key is typically sent as "api-key" header
# Base URL format: https://your-resource.openai.azure.com/openai/deployments/your-deployment

# For providers behind Cloudflare Access:
# You may need CF-Access-Client-Id and CF-Access-Client-Secret headers

Troubleshooting

Switching Between Providers

You can quickly switch between different API configurations in Cline by changing the provider dropdown. Your settings for each provider are saved separately, so you can easily switch between your relay service, local Ollama, and direct provider access without re-entering credentials each time.

For the most flexible setup, configure a relay service like claude4u.com as your primary provider. This gives you access to multiple models through a single endpoint, and you only need to change the Model ID field to switch between Claude, Gemini, GPT, and other models.

Get Started with 轻舟 AI

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

Sign Up Free