Blog

Alternatives to OpenAI API in 2026: what each costs per job, and what breaks when you switch

Ramashankar S · · Updated · 17 min read

The main alternatives to OpenAI API are Anthropic's Claude, Google's Gemini, xAI's Grok, DeepSeek, Mistral and Moonshot's Kimi, plus open-weight models such as gpt-oss-120b on Groq, Together or Fireworks, and gateways such as OpenRouter that resell many of them. All of them accept the OpenAI SDK: change base_url, the API key and the model name, and a basic chat completion works. What differs is the price of a job, from $0.65 to $26.00 for the same 1,000 requests, and what stops working once you use more than basic chat.

Every price below was checked on the provider's own page on 5 November 2026. The sections cover the cost of one standard job on each, the code that switches between them, the features each compatibility layer drops, and which one fits which workload.

Alternatives to OpenAI API at a glance

The cost column is one standard job: 1,000 requests with 4,000 input tokens and 500 output tokens each, at list price, with no caching or Batch discount.

ProviderModel to try firstPrice per 1M tokens, in / out1,000 requestsOpenAI-compatible base URL
OpenAI (baseline)gpt-6.1-sol$2.00 / $10.00$13.00https://api.openai.com/v1
OpenAI (baseline)gpt-6.1-terra$1.00 / $5.00$6.50same
OpenAI (baseline)gpt-6-luna$0.10 / $0.50$0.65same
Anthropicclaude-opus-5-5$4.00 / $20.00$26.00https://api.anthropic.com/v1/
Anthropicclaude-sonnet-5-5$2.00 / $10.00$13.00same
Anthropicclaude-haiku-5-5$0.10 / $0.50$0.65same
Googlegemini-3.8-flash$0.75 / $3.75 to 31 Dec$4.88https://generativelanguage.googleapis.com/v1beta/openai/
Googlegemini-4-argon$2.00 / $10.00 to 30 Nov$13.00same
xAIgrok-4.7$2.00 / $6.00$11.00https://api.x.ai/v1
DeepSeekdeepseek-flash (V4.1 Flash)$0.30 / $1.20, half off-peak$1.80, or $0.90https://api.deepseek.com
Mistralmistral-large-4$0.70 / $2.10$3.85https://api.mistral.ai/v1
Moonshotkimi-k3.1-pro$2.00 / $10.00$13.00https://api.moonshot.ai/v1
Groq, Together, Fireworksgpt-oss-120b$0.15 / $0.60$0.90see the code below
OpenRouterany of the abovelist price, plus 5.5% when you pay+5.5%https://openrouter.ai/api/v1

Two prices change soon. Google's Gemini 4 Argon doubles to $4.00 / $20.00 on 1 December, which takes the standard job to $26.00, and Gemini 3.8 Flash doubles to $1.50 / $7.50 on 1 January 2027, or $9.75 a job. Google announced Gemini 4 Carbon on 28 October at the same $2 / $10 introductory price, but it isn't open to developers yet.

Cost of 1,000 requests with 4,000 input and 500 output tokens each, on three OpenAI models and ten alternatives, at list price

What one job really costs

The table above is token arithmetic: 4,000 × the input price plus 500 × the output price, per million tokens, times 1,000 requests. Three things move the real bill away from it.

  • Reasoning tokens are billed as output, and several alternatives think by default. Claude 5 models think by default even through Anthropic's compatibility layer, DeepSeek runs at high effort unless told otherwise, Kimi K3.1 Pro defaults to max, and Google says thinking can't be turned off on Gemini 3 models. Treat the 500 output tokens in the job above as a floor.
  • Cached input changes the input side. DeepSeek V4.1 Flash bills a cache hit at $0.006 per million at peak, about 2% of its input price, while Anthropic's OpenAI-compatible endpoint doesn't support prompt caching at all.
  • Long prompts reprice the whole request. Grok 4.7 goes to $4.00 / $12.00 once a prompt reaches 200,000 tokens, and Claude Haiku 5.5 goes to $0.50 / $2.50 above 100,000.

To see the effect of the first point, look at what a whole task costs when the model thinks as much as it wants. Artificial Analysis runs every model through the same evaluations and publishes its Intelligence Index with the cost of one task at the maker's prices:

