---
title: "OpenCode Setup: DeepSeek V4.1 Flash, Kimi K3 & GLM-5.3 | Inference.net"
description: "Copy-paste OpenCode opencode.json config for DeepSeek V4.1 Flash, Kimi K3.1 Pro, and GLM-5.3 on Inference.net with real session cost math and ZDR."
url: "https://inference.net/guides/opencode-deepseek-kimi-setup/"
---

Guide Published December 06, 2026 5 min read

# OpenCode Setup: DeepSeek V4.1 Flash, Kimi K3 & GLM-5.3

Copy-paste OpenCode opencode.json config for DeepSeek V4.1 Flash, Kimi K3.1 Pro, and GLM-5.3 on Inference.net with real session cost math and ZDR.

[**Inference.net**](https://inference.net/company/)

## Run OpenCode at $0.03 per Session

Wire DeepSeek V4.1 Flash 1017, Kimi K3.1 Pro, and GLM-5.3 into OpenCode with 1M context, 0% markup billing, and hosted ZDR.

## Configure OpenCode with DeepSeek, Kimi K3, and GLM-5.3

You can run OpenCode on Inference.net in under two minutes with one copy-paste `opencode.json` file or one CLI command (`fast opencode on`). Wiring [`deepseek-v4.1-flash-1017`](https://inference.net/models/deepseek-v4-1-flash-1017/), [`moonshotai/kimi-k3`](https://inference.net/models/kimi-k3/), [`moonshotai/kimi-k3.1-pro`](https://inference.net/models/kimi-k3-1-pro/), and [`glm-5.3`](https://inference.net/models/glm-5-3/) under one provider gives OpenCode **1M-token context windows**, full tool calling, reasoning effort toggles (`Ctrl+T`), and per-agent switching between a `$0.0329/session` build loop and frontier open-weight planning models.

## Step 1: Create and export your Inference.net API key

Create a free account at [/register](https://inference.net/register/?model=deepseek-v4.1-flash-1017), generate a project key in [API keys](https://inference.net/dashboard/api-keys/), and export it in your shell profile (`~/.zshrc` or `~/.bashrc`) before launching OpenCode:

bash

```bash
export INFERENCE_API_KEY="inf_sk_..."
```

OpenCode resolves `{env:INFERENCE_API_KEY}` at startup, so restart OpenCode after adding or rotating the key.

## Step 2: Copy-paste `opencode.json`

Save this configuration to `~/.config/opencode/opencode.json` (global) or `./opencode.json` (repository-scoped). Every model ID, context window, max output ceiling, modality list, and reasoning variant below matches live `GET https://api.inference.net/v1/models` (verified **2026-12-06**):

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" }
          }
        },
        "glm-5.3": {
          "name": "GLM 5.3",
          "attachment": false,
          "modalities": {
            "input": ["text"],
            "output": ["text"]
          },
          "limit": { "context": 1048576, "output": 943718 },
          "tool_call": true,
          "reasoning": true,
          "variants": {
            "low": { "reasoning_effort": "low" },
            "high": { "reasoning_effort": "high" },
            "max": { "reasoning_effort": "max" }
          }
        },
        "moonshotai/kimi-k3": {
          "name": "Kimi K3",
          "attachment": true,
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": { "context": 1048576, "output": 1048576 },
          "tool_call": true,
          "reasoning": true,
          "variants": {
            "none": { "reasoning_effort": "none" },
            "low": { "reasoning_effort": "low" },
            "high": { "reasoning_effort": "high" },
            "max": { "reasoning_effort": "max" }
          }
        },
        "moonshotai/kimi-k3.1-pro": {
          "name": "Kimi K3.1 Pro",
          "attachment": true,
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": { "context": 1048576, "output": 1048576 },
          "tool_call": true,
          "reasoning": true,
          "variants": {
            "none": { "reasoning_effort": "none" },
            "low": { "reasoning_effort": "low" },
            "high": { "reasoning_effort": "high" },
            "max": { "reasoning_effort": "max" }
          }
        }
      }
    }
  }
}
```

Three config details prevent the most common OpenCode errors:

1. **Keep the key name `"inference"` under `"provider"`:** Overriding the built-in `inference` entry ensures OpenCode calls `https://api.inference.net/v1` instead of an outdated `models.dev` base URL (`https://inference.net/v1`), while keeping `"provider"` (singular) compatible with both OpenCode 1.x and 2.x.
2. **Keep the `moonshotai/` prefix on Kimi IDs:** Use `moonshotai/kimi-k3` and `moonshotai/kimi-k3.1-pro` so requests hit Inference.net-hosted US infrastructure with default ZDR and live serverless rates.
3. **Optional US-only endpoint:** All four models above run on US servers, so you can change `baseURL` to `https://us.api.inference.net/v1` for US-only routing.

### Alternative: one-command setup with split build and plan models

If you prefer automatic setup with a backup of your existing config, use the `fast` CLI to assign separate models to OpenCode's `build` and `plan` agents:

bash

