Direct answer: how to migrate to an OpenAI-compatible LLM API
To migrate an existing OpenAI application to Inference.net, change exactly three values: set base_url (baseURL in Node) to https://api.inference.net/v1 (or https://us.api.inference.net/v1 for US-only hosted inference), swap api_key to your INFERENCE_API_KEY, and set model to a live model ID from GET https://api.inference.net/v1/models (such as deepseek-v4.1-flash-1017, glm-5.3, or moonshotai/kimi-k3.1-pro). Your existing messages, tools, response_format, streaming loops, and usage parsing stay unchanged. Applications built on the Anthropic SDK can make the same 3-line swap to https://api.inference.net using native POST /v1/messages with zero proxy.
Endpoint map: one key across four wire formats
| Wire protocol | Global base URL | US-only hosted base URL | Notes |
|---|---|---|---|
OpenAI Chat Completions (/v1/chat/completions) | https://api.inference.net/v1 | https://us.api.inference.net/v1 | Standard OpenAI Python and TypeScript SDKs |
OpenAI Responses (/v1/responses) | https://api.inference.net/v1 | https://us.api.inference.net/v1 | Supported across live catalog models and Codex CLI |
Native Anthropic Messages (/v1/messages) | https://api.inference.net | https://us.api.inference.net | Omit /v1; SDKs append /v1/messages automatically |
OpenAI Batch & Files (/v1/batches, /v1/files) | https://batch.inference.net/v1 | Not applicable | Up to 1,000,000 requests/file, 25%+ discount; requires credit key with ZDR disabled |
3-line drop-in migration snippets
Create a key in API keys (or register first) and export INFERENCE_API_KEY.
1. OpenAI Python SDK
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.inference.net/v1", # Line 1: swap base URL
api_key=os.environ["INFERENCE_API_KEY"], # Line 2: swap API key
)
response = client.chat.completions.create(
model="deepseek-v4.1-flash-1017", # Line 3: pick a live model ID
messages=[{"role": "user", "content": "Write a SQL query to find duplicate emails."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in response:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)2. OpenAI Node / TypeScript SDK
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.inference.net/v1", // Line 1: swap base URL
apiKey: process.env.INFERENCE_API_KEY, // Line 2: swap API key
});
const stream = await client.chat.completions.create({
model: "deepseek-v4.1-flash-1017", // Line 3: pick a live model ID
messages: [{ role: "user", content: "Write a SQL query to find duplicate emails." }],
stream: true,
stream_options: { include_usage: true },
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}3. Native Anthropic SDK (/v1/messages)
Inference.net translates Anthropic Messages payloads directly into open-weight serverless models without a middleman proxy:
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.inference.net", // Line 1: omit /v1
apiKey: null,
authToken: process.env.INFERENCE_API_KEY, // Line 2: pass Inference.net key
});
const message = await client.messages.create({
model: "deepseek-v4.1-flash-1017", // Line 3: pick any messages-capable model
max_tokens: 1024,
messages: [{ role: "user", content: "Summarize the tradeoffs of cursor pagination." }],
});
console.log(message.content);4. LiteLLM Python SDK and Proxy
Prefix every Inference.net model ID with openai/ so LiteLLM routes it through its OpenAI-compatible adapter and strips only the leading openai/ prefix:
import os
from litellm import completion
response = completion(
model="openai/deepseek-v4.1-flash-1017",
api_base="https://api.inference.net/v1",
api_key=os.environ["INFERENCE_API_KEY"],
messages=[{"role": "user", "content": "Explain idempotency keys in two sentences."}],
)
print(response.choices[0].message.content)For multi-model fallback routing, health checks, and additional_drop_params: ["prompt_cache_key"] on DeepSeek routes, see the full LiteLLM integration guide.
5. Plain curl
curl -sS https://api.inference.net/v1/chat/completions \
-H "Authorization: Bearer $INFERENCE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4.1-flash-1017",
"messages": [{"role": "user", "content": "Return a JSON object with status ok."}],
"response_format": {"type": "json_object"}
}'Live catalog pricing: drop-in model replacements
Every model ID, context limit, and per-1M-token rate below was verified directly against GET https://api.inference.net/v1/models on 2026-12-06. All listed models expose chat, responses, and messages endpoints:
| Model ID | Best migration role | Context / max output | Fresh input ($/1M) | Cached read ($/1M) | Output ($/1M) | US-hosted ZDR |
|---|---|---|---|---|---|---|
deepseek-v4.1-flash-1017 | Default coding, agents, high-volume chat | 1,040,000 / 393,216 | $0.08 | $0.007 | $0.635 | Yes (us.api.inference.net) |
glm-5.3-flash | Output-heavy generation, image + video | 1,048,576 / 262,144 | $0.10 | $0.03 | $0.35 | Yes (us.api.inference.net) |
glm-5.3 | Deep reasoning and long code generation | 1,048,576 / 943,718 | $0.084 | $0.079 | $3.00 | Yes (us.api.inference.net) |
moonshotai/kimi-k3.1-pro | Frontier open-weight reasoning and architecture | 1,048,576 / 1,048,576 | $1.80 | $0.198 | $9.00 | Yes (us.api.inference.net) |
inference-net/schematron-v2-turbo | High-throughput HTML-to-JSON extraction | 128,000 / 8,192 | $0.03 | $0.03 | $0.15 | Yes (us.api.inference.net) |
gpt-4.1 | Reference closed-weight baseline | 1,047,576 / 32,768 | $2.00 | $0.50 | $8.00 | External route |
gpt-5.4 | Frontier closed-weight baseline | 1,050,000 / 128,000 | $2.50 (<= 272K in)* | $0.25 (<= 272K in)* | $15.00 (<= 272K in)* | External route |
claude-sonnet-4-6 | Anthropic baseline on one key | 1,000,000 / 128,000 | $3.00 | $0.30 | $15.00 | External route |
*gpt-5.4 base rates apply below 272,000 input tokens. Requests above 272,000 input tokens bill at the long-context tier: $5.00/1M input, $0.50/1M cached read, and $22.50/1M output. Browse all live models, capabilities, and rate sheets in the model catalog.
Production migration checklist (avoiding 4 common gotchas)
- Match prompt-cache parameters per family: Pass
prompt_cache_keyonglm-5.3,glm-5.3-flash, and OpenAI models, and omitprompt_cache_keyondeepseek-v4.1-flash-1017anddeepseek-v4.1-flash(DeepSeek uses implicit prefix caching and may reject requests withprompt_cache_key). See the Prompt Caching Guide. - Respect temperature behavior on reasoning models:
glm-5.3andglm-5.3-flashalways think and sample at1.0regardless of yourtemperatureparameter.deepseek-v4.1-flash-1017samples at1.0when thinking is active and respects yourtemperaturewhenreasoning_effortis set to"none". - Verify ZDR and regional endpoints before cutover: Eligible Inference.net-hosted, non-ad models (
deepseek-v4.1-flash-1017,glm-5.3,glm-5.3-flash,moonshotai/kimi-k3.1-pro,inference-net/schematron-v2-turbo) run with default Zero Data Retention and accept traffic onhttps://us.api.inference.net/v1. Third-party-routed models (gpt-5.4,claude-sonnet-4-6) return400 region_not_supportedonus.api.inference.netand follow upstream retention terms onapi.inference.net. - Use dedicated Batch base URL for offline jobs: Route OpenAI Batch and Files calls to
https://batch.inference.net/v1using a credit-billing API key with team ZDR disabled (ZDR-enabled teams receive403 Forbiddenon/v1/batchesand/v1/files). See Batch API docs.
Need to keep an existing OpenAI or Anthropic key during rollout?
If you want unified logging, task tagging (x-inference-task-id, x-inference-environment), and gradual traffic shifting before moving billing over, pass x-inference-provider and x-inference-provider-api-key headers to https://api.inference.net/v1 to proxy through the Inference.net Gateway with your own provider key. Gateway passthrough requires a credit-billing Inference.net API key; Inference Pass plan keys do not support x-inference-provider / x-inference-provider-api-key passthrough. See API quickstart.
Frequently asked questions
Do OpenAI tools, response_format, and streaming work without code changes?
Yes. Tool calling (tools and tool_choice), structured outputs (response_format with json_object or json_schema), and Server-Sent Events streaming (stream: true with stream_options: {"include_usage": true}) follow the standard OpenAI schema on supported catalog models.
Why did my Anthropic SDK call return 404 after changing baseURL?
The Anthropic SDK appends /v1/messages automatically. Set baseURL to https://api.inference.net (or https://us.api.inference.net) without a trailing /v1.
How do I verify which models are supported on us.api.inference.net?
Look for the US badge in the model catalog or inspect hosted US models such as deepseek-v4.1-flash-1017, glm-5.3, glm-5.3-flash, moonshotai/kimi-k3, moonshotai/kimi-k3.1-pro, and inference-net/schematron-v2-turbo. Requests sent to us.api.inference.net stay in US data centers end-to-end and never fall back to external providers.
Can I connect coding editors and frameworks without custom code?
Yes. Ready-to-copy configs for Claude Code, Cursor, Cline, Roo Code, OpenCode, LiteLLM, LangChain, and Vercel AI SDK are documented in the Integrations hub.
Related resources
- Model catalog & hubs: Full Model Catalog · DeepSeek API · Kimi API · GLM API · Schematron API
- Integrations & docs: Integrations Hub · API Quickstart · Anthropic SDK · Batch API
- Pricing & comparison guides: Prompt Caching Guide · Cheapest LLM API · Inference.net vs OpenAI API · Inference.net vs OpenRouter
Swap your base URL and ship in minutes
Create a free Inference.net API key to call DeepSeek V4.1 Flash, GLM-5.3, Kimi K3.1 Pro, and Schematron through the OpenAI and Anthropic SDKs you already use.
Create API key