Model (effort setting)Intelligence IndexCost per task
Claude Opus 5.5 (high)52$3.46
GPT-6.1 Sol (high)50$0.59
Gemini 4 Argon (high)50$7.68
Kimi K3.1 Pro46$3.68
Claude Sonnet 5.5 (high)42$1.64
GPT-6.1 Terra (high)42$0.26
Grok 4.7 (high)35$6.18
Gemini 3.8 Flash (high)31$7.77
Claude Haiku 5.5 (high)30$0.16
DeepSeek V4.1 Flash (high)29$0.46
Mistral Large 4 (high)26$2.06
GPT-6 Luna (high)21$0.07

Gemini 3.8 Flash is the clearest warning. Artificial Analysis prices it at $0.75 / $3.75, under 40% of Claude Sonnet 5.5's token prices, yet one task cost $7.77 against Sonnet's $1.64, because it spends far more tokens. The other lesson is less comfortable for this post: on this measure, OpenAI's own GPT-6.1 Sol and Terra are hard to beat. If cost is the only reason to leave, try a smaller OpenAI model first, as the cheapest way to use the OpenAI API explains.

Among the alternatives, Claude Haiku 5.5 and DeepSeek V4.1 Flash stand out on cost per task, Claude Opus 5.5 on the hardest work (it scores 59 at max effort, for $10.04 a task), and Kimi K3.1 Pro is the highest-scoring open-weight model on the board.

How much code changes when you switch

For a basic chat call, three values: the base URL, the key and the model name. This works with the OpenAI Python SDK 3.45.0 (released 4 November), and every base URL comes from the provider's own docs:

import os
from openai import OpenAI

# provider: (base_url, key variable, model, extra fields). Checked 5 Nov 2026.
PROVIDERS = {
    "openai":     ("https://api.openai.com/v1", "OPENAI_API_KEY", "gpt-6.1-terra", {}),
    "anthropic":  ("https://api.anthropic.com/v1/", "ANTHROPIC_API_KEY", "claude-sonnet-5-5", {}),
    "gemini":     ("https://generativelanguage.googleapis.com/v1beta/openai/", "GEMINI_API_KEY",
                   "gemini-3.8-flash", {"reasoning_effort": "low"}),
    "xai":        ("https://api.x.ai/v1", "XAI_API_KEY", "grok-4.7", {}),
    "deepseek":   ("https://api.deepseek.com", "DEEPSEEK_API_KEY", "deepseek-flash", {}),
    "mistral":    ("https://api.mistral.ai/v1", "MISTRAL_API_KEY", "mistral-large-4", {}),
    "moonshot":   ("https://api.moonshot.ai/v1", "MOONSHOT_API_KEY", "kimi-k3.1-pro",
                   {"reasoning_effort": "low"}),  # default is max
    "groq":       ("https://api.groq.com/openai/v1", "GROQ_API_KEY", "openai/gpt-oss-120b", {}),
    "together":   ("https://api.together.ai/v1", "TOGETHER_API_KEY", "openai/gpt-oss-120b", {}),
    "fireworks":  ("https://api.fireworks.ai/inference/v1", "FIREWORKS_API_KEY",
                   "accounts/fireworks/models/gpt-oss-120b", {}),
    "openrouter": ("https://openrouter.ai/api/v1", "OPENROUTER_API_KEY", "anthropic/claude-sonnet-5.5", {}),
    "aight":      ("https://api.getaight.ai/v1", "AIGHT_API_KEY", "claude-sonnet-5-5", {}),
}

# US$ per 1M tokens, input / output, from each pricing page on 5 Nov 2026
PRICES = {"openai": (1.00, 5.00), "anthropic": (2.00, 10.00), "deepseek": (0.30, 1.20)}


def ask(provider, messages, **client_options):
    base_url, key_var, model, extra = PROVIDERS[provider]
    client = OpenAI(base_url=base_url, api_key=os.environ[key_var], **client_options)
    return client.chat.completions.create(model=model, messages=messages, **extra)


def cost(provider, usage):
    price_in, price_out = PRICES[provider]
    return (usage.prompt_tokens * price_in + usage.completion_tokens * price_out) / 1e6