```bash
npm install -g @inference/fast
fast login

# Use DeepSeek V4.1 Flash for fast build loops and Kimi K3.1 Pro for planning
fast opencode on \
  --build deepseek-v4.1-flash-1017 \
  --plan moonshotai/kimi-k3.1-pro
```

For native Anthropic `/v1/messages` (`@ai-sdk/anthropic`) config and Inference Pass (`inf pass on opencode`) instructions, see the full [OpenCode integration documentation](https://inference.net/docs/integrations/opencode/).

## Real OpenCode session cost math

Coding agents replay repository files, tool schemas, and prior turns on every step. The table below uses our standard [Coding Agent workload preset](https://inference.net/tools/llm-pricing-calculator/?preset=coding-agent): **40 turns per session**, **14,000 average input tokens per turn** (`560K` total input = `84K` fresh + `476K` cached reads at **85% prompt caching**), and **900 average output tokens per turn** (`36K` total output).

All rates below were verified from `GET https://api.inference.net/v1/models` on **2026-12-06**:

| OpenCode setup | Fresh / Cached / Output ($/1M) | 40-turn session cost | Monthly (100 sessions/dev) | Best workflow role |
| --- | --- | --- | --- | --- |
| `deepseek-v4.1-flash-1017` (all turns) | `$0.08` / `$0.007` / `$0.635` | **`$0.0329`** | `$3.29` | Default `build`, `small_model`, test fixes |
| Hybrid: 30 `deepseek-v4.1-flash-1017` + 10 `glm-5.3` | Tiered build + plan | **`$0.0628`** | `$6.28` | Low-cost build loops + deep refactor planning |
| `glm-5.3` (all turns) | `$0.084` / `$0.079` / `$3.00` | **`$0.1527`** | `$15.27` | Single-model long-output refactors |
| Hybrid: 30 `deepseek-v4.1-flash-1017` + 10 `moonshotai/kimi-k3.1-pro` | Tiered build + plan | **`$0.1670`** | `$16.70` | Fast build execution + frontier K3.1 Pro planning |
| `moonshotai/kimi-k3.1-pro` (all turns) | `$1.80` / `$0.198` / `$9.00` | **`$0.5694`** | `$56.94` | Complex multi-file architecture end to end |
| `moonshotai/kimi-k3` (all turns) | `$0.245` / `$0.224` / `$15.00` | **`$0.6672`** | `$66.72` | Input-heavy repo exploration and synthesis |
| `claude-sonnet-4-6` (reference) | `$3.00` / `$0.30` / `$15.00` | **`$0.9348`** | `$93.48` | Proprietary baseline comparison |

Splitting 30 `build` turns onto `deepseek-v4.1-flash-1017` (`$0.0247`) and 10 `plan` turns onto `moonshotai/kimi-k3.1-pro` (`$0.1424`) totals **`$0.1670`** per 40-turn session: 3.4x cheaper than running `moonshotai/kimi-k3.1-pro` on every turn (`$0.5694`) and 5.6x cheaper than `claude-sonnet-4-6` (`$0.9348`).

Plug your team's session count and cache hit rate into the [LLM Pricing Calculator](https://inference.net/tools/llm-pricing-calculator/?preset=coding-agent) or [Prompt Cache Calculator](https://inference.net/tools/prompt-cache-calculator/).

## Switching models, reasoning effort, and caching inside OpenCode

- **Switch models mid-session:** Open OpenCode's model picker with `/models` (or `Ctrl+X` then `M`). All four configured models appear under **Inference.net**.
- **Tune reasoning effort on the fly:** Press `Ctrl+T` to cycle variants (`none`, `low`, `high`, `max` on DeepSeek V4.1 Flash and Kimi K3/K3.1; `low`, `high`, `max` on GLM-5.3). Dropping DeepSeek V4.1 Flash to `low` or `none` speeds up repetitive edits and cuts output tokens.
- **Prompt caching behavior by model:** `deepseek-v4.1-flash-1017`, `moonshotai/kimi-k3`, and `moonshotai/kimi-k3.1-pro` use automatic prefix caching with no cache-key header needed (never send `prompt_cache_key` to DeepSeek V4.1 Flash). `glm-5.3` uses a stable `prompt_cache_key` when called directly via API for cache affinity. Confirm cache hits in [Usage](https://inference.net/dashboard/usage/).

## Zero Data Retention (ZDR) and US residency scope

All four models in the `opencode.json` above (`deepseek-v4.1-flash-1017`, `glm-5.3`, `moonshotai/kimi-k3`, and `moonshotai/kimi-k3.1-pro`) are **Inference.net-hosted US serverless routes**. They are eligible for default [Zero Data Retention](https://inference.net/zero-data-retention/) under SOC 2 Type II controls (prompts and completions are not stored after processing or used for training) and accept US-pinned requests via `https://us.api.inference.net/v1`. If you add externally routed catalog models (such as `deepseek-v4-pro`, `kimi-k2.6`, or `glm-5.2`) to `opencode.json`, those external routes are excluded from Inference.net's ZDR policy and follow their upstream provider's retention terms.

## Frequently asked questions

### Why did OpenCode fail with a `301` or `404` error using the built-in `inference` provider?

OpenCode's bundled `models.dev` catalog can point to `https://inference.net/v1` instead of `https://api.inference.net/v1`. Copy the `opencode.json` block above so `"baseURL": "https://api.inference.net/v1"` overrides the built-in URL.

### Should I use `@ai-sdk/openai-compatible` or `@ai-sdk/anthropic` in OpenCode?

Start with `@ai-sdk/openai-compatible` (`https://api.inference.net/v1`) because it exposes `reasoning_effort` variants cleanly across DeepSeek, Kimi, and GLM models. Use `@ai-sdk/anthropic` (also with `baseURL: "https://api.inference.net/v1"`, since `@ai-sdk/anthropic` appends `/messages`) if you specifically want Anthropic Messages wire formatting.

### Which model is best for OpenCode's `small_model` slot?

Set `"small_model": "inference/deepseek-v4.1-flash-1017"`. At `$0.08` fresh input, `$0.007` cached reads, and `$0.635` output per 1M tokens with 1.04M context, it handles title generation, compaction, and quick repo lookups for fractions of a cent.

### Can I route OpenCode through a team LiteLLM Proxy instead of individual keys?

Yes. Run a centralized [LiteLLM Proxy](https://inference.net/docs/integrations/litellm/) backed by Inference.net and point OpenCode's `baseURL` to `http://127.0.0.1:4000/v1` (or your internal proxy HTTPS URL) with your LiteLLM virtual key.

## Related OpenCode and model resources

- **Integration docs:** [OpenCode Integration Docs](https://inference.net/docs/integrations/opencode/) · [Claude Code Integration](https://inference.net/docs/integrations/claude-code/) · [LiteLLM Proxy & SDK](https://inference.net/docs/integrations/litellm/) · [Integrations Hub](https://inference.net/docs/integrations/)
- **Model family hubs:** [DeepSeek API](https://inference.net/models/deepseek/) · [Kimi API](https://inference.net/models/kimi/) · [GLM API](https://inference.net/models/glm/)
- **Pricing guides & tools:** [DeepSeek API Pricing](https://inference.net/guides/deepseek-api-pricing/) · [Kimi K3 Pricing](https://inference.net/guides/kimi-k3-pricing/) · [GLM-5 Pricing](https://inference.net/guides/glm-5-pricing/) · [LLM Pricing Calculator](https://inference.net/tools/llm-pricing-calculator/?preset=coding-agent)

### Connect OpenCode to DeepSeek, Kimi K3, and GLM-5.3

Create a free Inference.net API key to run 1M-context open-weight models in OpenCode with automatic prompt caching, 0% markup billing, and hosted US Zero Data Retention.

[Create API key](https://inference.net/register/?model=deepseek-v4.1-flash-1017)

Estimate Your Inference Bill

## Calculate your monthly LLM API & prompt-cache spend

Compare live input, cached-read, and output token pricing across every open-weight and frontier model on Inference.net with 0% markup.

[Open pricing calculator](https://inference.net/tools/llm-pricing-calculator/) [Explore model catalog](https://inference.net/models/)

## Related reading & models

[Back to all guides](https://inference.net/guides/)

[Guide December 06, 2026 **DeepSeek V4.1 vs Kimi K3 vs GLM-5.3 for Coding Agents** Compare DeepSeek V4.1 Flash, Kimi K3.1 Pro, Kimi K3, and GLM-5.3 for coding agents with live pricing, 1M context, 40-turn cache math, and ZDR rules. Read more](https://inference.net/guides/deepseek-vs-kimi-vs-glm-coding-agents/) [Blog December 04, 2026 **Benchmarking DeepSeek V4.1 Flash & Kimi K3: Live Speed & Open Harness** Live 15-minute production speed, TTFT, and pricing for DeepSeek V4.1 Flash and Kimi K3 on Inference.net, plus a zero-dependency Python benchmark script. Read more](https://inference.net/blog/benchmarking-deepseek-v4-1-flash-kimi-k3-serverless-inference/) [Guide December 06, 2026 **GLM-5 Pricing: GLM-5.3, Flash & GLM-5.2 API Rates** Live GLM-5.3, GLM-5.3 Flash, and GLM-5.2 API pricing per 1M tokens on Inference.net, with prompt_cache_key rules, 40-turn session math, and SDK setup. Read more](https://inference.net/guides/glm-5-pricing/) [Guide December 05, 2026 **DeepSeek API Pricing: Live Rates, Caching Math, and Models** Live DeepSeek API pricing per 1M tokens for V4.1 Flash, V4 Pro, Cyber, and V3.2 on Inference.net, with prompt caching math and copy-paste code snippets. Read more](https://inference.net/guides/deepseek-api-pricing/)

[**Explore serverless models** Compare open-weight and frontier models, context windows, and per-token pricing.](https://inference.net/models/) [**Inference Pass plans** Predictable monthly access for coding agents and high-volume OpenAI-compatible API workloads.](https://inference.net/subscription/)
