Setup guides

Switching an existing integration to a different billing route is usually a base URL change, not a rewrite. These walk through it tool by tool.

Three ways in. By tool, Claude Code, Cursor, Cline, LiteLLM and the rest. By task — fixing an error, working out the bill, or routing and migration. Or by model, if you already know which one you want.

Claude Code

Two environment variables, verification via curl, and the four errors people actually hit.

Cursor

Where the base URL override lives, and how to confirm requests are routing.

Cursor — OpenAI-compatible models

The override takes a versioned base with no trailing slash, and Cursor never reads /v1/models (every model ID has to be added by hand).

Cursor Agent mode on your own endpoint

Which surfaces reach your key and which never leave Cursor's backend, including background sub-agents that ignore the override entirely.

Cursor Agent errors on a custom endpoint

Chat answers but Agent stalls. Triage table for tool calls, streaming drops, reasoning-field failures and context exhaustion.

OpenAI & Anthropic SDK

One base_url argument. Python, Node and curl examples.

Base URL in Node.js

OpenAI and Anthropic SDKs from Node: the capitalisation trap, doubled paths and a dependency-free fetch version.

Gemini through a custom endpoint

Use one client across vendors, and read the exact model ID off /models.

Looking for a number rather than a setup? Price a workload in the calculator, compare vendors on the pricing index, or read how the bill is built.

Using Claude inside your tools

Claude API in Cursor

Add your own key, override the base URL, and pick a model per task.

Anthropic base URL in Python

Sync, streaming, async and raw HTTP examples (plus the headers that cause most 401s).

Migrate from OpenAI to Claude

Request/response mapping table, tool calling differences, and a shadow-mode cutover plan.

Claude in LangChain

Set the endpoint on the chat model; chains, agents and parsers stay unchanged.

Cost control

Claude Code cost per month

What actually drives the bill, and why it is usually context resends, not message count.

Reduce Claude API cost

Eight levers ranked by effect, with code for the two that matter most.

OpenAI-compatible endpoints

Which parts of the contract are portable, and the three features that are not.

Monitor API spend

Log usage per request, attribute it, and alert on change rather than totals.

Batch API vs realtime rates

What the 50% batch discount and 10% cached-input rate really buy And when waiting 24 hours saves nothing.

Prompt caching: what a hit costs

Per-model numbers: a cache hit runs about 5× cheaper than the uncached rate, plus the break-even reuse count.

Why the same model has two prices

All 24 models we can check against a published list rate, and the one exception that proves no flat rate exists.

2026 AI API price index

The benchmark behind every ranking here: three token mixes, published method, and the full dataset as CSV and JSON.

No cheapest model, only a cheapest mix

226 models re-ranked on three token ratios. Sorting by input price alone can be 74 places wrong.

The thinking tax

21 reasoning models hold the steepest multiples in the index, and sit at the same 4.00× median as everything else — so the tax is not the multiple.

The 4x rule in model pricing

Median 4.00× across 226 models, identical in the three cheapest quartiles — and 24 more sitting at exactly 8.00×.

Why output dominates the bill

Output costs a median of 4.0× input across 226 models, up to 12.0× And 16 models charge both the same.

How to calculate the cost

Two multiplications, and the median model charges 4.0× for the second one. One reference workload priced five ways.

Coding agent cost per month

The same agent costs $4 or $78 a month depending only on the model. Three workloads, priced.

Why Cursor gets expensive

Agent mode re-sends the whole conversation every turn, and output costs a median of 4.0× input.

What hitting the context limit costs

Compression, truncation or restart, three exits from a full context, priced differently.

Cline cost per month

Cline returns whole files, not diffs, so output arrives in bursts Which makes the output rate the one that decides the bill.

Aider cost per month

Aider sends a map of your repository before you ask anything. On a large codebase that fixed per-session cost dominates.

Codex CLI cost per month

Terminal agents carry less ambient context per turn, but unattended runs multiply turns, and turns are the cost driver.

Tool integration (one endpoint), every tool

Every tool with one endpoint

The tool matrix: which setting to change in Claude Code, Cursor, LiteLLM, the AI SDK and Cline, plus the three failures behind most tickets.

LiteLLM custom endpoint

Per-call api_base, streaming, fallbacks and proxy YAML And why its built-in cost table cannot price a gateway route.

Vercel AI SDK endpoint

createOpenAI({ baseURL }) instead of openai(), with generateText, streaming and tool calling.

Cline OpenAI-compatible

The provider switch that reveals the base URL field, and why agent loops make the output rate the one that matters.

Aider custom endpoint

The openai/ model prefix, the double-prefix trap, and why Aider is input-heavy in a way chat is not.

Continue custom endpoint