r = ask("deepseek", [{"role": "user", "content": "Summarize: the invoice was paid twice."}])
print(r.choices[0].message.content)
print(f"${cost('deepseek', r.usage):.6f}")  # overstates a little: cache hits cost less

Each URL above was checked against the SDK with a mocked HTTP transport: every client posts to <base_url>/chat/completions, which matches each provider's documented endpoint. The SDK also reads OPENAI_BASE_URL and OPENAI_API_KEY from the environment, so code that never sets them can be switched without editing a line.

If your code calls client.responses.create, the move is bigger. xAI, DeepSeek, Moonshot, Together, Fireworks and OpenRouter accept the Responses API, and Mistral has it in public preview. Anthropic's and Google's compatibility docs cover Chat Completions only. OpenAI itself says Chat Completions "remains supported", but GPT-6.1 Sol and Terra need the Responses API for tool calling. The plain guide to the OpenAI API covers both APIs from the OpenAI side.

For xAI, the Responses API is the one to use. Its docs call Chat Completions a legacy endpoint, and the same OpenAI client works:

import os
from openai import OpenAI

client = OpenAI(base_url="https://api.x.ai/v1", api_key=os.environ["XAI_API_KEY"],
                timeout=3600)  # xAI's example allows an hour for reasoning models
r = client.responses.create(model="grok-4.7", input="Classify this ticket: refund not received.",
                            store=False)  # xAI keeps responses for 30 days by default
print(r.output_text)

What breaks beyond basic chat

The compatibility layers accept the same request shape but not the same fields. This is what each provider's own documentation says, and the first thing that tends to fail:

ProviderStatus of its OpenAI-compatible chatResponses APIBatch discountFirst thing that breaks
AnthropicMainly for testing; "not considered" production-readyNo50% (native API)temperature below 1 returns 400 on Claude 4.7 and later
GoogleBetaNot documented50%Thinking can't be turned off on Gemini 3 models
xAILegacyYes, recommended20%No reasoning content returned on Chat Completions
DeepSeekSupportedYesNone; off-peak is half priceThinking is on by default; temperature is ignored while thinking
MistralSupportedPublic preview50%mistral-large-latest still points at Large 3, deprecated on 31 Oct
MoonshotSupportedYes40%reasoning_effort defaults to max; sampling fields are fixed
TogetherSupportedYesUp to 50% (own batch API)Model IDs are namespaced; the cached-token field moves by model
FireworksSupportedYes50%max_tokens is quietly trimmed to fit the context window
GroqSupportedNot checkedNot checkedUnsupported fields return 400
What changes when moving from the OpenAI API to each alternative: status, Responses API, Batch discount and the first thing that breaks

The details that cost people the most time:

  • Anthropic returns 400 for response_format: json_object, for n other than 1, and for forced tool use (tool_choice: "required") on Opus 5.5 and Sonnet 5.5. It silently ignores reasoning_effort, seed, logprobs and strict on tools, so a schema isn't guaranteed. Through this endpoint there's no prompt caching, which on Sonnet 5.5 means paying $2.00 for input that would cost $0.10 as a cache hit. For production, Anthropic points you to its own SDK. The temperature post covers the 400 in detail.
  • Google maps reasoning_effort onto Gemini's thinking levels and matches OpenAI's service_tier for Flex and Priority. Batch jobs can be created through the OpenAI library, but files have to be uploaded and downloaded with Google's own SDK. Gemini's context cache goes through extra_body.
  • DeepSeek switches thinking off with extra_body={"thinking": {"type": "disabled"}}. Its old model names (deepseek-v4-flash) still work but are served by V4.1 Flash.
  • Moonshot fixes temperature, top_p, n and the penalties on Kimi K3.1 Pro, so remove them. Vision input needs base64, not a public image URL.
  • Together accepts service_tier and store but ignores them, and returns 404 for OpenAI model names such as gpt-4o.

Tool-calling schemas are the other quiet difference. A schema OpenAI accepts can fail elsewhere, so run your real tool definitions through each candidate before you switch.

Each alternative in brief

Anthropic (Claude)

