OpenAI-Compatible API: What It Means, How to Use It

What an OpenAI-compatible API is, base URL vs endpoint, and the three values to change so the OpenAI SDK, curl or Cline can call Claude, GPT, DeepSeek or GLM.

GoiAPI · · 12 min read

Ask AI and more
View as Markdown

Diagram of the OpenAI SDK, Cursor, Cline, curl and n8n pointing to a terminal showing base_url https://api.goiapi.com/v1, an sk- API key, a model name and POST /chat/completions

An OpenAI-compatible API is a service that accepts requests in the same format as OpenAI's API: the same paths (such as /v1/chat/completions), the same JSON body, and the same Authorization: Bearer key header. Because of that, code and tools built for OpenAI, like the OpenAI SDK, Cline, n8n or Open WebUI, work with it after you change just three values: the base URL, the API key and the model name. The model behind the endpoint does not have to be GPT; it can be Claude, DeepSeek, GLM or anything else the service offers.

This guide explains what "compatible" covers and what it does not, how a base URL differs from an endpoint (the most common cause of 404 errors), and gives copy-paste examples for Python, Node.js, curl and coding tools. The tests and examples use GoiAPI, which sells access to the models mentioned here.

What "OpenAI-compatible" actually means

OpenAI's Chat Completions format has become the format most AI tools support out of the box. A service is OpenAI-compatible when it accepts and returns that format:

  • Same paths. For example POST /v1/chat/completions for chat and GET /v1/models for the model list.
  • Same request body. JSON with fields like model, messages, max_tokens and stream.
  • Same authentication. The key goes in an Authorization: Bearer <key> header.
  • Same response shape. The answer comes back in choices[].message.content, with token counts in usage.

The format says nothing about which model answers. On GoiAPI, you can send an OpenAI-format request with "model": "claude-haiku-5-5" or "model": "deepseek-v4.1-flash" and get an OpenAI-format response back. When we tested on December 3, 2026, all 9 models on GoiAPI (Claude, GPT, DeepSeek and GLM) returned HTTP 200 through /v1/chat/completions.

One caveat from the same day: Claude models were less stable through the OpenAI format than through Anthropic's own format. In a separate round of tests, three calls to claude-haiku-5-5 through /v1/chat/completions returned 503, while the same model through /v1/messages returned 200. The format comparison further down explains when to pick which.

Base URL vs endpoint

Mixing these two up is the most common reason an OpenAI-compatible setup returns 404.

  • Base URL is the shared prefix of every API path. It is what you paste into a tool's "Base URL" field or pass as base_url to an SDK.
  • Endpoint is the full address of one operation: the base URL plus a specific path. SDKs and tools add that path for you, so you normally never type it.
API formatBase URL you enterEndpoint the tool callsUsed by
OpenAI Chat Completionshttps://api.goiapi.com/v1https://api.goiapi.com/v1/chat/completionsOpenAI SDK (chat.completions.create), Cline, Roo Code, most "OpenAI Compatible" options
OpenAI Responseshttps://api.goiapi.com/v1https://api.goiapi.com/v1/responsesCodex CLI, OpenAI SDK (responses.create)
Anthropic Messageshttps://api.goiapi.com (no /v1)https://api.goiapi.com/v1/messagesClaude Code, Anthropic SDKs

Sources: GoiAPI docs for Chat Completions, the Responses API and Anthropic Messages, checked on December 5, 2026.

The /v1 trap

Look at the base URL column. For OpenAI formats the base URL ends in /v1. For the Anthropic format it does not, because the Anthropic SDKs and Claude Code append /v1/messages themselves. If you paste https://api.goiapi.com/v1 as an Anthropic base URL, the final path becomes /v1/v1/messages. When we tried this on December 3, 2026, the request came back as a 404, the "path does not exist" error. In English, GoiAPI's error codes page gives that message as:

TEXT
The path {method} {path} does not exist.

The opposite mistake happens too: entering https://api.goiapi.com without /v1 in an OpenAI-format tool makes it call /chat/completions at the root, which also returns a 404.