Assign autocomplete and chat to different models by role, the most under-used cost control in the tool.

Open WebUI endpoint

Persistent config that ignores later environment changes, and URL/key lists that pair by position.

n8n custom endpoint

The credential-level base URL, and the toggle that sends requests to the wrong path.

Zed

The provider block in settings.json And why edit prediction needs a different endpoint than chat.

Windsurf Cascade

Selecting the OpenAI-compatible provider, and why every turn is billed mostly on input.

Dify

Adding an OpenAI-API-compatible provider, plus the Docker localhost trap that blocks local servers.

Pydantic AI

Why the default openai: prefix posts to /v1/responses, and how retries multiply your bill.

OpenHands

The agent loop that resends its whole history, and the budget and retry limits that ship switched off.

LibreChat

One endpoint under a shared key, plus the title-generation setting that adds a call per conversation.

Roo Code

Why a model without tool calling chats fine but cannot touch your files, and what scope does to the bill.

AnythingLLM

Embedding is a one-off cost and queries are forever (choosing on embedding price picks the wrong model).

CodeCompanion.nvim

An adapter is not a global setting, four strategies resolve one each and fall back silently. The shipped openai_compatible adapter defaults its URL to a local Ollama port.

avante.nvim

The endpoint field is documented both as a prefix and as a full path. Automatic repository context puts 87% of the bill on input.

LobeChat

The proxy variable is OPENAI_PROXY_URL, and anything else is ignored silently. Whether the URL takes /v1 shows up as an empty reply, not a 404.

gptel (Emacs)

The request URL is assembled as protocol://host plus endpoint — so :host takes no scheme, :protocol assumes https, and :stream defaults to off.

Cherry Studio

The API Address field appends /v1/chat/completions for you; a trailing # switches that off. Models stay hidden until you add them.

Frameworks, SDKs and command-line agents

LangChain

One base_url kwarg. Then check whether token usage still comes back, because a non-OpenAI host turns it off.

LlamaIndex

OpenAILike for gateway model IDs, and a second object for the embedding model that most setups forget.

AutoGen

Declare function_calling explicitly, or tool use fails silently with no error anywhere.

OpenAI Agents SDK

Tracing exports to OpenAI by default, and the default transport is Responses rather than Chat Completions.

CrewAI

custom_openai=True, and why the bill is agents multiplied by turns rather than messages.

DSPy

The real spend is in compile(), not inference, one optimisation run is a thousand calls.

Codex CLI

Recent versions reject wire_api = "chat" at config load rather than at request time.

Gemini CLI

A model without tool calls replies in prose and never touches the repository, without saying so.

OpenCode

/connect stores a credential and stops. The provider block has to be written into opencode.json by hand And v1 and v2 use different keys.

Kilo Code

The base URL field takes a full endpoint URL, provider IDs reject slashes while model IDs accept them, and unset token limits disable context management.

Goose

The host variable is OPENAI_HOST, not the OPENAI_BASE_URL every other tool reads — and the models array supplies context sizes, not a model list.

Crush

One JSON file holds every provider. type is spelled two different ways in official sources, and models[] declares context rather than discovering it.

Semantic Kernel

The answer splits by language: .NET takes endpoint but it is flagged experimental, and Python has no base URL argument at all.

Spring AI

base-url carries no /v1 — completions-path supplies it, so a versioned URL doubles the path. The API key is mandatory even without authentication.

Plandex

Custom providers come from a JSON file, not an environment variable, and apiKeyEnvVar wants the name of a variable rather than the key.

Agno

OpenAILike defaults id and api_key to the string not-provided, and a knowledge base embeds through OpenAI until you re-point the embedder.

Open Interpreter

LiteLLM underneath means api_key cannot be empty, and api_base alone leaves the context window at 3000.

Cody

Each cody.dev.models entry declares its own context budget, and inputTokens starts at 7000 no matter what the endpoint serves.

Mastra

baseURL belongs on createOpenAI. On the model call it is dropped, and the request reaches OpenAI carrying your gateway key.

Jan

The API format is picked before the URL and describes the protocol, not the model's maker. The base URL has to carry /v1.

Smolagents

Whether the model id needs an openai/ prefix depends on which model class you constructed, and both take api_base.

Bolt.diy

OpenAI-Like ships disabled under Local Providers, and model ids are discovered from /models rather than typed into a field.

Prism PHP

The url default already ends in /v1, the opposite of Spring AI, and a cached Laravel config hides env edits.

Flowise

Only the ChatOpenAI Custom node has a Base Path field, and it is stored per node with no shared default.

Void

One provider fills the URL; autocomplete, inline edit and chat each need a model assigned before they do anything.

LangChain4j

apiKey is checked at build time, and the Spring property prefix keeps the hyphen: open-ai.

