OpenAI alternatives: which API to pick, and how to migrate without breaking anything
Seven APIs in detail, one per reason to leave, and a seven-step migration plan.
The short answer: Claude for the best quality on agents and code, Gemini to prototype for free, Mistral for a European vendor and open models, DeepSeek when your bill grows with volume, OpenRouter so you never depend on a single provider. The good news: almost all of them accept the OpenAI SDK, so a first test takes three lines. The bad news: those compatible layers drop options, and that's where migrations break. We compared the seven destinations in this guide against their official 2026 pricing. Looking for a ChatGPT subscription alternative instead? See our ChatGPT alternatives page.
The ranking is editorial: a sponsored spot is always labeled on its card, and no affiliate link changes a score.
Why teams leave the OpenAI API
OpenAI is still the reference: the widest catalog (text, image, audio, realtime) and docs everyone knows. People leave for other reasons: the pace of shutdowns, the price of the top models, data handling in Europe and depending on a single vendor. Six reasons, all checked in 2026.
Products shut down, models get retired
The Assistants API was shut down in 2026, with no automatic tool to migrate threads. Agent Builder, Evals and the reusable prompts API close at the end of 2026. The gpt-5 and o3 snapshots go at the end of 2026 too, then GPT-4o and GPT-4.1 in early 2027. Each shutdown forces work you didn't plan.
The top models are expensive
GPT-6 Astra costs $10 per million input tokens and $50 per million output tokens, gpt-5.5-pro $30 and $180. Claude Opus 5.5 is $4 and $20. Example: 20 million tokens in and 5 million out a month cost $450 on Astra, against $180 on Opus 5.5.
EU data residency takes paperwork, and costs 10% more
European data residency exists for eligible customers: abuse-monitoring approval, a retention amendment, a sales review. OpenAI promises neither approval nor a timeline. Regional endpoints also add 10% on recent models (released since March).
Spend caps that throttle growth
New accounts are capped: $100 a month on the free tier, $500 on Build ($5 in credits bought), $5,000 on Launch ($100). You need $500 in credits to reach $200,000. On the forum, the 429 "insufficient_quota" error comes up constantly: same code as a rate limit, but waiting doesn't fix it.
Your prompts stay 30 days at OpenAI
By default, abuse-monitoring logs keep your prompts and responses for up to 30 days, and the Responses API stores conversation state for 30 days. Zero data retention exists, but only with approval. In regulated industries, that's often what triggers the move.
One provider, one point of failure
When OpenAI slows down, your product slows down. One Hacker News developer described waiting "up to 10 minutes for the first token in the most egregious cases"; another left "because of latency (and availability)". Without a plan B, one vendor's outage becomes yours.
You're leaving because… go to…
The right OpenAI alternative depends on what's pushing you out. Usually only one line applies. Each card jumps to the full entry below.
Opus 5.5 at $4 / $20, less than half of GPT-6 Astra.
You want to test without payingGeminiFree tier on 3.8 Flash, no credit card.
You need a European vendorMistralFrench company, Apache 2.0 models you can self-host.
Your bill grows with volumeDeepSeek$0.15 / $0.60 off-peak, cached input at $0.006.
You never want one provider againOpenRouterOne key, every model, no markup on rates.
You want open models without serversTogether AIgpt-oss-120B at $0.15 / $0.60, OpenAI-compatible.
OpenAI API alternatives, one by one
For each API: why move there, who it's for, the catch, how to migrate from OpenAI, and what it costs. Prices come from official pages in 2026, in dollars per million tokens (input / output).
The APIs
Claude (Anthropic): when answer quality matters more than price
Closest on qualityWhy move to Claude. It's where most teams go when they leave OpenAI for agents, coding or long documents. All four models read a one-million-token context window and write up to 128,000 tokens in one response. Opus 5.5, Anthropic's recommended model for hard work, costs $4 per million input tokens and $20 per million output tokens. That's less than half of GPT-6 Astra ($10 and $50). One Hacker News developer put it in a single line: "just switched to Anthropic from OpenAI because of the ZDR guarantee" (zero data retention).
Who it's for. Products where a wrong answer is expensive: agents that chain tools, code generation, contract or report analysis.
Who it's not for. Apps that generate images or audio. Claude does neither. For a huge volume of simple tasks, use Haiku 5.5 rather than Opus, or look at DeepSeek.
The catch. Anthropic's OpenAI-compatible layer is for testing, not production, and the docs say so plainly. The function strict flag is ignored, response_format only accepts strict json_schema (a json_object request returns a 400), prompt caching doesn't work, and Opus 5.5 rejects forced tool calls.
How to migrate. For a first run, keep the OpenAI SDK and change three things: the base URL (api.anthropic.com/v1/), the key and the model name. If the output holds up, move to the native Anthropic SDK before you ship. That's what unlocks prompt caching, guaranteed structured outputs and half-price batch processing.
Pricing. Haiku 5.5: $0.10 / $0.50 (prompts up to 100,000 tokens). Sonnet 5.5: $2 / $10. Opus 5.5: $4 / $20. Fable 5.1: $10 / $50. Our Anthropic review walks through sample bills.
- From
- $0.10 / $0.50 (Haiku 5.5)
- Top model
- Opus 5.5, $4 / $20
- Best for
- agents, code, long docs
- Catch
- OpenAI layer is test-only
Gemini (Google): prototype for free, and go multimodal
Best free tierWhy move to Gemini. It's the only major API with a usable free tier on a recent model: Gemini 3.8 Flash and 2.5 Flash-Lite run without a credit card. Google also ships a documented OpenAI-compatible endpoint built for migrations. Gemini reads text, images, audio and video in the same request.
Who it's for. Prototypes, internal tools, low-volume n8n or Make automations, and teams already on Google Cloud.
Who it's not for. Customer data on the free tier. Google says free-tier traffic is used to improve its products. Paid traffic isn't.
The catch. Prices are moving up. Google has announced that Gemini 4 Argon goes from $2 / $10 to $4 / $20 per million tokens, and Gemini 3.8 Flash from $0.75 / $3.75 to $1.50 / $7.50, by early 2027. Gemini 2.5 Flash-Lite is deprecated and will be routed to 3.5 Flash-Lite at $0.30 / $2.50. Budget on the announced rates, not today's.
How to migrate. Point the OpenAI SDK at generativelanguage.googleapis.com/v1beta/openai/ with your Gemini key and a Gemini model name. Note that reasoning_effort and Gemini's own thinking settings can't be combined. For a new project, Google recommends its native API.
Pricing. 2.5 Flash-Lite $0.10 / $0.40, 3.8 Flash $0.75 / $3.75, 4 Argon $2 / $10 ($1 / $5 in batch), before the increase. Our Gemini review also covers the consumer plans.
- Free
- 3.8 Flash and 2.5 Flash-Lite
- Paid
- from $0.10 / $0.40
- Best for
- prototypes, multimodal
- Catch
- price increase announced
Mistral AI: the European option, with models you can self-host
The EU pickWhy move to Mistral. Mistral is a French company, and the only big lab on this list that ships recent open models under Apache 2.0 (Mistral Small 4, the Ministral 3 range). In practice, you call the API today, and if your legal team asks for it tomorrow, you run the same model on hardware you control. Prices are among the lowest for a frontier-class model: Large 4 costs $0.70 per million input tokens and $2.10 per million output tokens.
Who it's for. Companies selling into Europe that want a European vendor on the contract, public-sector teams, and anyone who wants to keep self-hosting on the table.
Who it's not for. The hardest reasoning tasks, where Claude Opus and GPT-6 Astra still come out ahead in most reports.
The catch. The free Experiment plan needs a verified phone number, and Mistral warns that requests on it may be used to train its models. Use a paid workspace for real data. The official SDK also renames methods (chat.complete instead of chat.completions.create).
How to migrate. Mistral publishes an OpenAI migration guide: base URL api.mistral.ai/v1, the same function-calling schema, and direct mappings (gpt-4o to mistral-large-latest, gpt-4o-mini to mistral-small-latest, text-embedding-3-small to mistral-embed). With LangChain or LlamaIndex, only the URL and model change. Your embeddings need recomputing.
Pricing. Small 4 $0.15 / $0.60, Codestral $0.30 / $0.90, Large 4 $0.70 / $2.10, Ministral 3 3B $0.10 / $0.10. Batch is half price, cached input up to 90% off. Need hands-on help? See our Mistral agency page.
- From
- $0.10 / $0.10 (Ministral 3 3B)
- Top model
- Large 4, $0.70 / $2.10
- Best for
- EU vendor, open weights
- Catch
- free tier may train models
DeepSeek: the lowest price, if you pick your hours
CheapestWhy move to DeepSeek. The bill. deepseek-flash costs $0.30 per million input tokens and $1.20 per million output tokens at peak, and half that off-peak. Cached input drops to $0.006. The API speaks both the OpenAI format (api.deepseek.com) and the Anthropic format, with a one-million-token context. On Hacker News, one user wrote: "Ever since I switched away from OpenAI to DeepSeek I never felt the need to go back."
Who it's for. Bulk jobs: tagging tickets, summarizing documents, enriching a database, feeding automation workflows.
Who it's not for. Regulated personal data without a legal review. DeepSeek is a Chinese company, so read its privacy policy with your compliance team before sending anything sensitive.
The catch. Peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC on weekdays. On the US East Coast, that lands overnight, which is good news: your working day is mostly off-peak. Web search and fetch cost $0.75 per 1,000 calls.
How to migrate. The shortest migration on this list: base URL, key, model name. Keep your eval set anyway (step 2 below), because the answer style changes.
Pricing. deepseek-flash $0.30 / $1.20 ($0.15 / $0.60 off-peak). deepseek-v4-pro $1.32 / $3.96 ($0.66 / $1.98 off-peak).
- From
- $0.15 / $0.60 off-peak
- Cache
- $0.006 per million
- Best for
- volume, automations
- Catch
- sensitive data, peak pricing
Grok (xAI): mid-range price, very long context
Context for lessWhy move to Grok. xAI publishes clear API pricing: Grok 4.3 costs $1.25 per million input tokens and $2.50 per million output tokens, with a one-million-token context. Output is four times cheaper than GPT-6.1 Sol ($10). Grok 4.7, the most capable model, is $2 and $6.
Who it's for. Output-heavy work (drafting, long summaries) where the output price drives the bill, and products that want live context from X.
Who it's not for. Teams that rely on a deep tool ecosystem around the API. It's thinner than OpenAI's, Anthropic's or Google's.
The catch. Context drops to 500,000 tokens on Grok 4.5 to 4.7, and users keep reporting factual errors and made-up links. Check every source it cites.
How to migrate. The API follows the OpenAI format: base URL, key, model. Test your function calls and JSON outputs first.
Pricing. grok-build-0.1 $1 / $2, Grok 4.3 $1.25 / $2.50, Grok 4.7 $2 / $6. Our Grok review covers the plans.
- From
- $1 / $2 (grok-build-0.1)
- Context
- 1 million (Grok 4.3)
- Best for
- long outputs
- Catch
- thinner ecosystem
OpenRouter: one key, so you never depend on one provider again
Keep your optionsWhy move to OpenRouter. It's not a model, it's a router. One key, one OpenAI-compatible endpoint, and you call Claude, Gemini, Mistral, DeepSeek, Grok or GPT by changing a string. OpenRouter adds no markup on inference: you pay the provider's rate. In developer threads, that's the recurring point: comparing five models on the same prompt is worth more than the fee.
Who it's for. Teams that want to compare before they commit, teams that need a fallback when a provider goes down, and n8n or Make workflows that pick a model per task.
Who it's not for. Anyone who needs a data processing agreement signed directly with the model vendor. You add a middleman.
The catch. The fee is on credit purchases: 5.5% pay as you go, 8% on Business. Free models are capped at 50 requests a day, 1,000 once you've bought $10 of credits. Bring your own keys and it's free up to $25,000 of monthly usage, then 5%.
How to migrate. OpenRouter's base URL, your key, and vendor-prefixed model names. It's also the easiest way to keep OpenAI as a fallback during the switch.
Pricing. Each model's own rate, plus 5.5% on top-ups.
- Fee
- 5.5% on top-ups
- Free
- 50 requests a day
- Best for
- comparing, fallback
- Catch
- one more middleman
Together AI: open models without running servers
Hosted open sourceWhy move to Together. You want open models (gpt-oss, Qwen, DeepSeek, Kimi) without renting GPUs. Together serves them behind an OpenAI-compatible API, pay as you go. gpt-oss-120B, OpenAI's own open model, costs $0.15 per million input tokens and $0.60 per million output tokens there: a way to keep an OpenAI model without depending on its platform.
Who it's for. Teams that want to change hosts without changing models, and teams preparing to self-host later.
Who it's not for. Anyone relying on OpenAI-style Batch and Files APIs. Together doesn't expose them under /v1, and there's no moderation endpoint.
The catch. The catalog changes fast, and an open model doesn't always match the best closed model on complex tasks. Run your evals.
How to migrate. OpenAI SDK, base URL api.together.ai/v1, Together key. Response IDs use Together's own format, so don't parse them as OpenAI IDs.
Pricing. gpt-oss-120B $0.15 / $0.60, Qwen3.8 Flash $0.15 / $0.47, DeepSeek V4 Pro $1.32 / $3.96, Kimi K3 $3 / $15.
- From
- $0.15 / $0.47 (Qwen3.8 Flash)
- OpenAI model
- gpt-oss-120B, $0.15 / $0.60
- Best for
- open models
- Catch
- no Batch or Files API
The 7 alternatives compared
Our default picks: Claude for quality, DeepSeek for volume, Mistral for a European vendor. For scale, take 20 million tokens in and 5 million out per month: about $450 on GPT-6 Astra, $90 on GPT-6.1 Sol, $180 on Claude Opus 5.5, $24.50 on Mistral Large 4, and $12 on DeepSeek Flash at peak ($6 off-peak).
| Price per million tokens (input / output) | Compatibility and migration | |
|---|---|---|
| OpenAIWhere you start | GPT-6 Luna $0.10 / $0.50; GPT-6.1 Sol $2 / $10; GPT-6 Astra $10 / $50 | Reference; batch at half price; +10% for regional residency |
| Claude (Anthropic)Quality | Haiku 5.5 $0.10 / $0.50; Opus 5.5 $4 / $20 | OpenAI layer for tests; native SDK for production |
| Gemini (Google)Free and multimodal | 2.5 Flash-Lite $0.10 / $0.40; 4 Argon $2 / $10 (increase announced) | Documented OpenAI-compatible endpoint; free tier |
| Mistral AIEuropean vendor | Ministral 3 3B $0.10 / $0.10; Large 4 $0.70 / $2.10 | Official migration guide; recompute embeddings |
| DeepSeekCheapest | Flash $0.15 / $0.60 off-peak, $0.30 / $1.20 peak | OpenAI and Anthropic formats; URL, key, model |
| Grok (xAI)Long context | grok-build-0.1 $1 / $2; Grok 4.3 $1.25 / $2.50 | OpenAI format; test function calls |
| OpenRouterRouter | Provider rates plus 5.5% on top-ups | OpenAI-compatible; cross-provider fallback |
| Together AIOpen models | gpt-oss-120B $0.15 / $0.60; Kimi K3 $3 / $15 | OpenAI-compatible; no Batch or Files under /v1 |
Prices in USD before tax, short context, subject to change. Always check against your own volume.
Leaving the OpenAI API in seven steps
Order matters. Each step protects something: answer quality, your data, your ability to roll back.
The steps
List everything your code asks OpenAI for
Day 1Find every call in your code and workflows: Chat Completions, Responses, Assistants, embeddings, audio, images, moderation, fine-tuning. For each one, note the model, monthly token volume and the options you use (response_format, function calling, stream, seed).
Why? Alternatives handle chat and function calling well, but rarely audio, images and fine-tuning in one place. This list tells you whether you're moving everything or just text.
- Time
- half a day
- Output
- one row per call
Build an eval set from your real prompts
QualityTake 50 to 100 real, anonymized requests along with the answer you considered good. Run them through two or three candidates at a fixed temperature and score three things: quality, latency and real cost, thinking tokens included.
A prompt tuned for GPT over months isn't neutral. Anthropic says so in its own docs: expect to rework it. The eval set shows you before your users do.
- Size
- 50 to 100 requests
- Measure
- quality, latency, cost
Put a gateway between your code and the provider
ArchitectureMove the base URL, key and model name into environment variables. Better yet, route through a gateway, self-hosted LiteLLM or OpenRouter, that speaks the OpenAI format and forwards to any provider.
This is the step that makes everything else reversible. When a provider goes down or raises prices, you switch with one config line instead of a new project.
- Tools
- LiteLLM, OpenRouter
- Win
- one-line rollback
Fix JSON outputs and function calls
GotchasThis is where "three-line" migrations break. On Anthropic's compatible layer, strict is ignored and json_object returns a 400. On Google's, reasoning_effort can't be combined with Gemini's thinking settings. Validate every JSON response in your code, whatever the provider.
If a critical function depends on a guaranteed schema, use the provider's native SDK for that call and keep the compatible layer for the rest.
- Test
- JSON, tools, streaming
- Rule
- validate every output
Recompute embeddings, and never mix the two
DataIf you run RAG (searching your documents before answering), your OpenAI vectors can't be read by another embedding model. Dimensions often differ, and even at the same size the two spaces don't compare.
Build a new index next to the old one, recompute everything, compare search results on your eval set, then switch. You can also keep embeddings on OpenAI and only move generation. That's often the best trade-off.
- Risk
- search returns nonsense
- Option
- keep OpenAI embeddings
Shift traffic in stages, with OpenAI as fallback
ProductionSend 5% of traffic to the new provider, then 25%, then 100%, watching errors, latency and user feedback. Keep OpenAI as an automatic fallback for at least one billing cycle.
Watch the rate limits on the new account: fresh accounts usually start low. On OpenAI, the Build tier already caps spend at $500 a month. Check the equivalent at your destination before sending it all your traffic.
- Stages
- 5%, 25%, 100%
- Fallback
- one billing cycle
Cut the bill once you've switched
SavingsTurn on what the compatible layer didn't support: prompt caching (up to 90% off input on Mistral, $0.006 per million on DeepSeek), and half-price batch processing on Anthropic, Mistral and Google for anything that isn't real time.
Only then revoke unused OpenAI keys and check your prepaid credit balance before closing the account.
- Batch
- half price
- Last step
- revoke old keys
Is your tool missing from this page? Email us: hello@hackceleration.com
What makes an OpenAI migration fail
The same mistakes show up in developer threads and vendor guides. None is dramatic. Each costs more than the time it would have taken to avoid it.
Comparing input prices and ignoring output
Output often costs five times input, and reasoning models bill thinking tokens as output. An app that writes a lot pays mostly for output. Always price on your own input-to-output ratio, measured on your eval set.
Shipping the compatible layer to production
Anthropic reserves it for testing, and Google recommends its native API for new projects. You lose prompt caching, format guarantees and thinking controls. Use it to compare, then move critical calls to the native SDK.
Sending customer data to a free tier
Gemini's free tier and Mistral's Experiment plan may be used for training. For a prototype with real data, switch to a paid account right away. A few dollars usually covers it.
Budgeting on a price that's about to change
Google has announced it will double Gemini 4 Argon and 3.8 Flash prices by early 2027, and OpenAI lists time-limited promotional rates. Budget on the announced rates, not today's.
Running DeepSeek batches at peak
A DeepSeek job run during peak hours (01:00 to 04:00 and 06:00 to 10:00 UTC on weekdays) costs double. In Europe, that's the morning. Schedule background jobs off-peak, or use batch APIs elsewhere.
Moving everything at once
Failed migrations change chat, embeddings and audio on the same day. Move the most expensive call first, keep OpenAI as fallback, and touch embeddings last. For the OpenAI side, our OpenAI training and ChatGPT review give context.
- Every OpenAI call is listed with its model and volume
- The eval set has at least 50 real requests
- Base URL, key and model live in config
- Every JSON output is validated in your code
- Embeddings have a new index, compared before switching
- OpenAI stays as fallback for one billing cycle
OpenAI alternatives: frequently asked questions
What's the best free alternative to the OpenAI API?
Gemini, for prototyping: 3.8 Flash and 2.5 Flash-Lite have a free tier with no card. Mistral's free Experiment plan works too, with a verified phone number. Either way, free-tier requests may be used to improve the models, so keep customer data out. OpenRouter also gives you 50 requests a day on its free models.
Is there an open-source alternative to OpenAI?
Yes. Mistral Small 4 and the Ministral 3 models are Apache 2.0, and OpenAI's own gpt-oss-120B is open too. You can run them through Together AI ($0.15 / $0.60 per million tokens for gpt-oss-120B) or on your own hardware once volume justifies it.
Do I need to rewrite my code to leave OpenAI?
Rarely for a test. DeepSeek, Mistral, Gemini, Grok, Together and OpenRouter accept the OpenAI SDK: change the base URL, key and model. Production is another story: JSON outputs, forced tool calls and prompt caching behave differently. Expect a partial rewrite if you move to Anthropic.
I want a ChatGPT alternative, not an API. Where should I look?
This page is about the developer API. For subscriptions, Claude Pro is $20 a month, Google AI Pro $19.99 and Le Chat Pro $14.99, against $20 for ChatGPT Plus. Our ChatGPT alternatives page compares them, and our Claude review covers the closest one.
Does OpenAI train on data sent through its API?
Not by default, unless you opt in. But OpenAI keeps abuse-monitoring logs for up to 30 days, and they can include your prompts and responses. Zero data retention exists, subject to approval. The bigger trap is elsewhere: Gemini's and Mistral's free tiers may be used for training.
Is Claude's API more expensive than OpenAI's?
Not at the top end. Opus 5.5 costs $4 / $20 per million tokens against $10 / $50 for GPT-6 Astra. At the low end they're level: Haiku 5.5 and GPT-6 Luna both cost $0.10 / $0.50.
Can I keep OpenAI and add another provider?
Yes, and it's often the best plan. A gateway (LiteLLM, OpenRouter) sends each task to the right model: DeepSeek for volume, Claude for agents, OpenAI for audio or images. Our OpenAI agency page shows how we set this up inside existing workflows.
How long does a migration off the OpenAI API take?
A day for a first test on a single call. Two to four weeks for a production app: inventory, eval set, JSON fixes, embedding recompute, then a staged rollout. Prompt rework almost always takes longer than the code.
Get the next migration guide in your inbox
One tool to leave, one destination, one migration plan. Nothing else.