Some tools are more forgiving. Kilo Code's docs say it "supports full endpoint URLs in the Base URL field", so .../v1/chat/completions works there too (Kilo Code docs, checked on December 5, 2026). If a tool's docs don't say, start with the base URL ending in /v1.

The three values to change: base URL, API key, model

Moving code or a tool from OpenAI to an OpenAI-compatible service usually means changing three things and nothing else:

ValueWith OpenAIWith GoiAPI
Base URLOpenAI's default (usually left blank)https://api.goiapi.com/v1
API keyA key from your OpenAI accountA GoiAPI key that looks like sk-..., created under API Keys in the dashboard
Model nameAn OpenAI model nameOne of the model names below

The model name must match the API name exactly. These are the models available on GoiAPI, with prices per 1M tokens in USD from the pricing page, checked on December 5, 2026:

ModelModel name (use this in model)InputOutput
Claude Haiku 5.5claude-haiku-5-5$0.0221$0.1105
Claude Opus 5.5claude-opus-5-5$0.442$2.21
DeepSeek V4 Prodeepseek-v4-pro-0813$0.144144$0.432432
DeepSeek V4.1 Flashdeepseek-v4.1-flash$0.0408408$0.1225224
GPT-6 Lunagpt-6-luna$0.0208$0.1248
GPT-6.1 Solgpt-6.1-sol$0.13$0.78
GPT-6.2 Solgpt-6.2-sol$0.13$0.78
GLM 5.3glm-5.3$0.144144$0.432432
GLM 5.3 Flashglm-5.3-flash$0.0408408$0.1225224

You can also get the list your key is allowed to use from GET /v1/models, which is not charged. A misspelled name returns a 404 with the message The model {model} does not exist. See the list at /v1/models.

For the key, GoiAPI accepts either Authorization: Bearer <key> (OpenAI style) or x-api-key: <key> (Anthropic style). Keys in the URL query string are not accepted. Keep real keys out of code you push to Git and out of screenshots; see Authentication.

How to use an OpenAI-compatible API: code examples

The examples below come from GoiAPI's docs. Replace <API_KEY> with your key (sk-...).

OpenAI SDK for Python

From the OpenAI SDK integration guide:

PYTHON
from openai import OpenAI

client = OpenAI(base_url="https://api.goiapi.com/v1", api_key="<API_KEY>")
reply = client.chat.completions.create(
    model="claude-haiku-5-5",
    messages=[{"role": "user", "content": "Hello"}],
)
print(reply.choices[0].message.content)

This is OpenAI's own Python library; only base_url, api_key and model differ from a call to OpenAI. To keep the key out of your source file, the library reads OPENAI_API_KEY from the environment by default, and you can set the base URL with the OPENAI_BASE_URL environment variable instead of base_url (openai-python README, checked on December 5, 2026):

BASH
export OPENAI_BASE_URL="https://api.goiapi.com/v1"
export OPENAI_API_KEY="sk-..."

OpenAI SDK for Node.js

Same idea, with camelCase option names:

JAVASCRIPT
import OpenAI from 'openai';

const client = new OpenAI({ baseURL: 'https://api.goiapi.com/v1', apiKey: '<API_KEY>' });
const reply = await client.chat.completions.create({
  model: 'claude-haiku-5-5',
  messages: [{ role: 'user', content: 'Hello' }],
});
console.log(reply.choices[0].message.content);

curl

curl is the quickest way to check a key and model without installing anything. From the Chat Completions docs:

BASH
curl https://api.goiapi.com/v1/chat/completions \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-5-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Write a Python function that reverses a string"}]
  }'

Set max_tokens (or max_completion_tokens). GoiAPI holds funds based on this value before calling the model, so keeping it close to what you need stops requests from being rejected with a 402 when your balance is low (Limits and balance). If tokens are new to you, AI API tokens and what 1M tokens costs explains how they are counted.

Cline, Roo Code, Kilo Code and Cursor

