Check out the newest way to compare different models for a task/agent harness: AutoEvals

API

Use Inference.net Models in Coding Agents

Use Inference.net models as the model in OpenCode, Claude Code, Codex, Cursor, Cline, Continue, or any OpenAI-compatible client.

You do not need inf instrument, inf auth login, or Gateway headers. Use your Inference API key with base URL https://api.inference.net/v1. Model IDs come 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 API key, sent as Authorization: Bearer <key>
Model IDAny id from GET https://api.inference.net/v1/models

To set up Claude Code, Codex, Grok, OpenCode, or Pi with one command, use the fast CLI: npm install -g @inference/fast, fast login, then fast <agent> on. fast signs you in with a browser, creates a new API key in your first project, and adds every catalog model to the agent's model picker. fast <agent> off restores the original config. To use your own key, follow the steps below. For each agent, use fast or the steps below, not both: fast writes different config keys, so a mix gives two conflicting provider entries.

This page is for using Inference.net models as your agent's model. To rewrite the LLM clients in your own app so they route through Inference Gateway, see inf instrument. To record traces of your OpenCode sessions, see OpenCode Traces.

Set your API key

Create a key on the API Keys tab 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.

Get model settings from GET /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-1017")'
{
  "id": "deepseek-v4.1-flash-1017",
  "context_length": 262144,
  "max_completion_tokens": 131072,
  "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.

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.

OpenCode

Add a provider to opencode.json (in your project, or globally at ~/.config/opencode/opencode.json). OpenCode 2 uses the providers key. Older versions use provider.

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "providers": {
    "inference": {
      "name": "Inference.net",
      "package": "@ai-sdk/openai-compatible",
      "settings": {
        "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",
          "limit": { "context": 262144, "output": 131072 },
          "capabilities": {
            "tools": true,
            "reasoning": {
              "supported": true,
              "toggle": true,
              "effort": ["low", "high", "max"]
            }
          }
        }
      }
    }
  }
}

limit comes from context_length and max_completion_tokens. effort comes from reasoning_efforts. toggle: true maps to none.

OpenCode's built-in Inference provider comes from the models.dev catalog. That entry can have an old base URL (https://inference.net/v1, which does not work) and an old model list. The config above uses the same inference ID, so it replaces the built-in entry.

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
export ANTHROPIC_DEFAULT_FABLE_MODEL=deepseek-v4.1-flash-1017
export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4.1-flash-1017
export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-v4.1-flash-1017
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4.1-flash-1017
export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-v4.1-flash-1017
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=262144
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.
  • Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the model's context_length. Otherwise Claude Code assumes 200K. For a model with a context of 1M or more, add [1m] to the model ID instead, for example moonshotai/kimi-k3[1m].
  • Use ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY. The API reads only Authorization: Bearer.

Codex

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

~/.codex/config.toml
model = "deepseek-v4.1-flash-1017"
model_provider = "inference"
model_context_window = 262144
model_max_output_tokens = 131072
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 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.

Optional headers

These headers work on every request. You do not need 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. Filter on it in the dashboard.
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. Some IDs include an owner prefix, such as moonshotai/kimi-k3.

On this page