Claude Opus 5.5 ($4 / $20) tops this group on the hardest work, Sonnet 5.5 ($2 / $10) is the middle option, and Haiku 5.5 ($0.10 / $0.50 up to 100,000 prompt tokens) matches GPT-6 Luna's price. Claude 4.6 and later, except Haiku 5.5, bill the whole 1M-token context at the standard rate, and US-only processing costs 1.1x. Use the native SDK for caching and structured outputs.

Google (Gemini)

Gemini 3.8 Flash and 3.5 Flash-Lite ($0.30 / $2.50) have a free tier, where Google may use your data to improve its products. Gemini 4 Argon is the reasoning model, at $2 / $10 until 30 November. Check the token volume on your own prompts before trusting the low Flash price.

xAI (Grok)

Grok 4.7 costs $2 / $6 with a 500,000-token context, and its output price is 40% below Sonnet 5.5's. Its cached input costs $0.50, five times Sonnet 5.5's cache hit, which matters for agents that resend history.

DeepSeek

V4.1 Flash (deepseek-flash) is $0.30 / $1.20 at peak and half that off-peak. Peak is 01:00 to 04:00 and 06:00 to 10:00 UTC on weekdays, so a 9-to-5 workday on Eastern, Central, Mountain or Pacific time is off-peak. DeepSeek's privacy policy says it stores personal data in the People's Republic of China. The same model runs on Together and Fireworks at $0.30 / $1.20 around the clock.

Mistral

Mistral Large 4 ($0.70 / $2.10, 1M context, open weights) has been in public preview since 6 October. Mistral Small 4 ($0.15 / $0.60) is the low-cost option. Medium 3.5 and Large 3 were deprecated on 31 October and retire on 30 April 2027.

Moonshot (Kimi)

Kimi K3.1 Pro ($2 / $10, 1M context) has open weights and scores highest of the open-weight models on Artificial Analysis. Set reasoning_effort to low or high yourself, because max is the default. K2 models closed to new users on 31 October and retire by the end of December.

Open models on Groq, Together and Fireworks

gpt-oss-120b costs $0.15 / $0.60 on all three. The spread across hosts is wide: OpenRouter lists 26 endpoints for it, from $0.024 / $0.09 to $0.35 / $0.75, at different quantizations (fp4 to fp16), so test quality on the host you pick. Together's US-only endpoint costs 1.25x, and Fireworks charges 1.5x for US-only serving on select models. Groq's documentation and pricing pages weren't reachable for this post, so its price here is the one OpenRouter lists for Groq.

Gateways

A gateway puts many providers behind one key. OpenRouter charges list price plus 5.5% when you pay (8% on its Business plan). The OpenRouter alternatives post compares gateways on fees, refunds and data terms.

Which alternative for which workload

WorkloadFirst choiceWhyAlso test
High-volume chat, classification, extractionClaude Haiku 5.5$0.65 per 1,000 requests; 30 on the index at $0.16 a taskDeepSeek V4.1 Flash off-peak ($0.90), gpt-6-luna ($0.65)
Hardest reasoning and long agent runsClaude Opus 5.559 at max, the top score open to developersGemini 4 Argon, until its 1 December price rise
Mid-range quality at a mid-range priceClaude Sonnet 5.542 at $1.64 a taskKimi K3.1 Pro (46 at $3.68)
Prompts over 272,000 tokensClaude Sonnet or Opus 5.51M tokens at the standard rate, where OpenAI charges 2x inputGemini, Kimi K3.1 Pro, Mistral Large 4
Overnight jobs that can waitAny provider's Batch50% off at Anthropic, Google, Mistral and FireworksDeepSeek off-peak, half price with no queue
Data that must stay in the USClaude with US-only processing (1.1x)Same model, one parameter in the native APIOpen models on Together's US endpoint (1.25x)
Prototyping at no costGemini 3.8 Flash free tierFree, with your data used to improve Google's productsPaid tier once anything sensitive goes in
Several providers behind one keyA gatewayOne integration, one billDirect accounts for Batch work

Whatever you pick, measure before moving traffic: send 200 real requests to two or three candidates, read usage from each response, and compare cost per correct answer. The Claude alternatives for coding post shows that method on coding tasks.

For a side-by-side of the main LLM APIs on price, rate limits and data terms, see the best LLM API in 2026.

Where Aight fits

