Coding agents overview
Use Inference.net models as the model in Claude Code, Codex, OpenCode, Cursor, or any OpenAI- or Anthropic-compatible client.
Any coding agent that accepts a custom OpenAI- or Anthropic-compatible
provider can use Inference.net models. You need an Inference.net API key, the
base URL, and a model ID from GET /v1/models.
| Setting | Value |
|---|---|
| Base URL (OpenAI-compatible) | https://api.inference.net/v1 |
| Base URL (US-only) | https://us.api.inference.net/v1 |
| Base URL (Anthropic Messages) | https://api.inference.net |
| API key | Your Inference.net API key, sent as Authorization: Bearer <key> or x-api-key: <key> (Authorization takes precedence if both are sent) |
| Model ID | Any id from GET https://api.inference.net/v1/models |
Not every model is served in the US on the US-only base URL. Models with a US badge in the Regions column of the model catalog are.
Agent guides
Each guide covers setup, model selection, status, and disconnecting for one agent:
To use your own key instead of fast, follow the steps below.
Set your API key
Create a key on the API keys page of the dashboard, then export it:
export INFERENCE_API_KEY=<your-api-key>Restart your agent after you set the key. Some clients (OpenCode included)
cache their provider configuration, and keep an empty key if the variable was
missing on first load. The result is a Missing Authorization Bearer token
error. See API keys for scoping and authentication details.
Model settings from /v1/models
GET /v1/models needs no API key. Send a pay-as-you-go key to also include your
team's dedicated deployments, or send an Inference Pass plan key to filter the
response (and GET /v1/models/{id}) to models included in your plan. It returns
the values most clients ask for when you add a custom model:
curl -s https://api.inference.net/v1/models \
| jq '.data[] | select(.id == "deepseek-v4.1-flash-1017")'{
"id": "deepseek-v4.1-flash-1017",
"context_length": 1040000,
"max_completion_tokens": 393216,
"max_output_tokens": 393216,
"supports_tools": true,
"reasoning_efforts": ["none", "low", "high", "max"],
"input_modalities": ["text", "image"],
"output_modalities": ["text"],
"supported_endpoints": ["chat", "responses", "messages"]
}/v1/models field | Client setting |
|---|---|
id | Model ID |
context_length | Context limit |
max_completion_tokens | Max output tokens |
max_output_tokens | Same value as max_completion_tokens, for clients that read this name |
supports_tools | Tool calls. Coding agents need true. |
reasoning_efforts | Reasoning effort levels. none turns reasoning off. See Reasoning. |
input_modalities | Image input |
output_modalities | Output modalities (for example, ["text"]) |
supported_endpoints | APIs the model accepts. The gateway converts between /v1/chat/completions, /v1/messages, and /v1/responses, so any chat model works in Claude Code and Codex. |
pricing | Cost per token, in USD. Multiply by 1,000,000 for per-million-token prices. |
requires_approved_access | Present and true only on privileged models. Your team needs approved access to call the model. |
access_status | Present only on privileged models: none, pending, approved, rejected, revoked, or terms_required. Only approved can call the model. Send your API key to get your team's status; without a key it is always none. |
Privileged models
A call to a privileged model without approval returns HTTP 403 with error type
model_access_required:
{
"error": {
"message": "Model '<model-id>' requires approved access. Request access at https://inference.net/model-access/<model-id>",
"type": "model_access_required",
"code": "model_access_required"
}
}Match on error.type. Some responses do not include code. To request access,
see Privileged model access.
Tool calls
Coding agents need tool calls. Pick a model with supports_tools: true in
GET /v1/models (see Function calling).
Configure an agent by hand
OpenCode
Add a provider to opencode.json (in your project, or globally at
~/.config/opencode/opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"model": "inference/deepseek-v4.1-flash-1017",
"small_model": "inference/deepseek-v4.1-flash-1017",
"provider": {
"inference": {
"name": "Inference.net",
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.inference.net/v1",
"apiKey": "{env:INFERENCE_API_KEY}",
"headers": {
"x-inference-task-id": "opencode"
}
},
"models": {
"deepseek-v4.1-flash-1017": {
"name": "DeepSeek V4.1 Flash 1017",
"attachment": true,
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"limit": { "context": 1040000, "output": 393216 },
"tool_call": true,
"reasoning": true,
"variants": {
"none": { "reasoning_effort": "none" },
"low": { "reasoning_effort": "low" },
"high": { "reasoning_effort": "high" },
"max": { "reasoning_effort": "max" }
}
}
}
}
}
}limit comes from context_length and max_completion_tokens. Set
"attachment": true and "modalities" from input_modalities and
output_modalities. Add one variant for each value in reasoning_efforts.
Press Ctrl+T in OpenCode to switch between them.
Use the provider key. OpenCode 1.x ignores the newer providers key, and
OpenCode 2 also reads provider.
Claude Code
Claude Code uses the Anthropic Messages API. Use the base URL without /v1:
export ANTHROPIC_BASE_URL=https://api.inference.net
export ANTHROPIC_AUTH_TOKEN="$INFERENCE_API_KEY"
export ANTHROPIC_MODEL='deepseek-v4.1-flash-1017[1m]'
export ANTHROPIC_DEFAULT_OPUS_MODEL='deepseek-v4.1-flash-1017[1m]'
export ANTHROPIC_DEFAULT_SONNET_MODEL='deepseek-v4.1-flash-1017[1m]'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='deepseek-v4.1-flash-1017[1m]'
export CLAUDE_CODE_SUBAGENT_MODEL='deepseek-v4.1-flash-1017[1m]'
claude- Set every model variable. Claude Code sends background tasks, subagents, and
/modelchoices to these overrides. Older Claude Code releases also readANTHROPIC_SMALL_FAST_MODELfor background tasks; set it to the same ID asANTHROPIC_DEFAULT_HAIKU_MODELif your version reads it. Leaving an override unset sends requests to a Claude model ID, which fails or bills at Claude prices. - For a model with a context of 1M or more, add
[1m]to the model ID, as above. The gateway strips[1m]server-side before routing. Quote the value: zsh reads an unquoted[1m]as a glob. For a smaller context, setCLAUDE_CODE_MAX_CONTEXT_TOKENSto the model'scontext_lengthinstead. Otherwise Claude Code assumes 200K. - The
/v1/messagesendpoint accepts Anthropicthinking(adaptiveandenabled) andoutput_config.effort, translating them into the model's reasoning settings and streamingthinking_deltablocks back. - You can authenticate with either
ANTHROPIC_API_KEY(x-api-key) orANTHROPIC_AUTH_TOKEN(Authorization: Bearer). If both headers are sent,Authorizationtakes precedence for Inference.net authentication;x-api-keyis stripped on Inference.net-hosted requests, and on external-provider (BYOK) gateway requests it is forwarded unchanged unless a provider credential replaces it.
Codex
Add a provider to ~/.codex/config.toml:
model = "deepseek-v4.1-flash-1017"
model_provider = "inference"
model_context_window = 1040000
model_max_output_tokens = 393216
model_reasoning_effort = "high"
[model_providers.inference]
name = "Inference.net"
base_url = "https://api.inference.net/v1"
env_key = "INFERENCE_API_KEY"
wire_api = "responses"
http_headers = { "x-inference-task-id" = "codex" }Take model_context_window, model_max_output_tokens, and
model_reasoning_effort from context_length, max_completion_tokens, and
reasoning_efforts. For a model Codex does not know, it uses a fallback system
prompt and tool set. fast codex on also writes a Codex model catalog so that
Inference.net models get Codex's standard prompt and tools.
Other OpenAI-compatible clients
Cursor, Cline, Roo Code, Continue, Windsurf, and other clients with an "OpenAI-compatible" provider option need three values:
- Base URL:
https://api.inference.net/v1 - API key: your Inference.net API key
- Model: an
idfromGET /v1/modelswithsupports_tools: true
Fill in context and output limits from the field table. The Cursor, Hermes, and OpenClaw guides walk through those clients.
Use an Inference Pass plan key
An Inference Pass plan works in every verified agent on this page. Use the inf CLI to connect, check status, and repair agent configs automatically:
inf auth login
inf pass on claude # Claude Code
inf pass on opencode # OpenCode (also supports codex, pi, grok)
inf pass status # Show active plan, lane, usage remaining %, and connected agents
inf pass doctor # Verify and self-heal keys, models, and drifted configs (--check for read-only)
inf pass off claude # Restore previous settingsDesktop apps (inf pass proxy and Claude Desktop)
Run a local loopback-only reverse proxy (127.0.0.1) for GUI apps such as Claude Desktop, Cursor, Windsurf, or Zed:
inf pass proxy- Claude Desktop: Run
inf pass on claude-desktopto write a native third-party gateway profile pointing athttp://127.0.0.1:4141, then startinf pass proxy. Runinf pass off claude-desktopto restore the pre-setup config snapshot (note: restoring a snapshot reverts edits made to Claude Desktop's managed config files after setup; if no snapshot exists, it switches back to standard mode and removes only the Inference Pass profile). - Other desktop apps: Use
http://127.0.0.1:4141(Anthropic) orhttp://127.0.0.1:4141/v1(OpenAI-compatible) with any placeholder API key. The proxy injects your Inference Pass key locally, maps Claude model tiers to models included in your plan, and rotates revoked or inactive keys automatically.
Manual setup with a plan key
- Open My plans and create a key for your plan, then use it as
INFERENCE_API_KEY. - Call
GET /v1/modelswith your plan key to see the models included in your plan (bothGET /v1/modelsandGET /v1/models/{id}filter to plan-eligible models; retrieving an excluded model withGET /v1/models/{id}returns404withmodel_not_found, while sending a generation request for a model outside your plan returns403with codemodel_not_in_plan). - Use the agent as usual.
How a plan key behaves:
- In-flight requests. A plan runs a fixed number of requests at the same
time. Some agents send a side call (a session title or a background task) next
to your first turn, and it counts toward your in-flight limit. Where the agent
has a small-model setting (OpenCode
small_model, Claude CodeANTHROPIC_DEFAULT_HAIKU_MODEL), point it at a fast model with reasoning off. - In-flight limit reached. The request gets
429with codeconcurrency_limitwhen too many requests are in flight — or, on partner-served models near the allowance limit, while remaining allowance is temporarily held by concurrent or recently finished unmeasured requests (for up to 60 seconds while usage settles). Wait the number of seconds in itsRetry-Afterheader before you retry. Most agents do this. If yours stops, send the turn again. - Usage used up. On models Inference.net hosts, requests keep working in the
slow lane at a lower priority. On partner-served models, once settled usage
reaches your allowance or partner-model limit, requests return
402witherror.code: "usage_limit",error.type: "usage_limit_reached",x-should-retry: false, and noRetry-Afterheader; the message starts with "Usage limit reached" and gives the reset time (while usage is still settling, requests instead return retryable429withconcurrency_limitandRetry-After). Check usage and the reset time on My plans. - Plan limited to the slow lane. If your plan is restricted to the slow
lane, partner-served models return
403witherror.code: "plan_restricted"andx-should-retry: false; switch to an Inference.net-hosted model. - Interactive requests. Plan keys send requests on
/v1/chat/completions,/v1/completions,/v1/embeddings,/v1/messages, and/v1/responses. - Allowed non-generation routes. Plan keys can also call
GET /v1/models,GET /v1/usage,GET /v1/generation/{id}, andPOST /v1/messages/count_tokens. - Not supported. Async and Group requests (including Group reads), Batch,
and Files return
403with codeplan_route_not_supported. Use a pay-as-you-go API key for those. See API keys for full authentication details.
Optional headers
These headers work on every request. You do not need the Gateway proxy headers
(x-inference-provider, x-inference-provider-api-key,
x-inference-provider-url) to call Inference.net models.
| Header | Description |
|---|---|
x-inference-task-id | Groups requests under a task, for example opencode. |
x-inference-environment | Tags requests with an environment, such as production or dev. |
x-inference-metadata-* | Attaches metadata. x-inference-metadata-user: alice stores user: alice. |
Troubleshooting
Missing Authorization Bearer token
The client sent no key. Check that INFERENCE_API_KEY (or ANTHROPIC_API_KEY
/ ANTHROPIC_AUTH_TOKEN in Claude Code) is set in the shell that starts the
client, then restart the client.
301 Moved Permanently, 404, or HTML instead of JSON
The base URL is https://inference.net/v1. Change it to
https://api.inference.net/v1.
The model is not found
Copy the exact id from GET /v1/models or the model catalog. Some
IDs include an owner prefix, such as moonshotai/kimi-k3.