Skip to contentNewDeepSeek V4.1 Flash 1017 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>
Model IDAny 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:

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. 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")'
json
{
  "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 fieldClient setting
idModel ID
context_lengthContext limit
max_completion_tokensMax output tokens
reasoning_effortsReasoning effort levels. none turns reasoning off. See Reasoning.
input_modalitiesImage input
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. 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):

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:

bash
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 /model choices 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, set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the model's context_length instead. Otherwise Claude Code assumes 200K.
  • Use ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY. The API reads only Authorization: Bearer.

Codex

Add a provider to ~/.codex/config.toml:

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 id from GET /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.

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 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.