Aight is one OpenAI-compatible endpoint, https://api.getaight.ai/v1, for 138 models, including Claude Sonnet 5.5 and Opus 5.5, Grok 4.7, DeepSeek V4.1 Flash and gpt-oss-120b, at the makers' list prices for most. A $100 recharge costs $103 and adds $110 of balance, about $0.94 per $1 of list-price usage, so the standard job on Sonnet 5.5 comes to about $12.17 instead of $13.00.

Where another route costs less or works better:

  • Aight documents Chat Completions, embeddings and the model list only. There's no Batch API, so work that can wait for 24 hours costs half as much at the provider directly, and there's no Responses API.
  • DeepSeek V4.1 Flash is a flat $0.30 / $1.20 on Aight. Direct off-peak, the standard job costs $0.90 instead of $1.69.
  • Kimi K3 is $3.30 / $16.50, 10% above Moonshot. Kimi K3.1 Pro and Mistral Large 4 aren't listed yet.

What one key adds is control per key: a monthly cap, an expiry date and a list of allowed models, so a test of three alternatives can't spend past its limit. Setup is in the one API key post.

What developers run into when switching

  • Anthropic describes its own OpenAI layer as "not considered a long-term or production-ready solution for most use cases" (Anthropic docs, OpenAI SDK compatibility, checked 5 Nov 2026).
  • An app's OpenAI-compatible provider, pointed at Anthropic's endpoint, sent temperature: 0.7 on every call, so current Claude models returned 400 and only older ones worked (mixarr GitHub issue #94, 1 Nov 2026, link).
  • Tool schemas that OpenAI accepted were rejected by Gemini with 400 INVALID_ARGUMENT, because Gemini enforces a strict subset of OpenAPI 3.0 (ash_ai GitHub issue #209, 27 Jun 2026, link).
  • "Chat Completions is offered as a legacy endpoint." (xAI docs, checked 5 Nov 2026)
  • In the thread on Kimi K3.1 Pro's open weights, a commenter said Together appeared to have "double throughput of the Moonshot AI endpoint at the same price point" (Hacker News, 4 Nov 2026, link).
  • "Official Deepseek v4.1 Flash API costs are more than GPT 5.6 Luna." (Hacker News commenter, 10 Sep 2026, link). Per token it still holds against gpt-6-luna ($0.10 / $0.50), even at Flash's off-peak $0.15 / $0.60. What Flash buys is a higher score: 29 against 21 on Artificial Analysis.

FAQ

What is the best alternative to the OpenAI API?

It depends on the job. Claude Opus 5.5 scores highest among models open to developers, Claude Haiku 5.5 and DeepSeek V4.1 Flash cost least per task, and Kimi K3.1 Pro is the strongest open-weight model. On cost per task, OpenAI's GPT-6.1 Terra and Sol still compete with all of them, so compare against them too.

Is there a free alternative to the OpenAI API?

Google's Gemini API has a free tier for Gemini 3.8 Flash and the Flash-Lite models, and Google may use free-tier data to improve its products. Open-weight models such as gpt-oss-120b and Kimi K3.1 Pro are free to download and run on your own hardware, but the hardware isn't free.

Does the OpenAI Python SDK work with Claude or Gemini?

Yes. Set base_url to https://api.anthropic.com/v1/ or https://generativelanguage.googleapis.com/v1beta/openai/ and use that provider's key and model name. Anthropic positions its layer for testing and drops prompt caching, and Google labels its layer beta, so production code usually moves to the native SDK.

Which OpenAI API alternatives support the Responses API?

xAI, DeepSeek, Moonshot, Together, Fireworks and OpenRouter accept it, and Mistral has it in public preview. Anthropic's and Google's OpenAI compatibility docs cover Chat Completions only, so code built on client.responses.create needs rewriting for them.

What is the cheapest alternative to the OpenAI API?

For the standard job here, Claude Haiku 5.5 at $0.65 per 1,000 requests, the same as OpenAI's gpt-6-luna. DeepSeek V4.1 Flash off-peak and gpt-oss-120b on Groq, Together or Fireworks come to $0.90, and some smaller gpt-oss-120b hosts on OpenRouter charge a fraction of that.


Sources

Checked on 5 November 2026. Updated 17 November 2026: Aight's current model list.