Most AI coding extensions have an "OpenAI Compatible" option. In Cline, click the gear icon, set API Provider to OpenAI Compatible, then fill in Base URL, API Key and Model (Cline docs, checked on December 5, 2026). With GoiAPI the Base URL is https://api.goiapi.com/v1. Roo Code has the same three fields; Kilo Code puts them under Custom provider in the Providers tab.

For Cursor, the GoiAPI Cursor guide uses Override OpenAI Base URL in Settings → Models. Screens change between versions, so step-by-step setup for all four tools, with the errors you may see, is in Cline, Roo Code, Kilo Code and Cursor: one API key setup.

Automation tools work the same way: see connecting n8n to Claude, GPT and DeepSeek through an OpenAI-compatible API. So do self-hosted chat interfaces and terminal coding agents: see Open WebUI with an OpenAI-compatible API and OpenCode custom provider setup.

OpenAI format vs Anthropic format: which one to use

Anthropic, the maker of Claude, has its own API format called Messages, at /v1/messages. Both formats send a list of messages and get a reply, but the details differ:

OpenAI (Chat Completions)Anthropic (Messages)
Endpoint/v1/chat/completions/v1/messages
Base URL on GoiAPIhttps://api.goiapi.com/v1https://api.goiapi.com
Key headerAuthorization: Bearer <key>x-api-key: <key> (GoiAPI also accepts Bearer)
max_tokensRecommendedRequired
Where the answer ischoices[].message.contentcontent[].text
Count tokens before sendingNot available/v1/messages/count_tokens (not charged on GoiAPI)

The same call in Anthropic format, from the curl guide:

BASH
curl https://api.goiapi.com/v1/messages \
  -H "x-api-key: <API_KEY>" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model": "claude-haiku-5-5", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'

How to choose:

  • The tool often decides for you. Claude Code does not speak the OpenAI format. Its gateway compatibility guide lists three formats a gateway can expose: Anthropic Messages (selected with ANTHROPIC_BASE_URL), Amazon Bedrock InvokeModel and Google Cloud's Agent Platform rawPredict (Claude Code gateway compatibility guide, checked on December 5, 2026). With GoiAPI that means ANTHROPIC_BASE_URL=https://api.goiapi.com; see the Claude Code API key setup guide. Cline, n8n and Open WebUI offer "OpenAI Compatible" directly.
  • Codex CLI uses the Responses API, a different OpenAI format. Its config reference says of wire_api: "responses is the only supported value, and it is the default when omitted" (Codex config reference, checked on December 5, 2026). GoiAPI serves /v1/responses; setup is in Codex CLI custom provider.
  • Your own code: GoiAPI's docs recommend the Anthropic format for Claude models, and note that some models are only available through one format, so calling them through the other returns a 503. If you want to switch between Claude, GPT, DeepSeek and GLM without touching code, the OpenAI format is the more convenient one.

OpenAI itself now suggests Responses for new projects ("Starting a new project? We recommend trying Responses", OpenAI API reference, checked on December 5, 2026). Still, when a third-party tool just says "OpenAI Compatible", it almost always means Chat Completions at /v1/chat/completions.

Compatible is not identical

OpenAI's API covers much more than chat: embeddings (turning text into vectors for semantic search), image generation, speech, file storage and more. An "OpenAI-compatible" service usually implements only part of it. Check which endpoints exist before you build on one.

On GoiAPI, the paths under /v1 are chat/completions, responses, messages, messages/count_tokens and models. We sent test requests without a key on December 3, 2026:

EndpointStatusMeaning
POST /v1/chat/completions401 (missing API key)Exists, needs a key
POST /v1/responses401 (missing API key)Exists, needs a key
POST /v1/embeddings404 (path does not exist)Not available
POST /v1/images/generations404 (path does not exist)Not available
POST /v1/audio/speech404 (path does not exist)Not available

