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> |
| Model ID | Any id from GET https://api.inference.net/v1/models |
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. 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")'{
"id": "deepseek-v4.1-flash",
"context_length": 1040000,
"max_completion_tokens": 393216,
"reasoning_efforts": ["none", "low", "high", "max"],
"input_modalities": ["text", "image"],
"supported_endpoints": ["chat", "responses", "messages"]
}/v1/models field | Client setting |
|---|---|
id | Model ID |
context_length | Context limit |
max_completion_tokens | Max output tokens |
reasoning_efforts | Reasoning effort levels. none turns reasoning off. See Reasoning. |
input_modalities | Image input |
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. Most chat models support them (see
Function calling). llama-3.2-1b-instruct,
llama-3.2-3b-instruct, and the inference-net/schematron-* extraction models
do not. GET /v1/models does not report tool support.
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",
"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": {
"name": "DeepSeek V4.1 Flash",
"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. 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[1m]'
export ANTHROPIC_DEFAULT_FABLE_MODEL='deepseek-v4.1-flash[1m]'
export ANTHROPIC_DEFAULT_OPUS_MODEL='deepseek-v4.1-flash[1m]'
export ANTHROPIC_DEFAULT_SONNET_MODEL='deepseek-v4.1-flash[1m]'
export ANTHROPIC_DEFAULT_HAIKU_MODEL='deepseek-v4.1-flash[1m]'
export CLAUDE_CODE_SUBAGENT_MODEL='deepseek-v4.1-flash[1m]'
claude- Set every model variable. Claude Code sends background tasks, subagents, and
/modelchoices to these slots. A slot you leave 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. 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. - Use
ANTHROPIC_AUTH_TOKEN, notANTHROPIC_API_KEY. The API reads onlyAuthorization: Bearer.
Codex
Add a provider to ~/.codex/config.toml:
model = "deepseek-v4.1-flash"
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, Continue, 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/models, for a model that supports tool calls
Fill in context and output limits from the field table. The Cursor, Hermes, and OpenClaw guides walk through those clients.
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 is set in the shell that
starts the client, then restart the client. In Claude Code, this also happens
when you set ANTHROPIC_API_KEY instead of ANTHROPIC_AUTH_TOKEN.
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.