OpenAI API alternatives
Claude, Gemini, DeepSeek, Grok, Mistral, open-weight hosts and self-hosting compared on price per million tokens, OpenAI compatibility and limits.
Short answer
Most OpenAI API alternatives run your existing OpenAI SDK code with a new key, base URL and model name.
Google Gemini, DeepSeek, xAI Grok, OpenRouter, Together AI, Groq, Fireworks AI and a local Ollama or vLLM server all document an OpenAI-compatible Chat Completions endpoint. Anthropic offers one too, but calls it a way to test Claude, not a production path. Prices below come from each vendor’s own page, read November 9, 2026.
8 of 10options we checked
Checked Nov 9, 2026Which OpenAI API alternative fits your app?
Pick what matters most. You get the provider and model to try, the price per million input and output tokens from the vendor’s own page, and the fact that decides it.
- 01Try DeepSeek V4.1 Flash, model name deepseek-flash, with base URL api.deepseek.com in the OpenAI SDK.
- 02Price: $0.30 per million input tokens and $1.20 per million output tokens at peak, half that off-peak ($0.15 and $0.60). A cache hit costs $0.006 at peak. Context is 1M tokens.
- 03The fact that decides it: peak is only 01:00 to 04:00 and 06:00 to 10:00 UTC on weekdays, DeepSeek’s pricing page says. Every other hour, weekends included, bills at half price.
- 04Check first: OpenAI’s own GPT-6 Luna costs $0.10 in and $0.50 out. For a small model, staying on OpenAI can cost less than switching.
- 01Try Claude Opus 5.5 (claude-opus-5-5) on the Anthropic API.
- 02Price: $4 per million input tokens and $20 per million output tokens, against $10 and $50 for GPT-6 Astra.
- 03The fact that decides it: Claude Opus 5.5 (max) tops FrontierCode 2.0 with 46.4%, ahead of GPT-6 Astra (max) at 42.4%, on Artificial Analysis, read November 9, 2026.
- 04Use Anthropic’s own SDK in production. Its OpenAI compatibility layer is for testing, and it drops prompt caching.
- 01Try OpenRouter: keep the OpenAI SDK, set the base URL to openrouter.ai/api/v1 and name a model such as anthropic/claude-opus-5.5 or google/gemini-4-argon.
- 02Price: the maker’s list price per token. The models API showed Claude Opus 5.5 at $4 and $20 and Gemini 4 Argon at $2 and $10, the same as Anthropic and Google.
- 03The fact that decides it: one key reaches 461 models in the models API, and OpenRouter calls its API a drop-in replacement for the OpenAI SDK.
- 04The cost: a 5.5% fee when you buy credits on the Standard plan, 8% on Business, never per request.
- 01Run an open-weight model on your own machine with Ollama, then point the OpenAI SDK at localhost:11434/v1/.
- 02Price: $0 per token. You pay for the hardware and power; gpt-oss:20b, the model in Ollama’s own example, needs about 14 GB of memory.
- 03The fact that decides it: prompts never leave your computer. The SDK still wants an API key, which Ollama ignores.
- 04Ollama supports “a subset of the OpenAI API”, its docs say; stateful Responses calls are not supported. On a Linux GPU server, vLLM offers the same kind of endpoint.
OpenAI API alternatives compared: price per 1M tokens
Every price below was read on the vendor’s own pricing page or model page on November 9, 2026, in US dollars per million tokens, input first and output second. OpenAI is the first row so you can compare against what you pay now. No provider here is rated by us; the picks above rest on prices, published limits and one named benchmark.
| Provider | Top model | Cheap model |
|---|---|---|
| OpenAI | GPT-6 Astra $10 / $50 | GPT-6 Luna $0.10 / $0.50 |
| Anthropic | Claude Opus 5.5 $4 / $20 | Claude Haiku 5.5 $0.10 / $0.50 |
| Gemini 4 Argon $2 / $10 | Gemini 3.1 Flash-Lite $0.25 / $1.50 | |
| DeepSeek | V4 Pro $1.32 / $3.96 | V4.1 Flash $0.30 / $1.20 |
| xAI | Grok 4.7 $2 / $6 | Grok 4.3 $1.25 / $2.50 |
| Mistral | Large 4 $0.70 / $2.10 | Small 4 $0.15 / $0.60 |
| Together, Fireworks | Kimi K3 $3 / $15 | GPT OSS 120B $0.15 / $0.60 |
| Groq | GPT OSS 120B $0.15 / $0.60 | GPT OSS 20B $0.075 / $0.30 |
| Self-hosted | Any open model, $0 | Hardware and power only |
Some prices change with the date or the prompt size. Gemini 4 Argon rises to $4 and $20 on December 1, 2026, and Gemini 3.8 Flash from $0.75 and $3.75 to $1.50 and $7.50 on January 1, 2027, Google’s page says. DeepSeek’s rates are peak rates; off-peak is half. Claude Haiku 5.5 costs $0.50 and $2.50 once a prompt passes 100,000 tokens. Our AI API pricing calculator turns these rates into a monthly bill for your own volume.
$10Which OpenAI API alternatives are OpenAI-compatible?
An OpenAI-compatible API accepts the same Chat Completions request your code already sends, so you change three things: the API key, the base URL and the model name. Each vendor’s docs, read November 9, 2026, give these base URLs (all start with https://):
| Provider | Base URL | What the docs say |
|---|---|---|
| Anthropic | api. | For testing, not production |
| generativelanguage. | Three lines of code | |
| DeepSeek | api. | OpenAI and Anthropic formats |
| xAI | api. | Chat Completions is legacy |
| Mistral | Own API | Not called OpenAI-compatible |
| OpenRouter | openrouter. | Drop-in replacement |
| Together | api. | Drop-in client setup |
| Groq | api. | Mostly compatible |
| Fireworks | api. | OpenAI SDK supported |
| Ollama | localhost: | A subset of the API |
In the OpenAI Python SDK the swap is one line where you create the client. For Gemini it looks like this, with your Gemini key in place of the OpenAI one:
client = OpenAI(
Then send model="gemini-3.8-flash" instead of a GPT name. The same pattern works for every row with a base URL. If you do not have an OpenAI key yet and want to compare both sides, our guide to getting an OpenAI API key covers that.
Anthropic Claude API as an OpenAI API alternative
Anthropic’s current models are Claude Fable 5.1 ($10 in, $50 out), Claude Opus 5.5 ($4, $20), Claude Sonnet 5.5 ($2, $10) and Claude Haiku 5.5 ($0.10, $0.50 for prompts up to 100,000 tokens). All four have a 1M-token context window and 128K tokens of output, Anthropic’s models page says. The Batch API halves every rate, and a cache hit on Opus 5.5 and Sonnet 5.5 costs 0.05 times the base input price.
Anthropic runs an OpenAI SDK compatibility layer at api.anthropic.com/v1/, available on every model. Its docs say it is “primarily intended to test and compare model capabilities” and not a long-term or production-ready solution for most uses. On that layer the strict setting for function calling is ignored, prompt caching is off, audio and file inputs return a 400 error, and system messages are merged into one. For production, the native Messages API and Anthropic’s SDKs keep caching and structured outputs. New users get a small amount of free credit to test. Every Claude rate, with cache and batch prices, is on our Claude API pricing page.
Google Gemini API
Google’s top model on the Gemini Developer API is Gemini 4 Argon, $2 in and $10 out through November 30, 2026, then $4 and $20. It is not on the free tier, and Google bills its thinking tokens as output. Gemini 3.8 Flash costs $0.75 and $3.75 until the end of 2026; Gemini 3.5 Flash-Lite costs $0.30 and $2.50, and Gemini 3.1 Flash-Lite $0.25 and $1.50. The Batch API takes 50% off.
Gemini is also the main free OpenAI API alternative: Flash and Flash-Lite models have a free tier with free input and output tokens. The trade is data: on the free tier Google’s pricing page marks content as used to improve its products, on the paid tier as not used. Google’s OpenAI compatibility page says Gemini works with the OpenAI Python and JavaScript libraries “by updating three lines of code”, but still recommends calling the Gemini API directly if you are not already on the OpenAI libraries.
DeepSeek API
DeepSeek sells two models. deepseek-flash, served by DeepSeek-V4.1-Flash-1017, costs $0.30 in and $1.20 out at peak; deepseek-v4-pro (DeepSeek-V4-Pro-0813) costs $1.32 and $3.96. Off-peak rates are half. Both have a 1M-token context and up to 384K tokens of output, and support JSON output and tool calls; only Flash reads images. The concurrency limit is 2,500 requests for Flash and 500 for Pro.
The API takes the OpenAI format at api.deepseek.com and the Anthropic format at api.deepseek.com/anthropic, so the OpenAI SDK works unchanged apart from key, URL and model. DeepSeek is a Chinese lab; our page on Chinese AI models covers what that means for licenses and data.
xAI Grok API
xAI’s newest model, grok-4.7, costs $2 in, $0.50 cached and $6 out, with a 500,000-token context. grok-4.3 and the grok-4.20 models cost $1.25 and $2.50 with a 1M context, and grok-build-0.1, a coding model, $1 and $2. Once a prompt reaches 200,000 tokens, the long-context rate, twice as high, applies to every token in the request. The US regional endpoint costs 10% more.
The xAI API sits at api.x.ai/v1 and its docs show the OpenAI SDK pointed there. One catch: xAI now calls Chat Completions a legacy endpoint, and new features come to the Responses API first. If your code uses client.chat.completions, it works today; plan the move to client.responses if you want new Grok features.
Mistral API
Mistral Large 4 costs $0.70 in and $2.10 out with a 1M-token context, and ships with open weights under the Mistral Ecosystem Open Weight License. Mistral Small 4, Apache 2.0 licensed, costs $0.15 and $0.60 with a 256K context; Ministral 3 3B costs $0.10 both ways. Batch processing halves the price. These are the prices on Mistral’s docs pricing table and model pages; the FAQ on the main pricing page still uses $0.50 and $1.50 as an example for Mistral Large, so check your console before you budget.
Mistral’s API has its own /v1/chat/completions endpoint, but the docs we read do not describe it as OpenAI-compatible. Expect to use Mistral’s SDK or test request by request.
Open-weight models through OpenRouter, Together, Groq or Fireworks
These four hosts run many models behind one OpenAI-style API. They differ in how they bill and what they run.
- OpenRouter is a router: one key for Claude, Gemini, Grok, DeepSeek and open models, 461 in its models API on November 9, 2026. It bills each model at the provider’s list price and takes 5.5% when you buy credits on the Standard plan. The Free plan offers 25+ free models and 50 requests a day.
- Together AI hosts open models such as Kimi K3 ($3 in, $15 out), GLM-5.3 ($1.40, $4.40), DeepSeek V4.1 Flash ($0.30, $1.20) and gpt-oss-120B ($0.15, $0.60). It also accepts the Responses API and Anthropic’s Messages API.
- Groq runs fewer models, fast: GPT OSS 120B at $0.15 and $0.60 and about 500 tokens a second, GPT OSS 20B at $0.075 and $0.30 and about 1,000 tokens a second, both with a 131,072-token context. Its Llama models are now listed as Contact Sales.
- Fireworks AI lists Kimi K3 at $3 and $15 and NVIDIA Nemotron 3.5 Lightning 30B A3B at $0.05 and $0.20. Batch mode takes 50% off, Spot mode 30% off with no guaranteed throughput, and US-only serving adds 50%.
Self-hosting: a free OpenAI API alternative
Run an open-weight model yourself and the per-token price is zero. Ollama serves an OpenAI-style API at localhost:11434/v1/ on your own computer; the SDK needs a key value, which Ollama ignores. vLLM, the server for Linux GPU machines, implements the Completions, Chat Completions and Responses APIs, and Chat Completions works only with models that have a chat template, its docs say.
What fits depends on memory: a 16 GB GPU runs 9B to 20B models, 24 to 32 GB the 27B to 30B class. Our guides to the best local LLM for your hardware and to building a local AI server give the model and the card for each budget.
How to switch from the OpenAI API
- 01Create a key in the new provider’s console and store it in an environment variable, never in code.
- 02Change the base URL and model name where you create the client, using the table above.
- 03Run your tests on tools, JSON output and streaming. These differ most: Groq rejects logprobs, Anthropic’s layer ignores strict schemas, Ollama has no stateful Responses.
- 04Re-check prompt caching and batch. Each provider prices them differently, and Anthropic’s OpenAI layer has no caching at all.
- 05Keep OpenAI as a fallback for a while; routers such as OpenRouter can switch providers per request.
FAQ
What is the best OpenAI API alternative?
It depends on the job. For coding, Claude Opus 5.5 leads FrontierCode 2.0 at $4 and $20 per million tokens. For low cost, DeepSeek V4.1 Flash is $0.15 and $0.60 off-peak. For one key to many models, OpenRouter. For privacy, a local Ollama server.
Is there a free OpenAI API alternative?
Yes. Gemini’s Flash and Flash-Lite models have a free tier, but Google uses free-tier content to improve its products. OpenRouter’s Free plan gives 50 requests a day on free models. A local model through Ollama costs nothing per token.
Can I use the OpenAI SDK with Claude?
Yes, with base URL api.anthropic.com/v1/ and a Claude key. Anthropic says the layer is for testing and comparing models, not long-term production, and it does not support prompt caching. Use the Anthropic SDK for production.
Is the Groq API OpenAI-compatible?
Mostly. Set the base URL to api.groq.com/openai/v1. Groq returns a 400 error for logprobs, logit_bias, top_logprobs and messages[].name, and n must be 1, its docs say.
Is the Grok API compatible with OpenAI?
Yes. The OpenAI SDK works with base URL api.x.ai/v1. xAI calls Chat Completions a legacy endpoint and brings new features to its Responses API first.
What is the cheapest OpenAI API alternative?
Small open models on hosting services cost least per token: Fireworks lists Nemotron 3.5 Lightning 30B A3B at $0.05 in and $0.20 out, Groq lists GPT OSS 20B at $0.075 and $0.30. Among the big labs, Claude Haiku 5.5 matches OpenAI’s GPT-6 Luna at $0.10 and $0.50.
Is there an open-source OpenAI API alternative?
Yes: run an open-weight model such as gpt-oss or Qwen on Ollama or vLLM, which serve an OpenAI-style API on your own machine. Mistral Small 4 is Apache 2.0 licensed and also sold through Mistral’s API.
Sources
- OpenAI, API pricing page, read November 9, 2026
- Anthropic, Claude API pricing, models overview and OpenAI SDK compatibility docs, read November 9, 2026
- Google, Gemini Developer API pricing and OpenAI compatibility docs, read November 9, 2026
- DeepSeek, Models and Pricing page and Your First API Call, read November 9, 2026
- xAI, API pricing, docs overview and Chat Completions (Legacy) page, read November 9, 2026
- Mistral AI, pricing page, docs pricing table and Mistral Large 4 and Small 4 model pages, read November 9, 2026
- OpenRouter, pricing page, quickstart and models API, read November 9, 2026
- Together AI, pricing page and OpenAI compatibility docs, read November 9, 2026
- Groq, supported models and OpenAI compatibility docs, read November 9, 2026
- Fireworks AI, pricing page and OpenAI compatibility docs, read November 9, 2026
- Ollama, OpenAI compatibility docs, read November 9, 2026
- vLLM, Online Serving docs, read November 9, 2026
- Artificial Analysis, FrontierCode 2.0 benchmark page, read November 9, 2026
Spotted a mistake? Write to support@gptx.io and we will check it.
Next up5 minDeepSeek API pricing$0.15Half price outside two weekday windows: DeepSeek’s peak and off-peak rates, cache hits and a monthly cost calculator.