So GoiAPI does not offer embeddings, image generation or audio. A retrieval chatbot over your documents would need another service for the embedding step. Other differences worth knowing:

  • The Responses API is partly supported. Responses are not stored, so previous_response_id returns a 400; OpenAI built-in tools such as web_search, file_search and code_interpreter are ignored; and files referenced by file_id return a 400 (Responses API docs).
  • Token counts differ by model. The same prompt produces different input token counts on Claude, GPT, DeepSeek and GLM, because each uses its own tokenizer. Some models, such as deepseek-v4.1-flash and glm-5.3-flash, also produce reasoning tokens that are billed as output.
  • Streaming adds a usage chunk. For OpenAI-format requests, GoiAPI always enables stream_options.include_usage, so a stream ends with an extra chunk containing usage (Streaming).
  • Errors follow the request's format. Calls to /v1/chat/completions get OpenAI-style error bodies ({"error": {"message": ..., "type": ..., "code": ...}}); calls to /v1/messages get Anthropic-style ones.
  • Format support can change. All 9 models answered through the OpenAI format when we tested, but a model only available in one format returns 503 in the other.

When to call the model maker's API directly

One key for many models is handy when you want to switch models without changing code and pay with USDT. Going straight to OpenAI, Anthropic or another model maker makes more sense when:

  • You need embeddings, image generation, audio, or OpenAI's built-in tools like web search and code execution.
  • You need a model GoiAPI does not list, such as Claude Sonnet or Gemini.
  • You need a data processing agreement signed directly with the model maker.
  • You need a brand-new feature on launch day; compatible services can lag behind.

FAQ

What is an OpenAI-compatible API?

It is an API that accepts requests and returns responses in OpenAI's format, usually Chat Completions at /v1/chat/completions. Any library or tool built for OpenAI can call it after you change the base URL, API key and model name.

What is the base URL for an OpenAI-compatible API?

It is the prefix before the endpoint path, usually ending in /v1. On GoiAPI it is https://api.goiapi.com/v1 for the OpenAI formats and https://api.goiapi.com (no /v1) for the Anthropic format.

What is /v1/chat/completions?

It is the Chat Completions endpoint: you send a model and a list of messages, and the reply comes back in choices. Tools labeled "OpenAI Compatible" call this endpoint unless they say otherwise.

Can I use the OpenAI SDK with Claude?

Yes, if the service you point it at serves Claude through the OpenAI format. On GoiAPI, set base_url="https://api.goiapi.com/v1" and model="claude-haiku-5-5" or "claude-opus-5-5". Both returned 200 in our main test on December 3, 2026, though one test round that day got 503s. For long-term Claude use, GoiAPI's docs recommend the Anthropic SDK with base URL https://api.goiapi.com. You cannot do this against api.openai.com, because OpenAI does not serve Claude.

Does Claude Code work with an OpenAI-compatible endpoint?

No. Claude Code calls the Anthropic Messages format (or Bedrock and Google Cloud formats), not Chat Completions. Set ANTHROPIC_BASE_URL=https://api.goiapi.com instead; the Claude Code integration docs have the full setup. To run GPT, DeepSeek or GLM inside Claude Code, see Claude Code Router.

Why does my OpenAI-compatible endpoint return 404?

Usually one of three things: the base URL has an extra or missing /v1, the model name is misspelled, or the tool calls an endpoint the service does not have (such as /v1/embeddings). Read the message: "The path ... does not exist" means a wrong path, "The model ... does not exist" means a wrong model name. All codes are listed in Error codes.

Is the Responses API OpenAI-compatible too?

Yes, it is a second OpenAI format at /v1/responses, used by Codex CLI and client.responses.create(). A service can support Chat Completions without supporting Responses, so check its docs. GoiAPI supports both, with the Responses limitations listed above.

Get started with GoiAPI

  1. Create an account and verify your email.
  2. Top up with USDT (TRC20 or BEP20) or Binance Pay. There is no credit card and no monthly fee. Top-ups are final and non-refundable, so add only what you plan to use.
  3. Create an API key under API Keys and copy it right away; it is shown only once.
  4. Set the base URL to https://api.goiapi.com/v1 (or https://api.goiapi.com for Anthropic-format tools), paste your key, and pick a model name from the table above.

The quickstart walks through your first call with curl, an SDK or Claude Code, and the dashboard's Request history page shows each request's tokens and cost as it happens.

Related posts