DEV Community

APIVAI
APIVAI

Posted on

Cline with Claude and GPT through your own API gateway: OpenAI Compatible vs Anthropic, and the /v1 trap

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.

Cline is an open-source coding agent for VS Code. It reads your files, proposes edits and runs commands with your approval, but it ships without a model: you bring a provider and a key. Cline offers two provider types that work with a third-party gateway, and most setup errors come from mixing up their base URLs. Here is how they differ and how to fill in each one.

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 Cline's list
Best for One setup for every model Claude in its native Messages format

Pick OpenAI Compatible if you want to switch between Claude and GPT, or use a model ID newer than Cline's built-in list. Pick Anthropic if you only use Claude. The same key works in both, and you can switch at any time.

Setting up OpenAI Compatible

  1. Open the Cline panel in VS Code and click the gear icon.
  2. Set API Provider to OpenAI Compatible.
  3. Fill in the fields below, click Verify if your version has it, 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 must end in /v1 exactly once, because Cline appends /chat/completions itself. Leave Context Window, Image Support and Computer Use at their defaults unless you know you need them. The Input/Output Price fields only change the cost estimate Cline shows; they don't affect billing.

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

Copy IDs from that response rather than from old tutorials; the list changes.

Setting up Anthropic (Claude only)

  1. Set API Provider to Anthropic.
  2. Paste your key into Anthropic API Key.
  3. Tick Use custom base URL and enter https://api.apivai.com.
  4. Pick a Claude model from the dropdown.

Do not add /v1 here. Cline's Anthropic client appends /v1/messages on its own, so https://api.apivai.com/v1 turns into /v1/v1/messages and returns 404. If the Claude model you want isn't in Cline's list yet, use the OpenAI Compatible provider and type the ID.

Which model for which job

Cline re-sends the conversation and every file it has read on each step, so input tokens add up quickly and the price per token matters more than in a chat app. A practical split:

  • Everyday coding: claude-sonnet-4-6 or claude-sonnet-5-5
  • Hard bugs and large refactors, when Sonnet keeps going in circles: claude-opus-5-5
  • Renames, comments, small fixes: claude-haiku-4-5
  • A second opinion: gpt-5.5 (OpenAI Compatible only)

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 Cline 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). Add budget to the key or switch to a cheaper model.
  • 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.
  • 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 agent runs can hit it; wait a moment or split work across 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)