Skip to contentNewKimi K3.1 Pro is now availableTry it now
Docs / Coding agents overview

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.

SettingValue
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 keyYour Inference.net API key, sent as Authorization: Bearer <key> or x-api-key: <key> (Authorization takes precedence if both are sent)
Model IDAny 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:

bash
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
curl -s https://api.inference.net/v1/models \
  | jq '.data[] | select(.id == "deepseek-v4.1-flash-1017")'
json
{
  "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 fieldClient setting
idModel ID
context_lengthContext limit
max_completion_tokensMax output tokens
max_output_tokensSame value as max_completion_tokens, for clients that read this name
supports_toolsTool calls. Coding agents need true.
reasoning_effortsReasoning effort levels. none turns reasoning off. See Reasoning.
input_modalitiesImage input
output_modalitiesOutput modalities (for example, ["text"])
supported_endpointsAPIs 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.
pricingCost per token, in USD. Multiply by 1,000,000 for per-million-token prices.
requires_approved_accessPresent and true only on privileged models. Your team needs approved access to call the model.
access_statusPresent 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:

json
{
  "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):

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:

bash
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 /model choices to these overrides. Older Claude Code releases also read ANTHROPIC_SMALL_FAST_MODEL for background tasks; set it to the same ID as ANTHROPIC_DEFAULT_HAIKU_MODEL if 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, set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the model's context_length instead. Otherwise Claude Code assumes 200K.
  • The /v1/messages endpoint accepts Anthropic thinking (adaptive and enabled) and output_config.effort, translating them into the model's reasoning settings and streaming thinking_delta blocks back.
  • You can authenticate with either ANTHROPIC_API_KEY (x-api-key) or ANTHROPIC_AUTH_TOKEN (Authorization: Bearer). If both headers are sent, Authorization takes precedence for Inference.net authentication; x-api-key is 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:

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 id from GET /v1/models with supports_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:

bash
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 settings

Desktop 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:

bash
inf pass proxy
  • Claude Desktop: Run inf pass on claude-desktop to write a native third-party gateway profile pointing at http://127.0.0.1:4141, then start inf pass proxy. Run inf pass off claude-desktop to 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) or http://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

  1. Open My plans and create a key for your plan, then use it as INFERENCE_API_KEY.
  2. Call GET /v1/models with your plan key to see the models included in your plan (both GET /v1/models and GET /v1/models/{id} filter to plan-eligible models; retrieving an excluded model with GET /v1/models/{id} returns 404 with model_not_found, while sending a generation request for a model outside your plan returns 403 with code model_not_in_plan).
  3. 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 Code ANTHROPIC_DEFAULT_HAIKU_MODEL), point it at a fast model with reasoning off.
  • In-flight limit reached. The request gets 429 with code concurrency_limit when 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 its Retry-After header 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 402 with error.code: "usage_limit", error.type: "usage_limit_reached", x-should-retry: false, and no Retry-After header; the message starts with "Usage limit reached" and gives the reset time (while usage is still settling, requests instead return retryable 429 with concurrency_limit and Retry-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 403 with error.code: "plan_restricted" and x-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}, and POST /v1/messages/count_tokens.
  • Not supported. Async and Group requests (including Group reads), Batch, and Files return 403 with code plan_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.

HeaderDescription
x-inference-task-idGroups requests under a task, for example opencode.
x-inference-environmentTags 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.