Skip to content
NewDeepSeek V4.1 Flash 1017 Uncensored is live, with 1M tokens of context.Read the launch
Coding agents

OpenCode

Add XField to OpenCode as an OpenAI-compatible provider, declare the models and their limits, and pick one with /models.

OpenCode can use any OpenAI-compatible API through a custom provider. You declare XField once in opencode.json, list the models you want with their limits, and they show up in the model picker next to everything else.

You need OpenCode installed and an API key from Settings › API keys. No key yet? Request access.

Setup

  1. Export your key
    Shell
    export XFIELD_API_KEY="sk-xf-v1-..."

    Put it in your shell profile. OpenCode reads it when it starts.

  2. Add the provider

    Use ~/.config/opencode/opencode.json for every project, or opencode.json in a project root for just that one.

    opencode.json
    JSON
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "field": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "XField",
          "options": {
            "baseURL": "https://xfield.cloud.brutal.ai/api/v1",
            "apiKey": "{env:XFIELD_API_KEY}"
          },
          "models": {
            "deepseek-v4.1-flash-1017-uncensored": {
              "name": "DeepSeek V4.1 Flash",
              "limit": { "context": 1000000, "output": 65536 }
            },
            "glm-5.3-uncensored": {
              "name": "GLM 5.3",
              "limit": { "context": 1000000, "output": 131072 }
            },
            "glm-5.3-flash-uncensored": {
              "name": "GLM 5.3 Flash",
              "limit": { "context": 1000000, "output": 32768 }
            },
            "qwen-3.8-27b-uncensored": {
              "name": "Qwen 3.8 27B",
              "limit": { "context": 131072, "output": 32768 }
            }
          }
        }
      },
      "model": "field/deepseek-v4.1-flash-1017-uncensored",
      "small_model": "field/glm-5.3-flash-uncensored"
    }
  3. Start OpenCode
    Shell
    opencode

    Send a prompt. If you get a 401, the key variable was empty when OpenCode started: {env:...} resolves to an empty string when the variable is unset.

What the config does

  • provider.field is the provider id. Model references use it as a prefix: field/<model-id>.
  • npm tells OpenCode to talk to the provider with the AI SDK's OpenAI-compatible client, which calls https://xfield.cloud.brutal.ai/api/v1/chat/completions.
  • apiKey uses OpenCode's {env:NAME} substitution, so the key never sits in the file.
  • models keys must match our model ids exactly. name is only the label in the picker.
  • limit.context and limit.output tell OpenCode how much room is left and when to compact. Without them it guesses.
  • model is the default; small_model handles light work such as session titles, so it should be the cheap one.

Choosing a model

Run /models inside OpenCode and pick from the XField section. The choice applies to the current session.

JobModel
Coding agent, long runsdeepseek-v4.1-flash-1017-uncensored
Hard reasoning, security researchglm-5.3-uncensored
Batch edits, cheap background workglm-5.3-flash-uncensored
Quick chat, screenshots as inputqwen-3.8-27b-uncensored

See models for the current list and limits.

Reasoning effort

OpenCode passes per-model options to the provider. reasoningEffort becomes reasoning_effort on the request, which XField maps to each model's levels:

JSON
"glm-5.3-uncensored": {
  "name": "GLM 5.3",
  "limit": { "context": 1000000, "output": 131072 },
  "options": { "reasoningEffort": "high" },
  "variants": {
    "max": { "reasoningEffort": "max" }
  }
}

Variants let you cycle effort from the keyboard without editing the file. DeepSeek V4.1 Flash already thinks at high effort with no options set. Qwen has thinking off by default.

Tips

  • Keep AGENTS.md and your tool set stable during a session. Prompt caching is automatic and works best on an unchanging prefix.
  • Project config overrides global config, so a repo can pin a different default model without touching your global file.
  • Reasoning text streams back with each turn; OpenCode shows it when the model sends it.