Langflow

The OpenAI Compatible provider only exists from 1.11, and SSRF protection refuses localhost until you allowlist it.

RAGFlow

Max tokens budgets retrieval and history rather than capping the reply, and its /v1 auto-append is version-bound.

Tabby

Three model slots with nothing shared, and the completion slot needs a fill-in-the-middle template matched to the model.

aichat

Several programs share this name, and the endpoint field takes a version root or a full operation path depending on which you installed.

claude-code-router

Translates Claude Code's Anthropic calls to an OpenAI backend, and the transformer list decides whether tool calling works.

MaxKB

Consumes an OpenAI-compatible endpoint as a model backend and serves one per application, with a different base URL both ways.

Trae

The request-URL field is a base address or a full address depending on one toggle, and /v1 belongs to whoever the toggle says.

Zencoder

Two unrelated routes to a custom model, a UI key screen limited to two vendors, and a settings.json provider map for everything else.

Twinny

Chat and inline completion call different routes, so a chat-only endpoint leaves completion silently unusable.

Haystack

The LLM components append the operation path themselves, and the embedder is a second endpoint with its own dimension contract.

Raycast AI

Custom models come from a providers.yaml whose base URL excludes the route, and whose abilities block is a promise about the model.

Ellama

An Emacs front end that takes a provider object rather than a URL And two constructors differ by one word.

Operations and troubleshooting

API error troubleshooting

401, 404, 429 and 529, what each actually means and the exact fix.

Rate limits explained

Three axes enforced per model, correct backoff, and why parallelism causes most throttling.

Cursor API key errors

Own-key failures diagnosed: restart behaviour, doubled paths, quota that will not move.

When it is configured and still does not work

Everything above ends with a working setup. These fifteen start where those end (with a configuration that looks correct and a request that still fails). The shared idea: a URL that is never read and a URL that is wrong produce identical symptoms, and authentication happens before routing.

Base URL not working

Seven causes in the order they actually happen, and one layered probe that eliminates a class of causes per layer.

Endpoint error codes

A 401 localises to the credential and a 404 to the path, plus the two failures that return a 200.

LiteLLM retries and timeouts

Two retry knobs with similar names, and the fallback chain that re-runs the retry loop at every hop.

Claude Code 429

One wrapper message, three unrelated limits And reset times that differ by orders of magnitude.

LiteLLM model names

The slash is a routing instruction, and the provider-not-found error fires before any request is sent.

Streaming and usage

The chunk that carries the token counts is the one with an empty choices array, and it may never arrive.

Empty model picker

Read the endpoint's own model list, and never let a client guess a context window from a name.

Context length exceeded

Two independent caps (the input window and the maximum output) and only one of them reports an error.

Cline 401 invalid_api_key

A 401 points at the key field and a 404 at the base URL. Bisect the path with curl instead of guessing which to edit.

Cursor: unification API is unreachable

It fires before the request reaches a model, so the key, the base URL and the model ID are all the wrong things to change.

Cursor 429 rate limit

Agent mode multiplies your request rate. Which of the three limits you hit, and how to back off without stalling.

Cursor model_not_found

Routing worked and the string did not match. The dropdown is a snapshot, not a catalogue, copy the ID from the endpoint.

Cursor request timeout

Connection timeout, read timeout and a context refusal look identical from the editor. Measure which before raising anything.

Claude Code 401

This client sends x-api-key and anthropic-version, not a Bearer token. Same key, different header, different result.

Langflow SSRF allowed hosts

A server-side request guard refuses your host before the key is checked (curl works, the flow does not).

Zed edit prediction silent

Chat answers while autocomplete never fires, edit prediction posts a different payload to a different route.

Codex stream disconnected

exceeded retry limit with a 429 at the end Which does not always mean the quota is gone.

OpenCode prompt is too long

The wording changes per provider; the field that decides when it fires is limit.context.

Gemini CLI 404

Not an auth failure. The CLI asks for v1beta by default, and a double slash is a different path.

Routing, fallback and migration

Once one endpoint serves many models, the interesting decisions move up a layer: which model handles a request, what happens when one is unavailable, and how to move an existing integration without a rewrite.

Model fallback chain

Order by capability, not price. Which errors should advance the chain, and the two ways a backup fails quietly.

Migrate from the OpenAI API

Three fields change, base URL, key, model IDs. What stays identical, and the log entry that proves traffic actually moved.

OpenAI to Claude migration

When the model changes too: message shape, system prompts, tool calling and the parts that do not translate.

Route by difficulty in Cursor

Most turns are mechanical. Send those to a cheap model and keep the open-ended ones on a strong one.

Before you start

Create account to get a key

Rate cards: GPT, Claude and Gemini