---
title: "OpenCode with EU-hosted models · Setup guide"
description: "Run the OpenCode terminal agent on open-weight models processed in EU data centres. Add one provider block to opencode.json and keep your code in Europe."
canonical: "https://inference.eu/integrations/opencode/"
language: "en"
---

Coding agents · OpenCode

# Use OpenCode with open-source models hosted in the EU

OpenCode is an open-source coding agent for the terminal. Add inference.eu as a custom provider in opencode.json and every prompt, file excerpt and tool call it sends is processed in European data centres, on open-weight models, under a GDPR data processing agreement.

[Contact sales](https://inference.eu/contact/)[Setup](#setup)

1.  01API format: OpenAI
2.  02EU data centres
3.  03Covered by one DPA

## Set it up in a few minutes

1.  1

    Create an API key in your inference.eu account and export it as `INFERENCE_EU_API_KEY` in your shell profile.

2.  2

    Install OpenCode with `curl -fsSL https://opencode.ai/install | bash`, or `npm install -g opencode-ai` on Windows.

3.  3

    Add the `inference-eu` provider block to `opencode.json` in your project, or to `~/.config/opencode/opencode.json` to use it everywhere.

4.  4

    Start `opencode` in your repository and pick a model with `/models`. Each one is listed as `inference-eu/<model id>`.

5.  5

    Ask for a small change, such as a unit test, to confirm that tool calls and file edits work end to end.

opencode.json

```
{
  "$schema": "https://opencode.ai/config.json",
  "model": "inference-eu/qwen3-coder-480b-a35b-instruct",
  "small_model": "inference-eu/gpt-oss-120b",
  "provider": {
    "inference-eu": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "inference.eu",
      "options": {
        "baseURL": "https://api.inference.eu/v1",
        "apiKey": "{env:INFERENCE_EU_API_KEY}"
      },
      "models": {
        "qwen3-coder-480b-a35b-instruct": { "name": "Qwen3 Coder 480B" },
        "gpt-oss-120b": { "name": "gpt-oss-120b" },
        "glm-5.3": { "name": "GLM-5.3" },
        "kimi-k3": { "name": "Kimi K3" }
      }
    }
  }
}
```

## What OpenCode is

OpenCode is an open-source, MIT-licensed coding agent that runs in your terminal. It reads your repository, plans changes, edits files and runs shell commands, asking for permission where you tell it to. It is not tied to one model vendor: providers are defined in a plain JSON file, and any service that speaks the OpenAI Chat Completions format can be added as a custom provider.

That makes it a natural fit for open-weight models. You keep the agent you like and choose where the model runs.

## How the configuration works

OpenCode loads custom providers through the AI SDK. The `npm` field selects `@ai-sdk/openai-compatible`, which talks to the `/chat/completions` endpoint. `options.baseURL` points at inference.eu and `options.apiKey` reads your key from the environment with the `{env:...}` syntax, so the key never sits in a file you might commit.

OpenCode does not discover models from `/v1/models`. List each model you want under `models`; the key must be the exact model id. The `model` and `small_model` fields set the defaults, written as `inference-eu/<model id>`. You can add `limit.context` and `limit.output` per model so OpenCode knows how much context is left.

## Which models to choose

For day-to-day agent work, start with `qwen3-coder-480b-a35b-instruct`. It is trained for code and agentic tool use, and it handles long multi-file edits well. `glm-5.3` and `kimi-k3` are strong general models with reliable tool calling and are worth trying on tasks that need more planning or reading of documentation.

Set `small_model` to `gpt-oss-120b`. OpenCode uses the small model for session titles and other light tasks, and a fast model keeps those calls cheap and quick. Switching models mid-session with `/models` is fine, so you can compare them on your own codebase.

## Troubleshooting

A 401 error means the key did not reach OpenCode. Check that `INFERENCE_EU_API_KEY` is exported in the same shell you start `opencode` from, and run `opencode auth list` to see stored credentials. If you added the key with `/connect`, the provider id there must match `inference-eu` exactly.

A "model not found" error almost always means the key under `models` differs from the model id on inference.eu. Copy the id exactly. If the agent describes edits instead of making them, the model is not returning tool calls: switch to one of the coding models above. Make sure `baseURL` ends in `/v1` and has no trailing path.

## Keeping code and data in the EU

OpenCode runs locally and sends model requests straight from your machine to the provider you configure. With inference.eu as the only provider, prompts, file contents and tool results are processed in EU data centres and are never used to train models. We sign a data processing agreement under Article 28 GDPR and give you our subprocessor list, and usage is billed in euros.

To make sure nothing goes elsewhere, remove other providers from your config and set both `model` and `small_model` to inference.eu models, so background tasks such as titles stay on the same endpoint.

## OpenCode

Category

Coding agents

Maker

Anomaly (formerly SST)

API format

OpenAI

Processing

EU data centres

Website

[opencode.ai](https://opencode.ai/)

Documentation

[opencode.ai](https://opencode.ai/docs/providers/)

## OpenCode: common questions

The questions buyers, developers and legal teams ask us most. Something missing? Ask us directly.

Yes. OpenCode is model-agnostic. Define inference.eu as a custom provider in opencode.json, set it as the default model and small model, and remove other providers. OpenCode then sends every request to inference.eu and needs no OpenAI or Anthropic account.

Model requests go directly from the OpenCode process on your machine to the provider in your config. With inference.eu configured, your code goes to our EU endpoint. Session sharing is a separate, optional feature; leave it unused if your policy does not allow it.

Start with qwen3-coder-480b-a35b-instruct for coding tasks and gpt-oss-120b as the small model. GLM-5.3 and Kimi K3 are good alternatives for tasks with more planning. Try two or three on a real ticket from your backlog; the differences show quickly.

OpenCode reads models from the \`models\` map in your config and does not query \`/v1/models\` for custom providers. Add an entry for each model you want to use, with the exact model id as the key. The display name is up to you.

Put it in the root of a project to apply to that project only, or in \`~/.config/opencode/opencode.json\` to apply everywhere. Project settings are merged over the global file, so you can set the provider globally and change the default model per repository.

Use \`"apiKey": "{env:INFERENCE\_EU\_API\_KEY}"\` so OpenCode reads the key from your environment, or store it with \`/connect\`. Never paste the key itself into opencode.json if the file is committed to a repository.

The key was missing or wrong. Confirm that \`INFERENCE\_EU\_API\_KEY\` is set in the shell that starts OpenCode, that the key is active in your account, and that no other credential stored with \`/connect\` under the same provider id overrides it.

Yes. inference.eu supports streaming and OpenAI-style tool calls, which OpenCode relies on to edit files and run commands. Use a model trained for tool use, such as Qwen3 Coder, GLM-5.3 or Kimi K3, for the most dependable agent behaviour.

Yes. Commit an opencode.json without secrets to your repository, with the provider block and default models. Each developer exports their own \`INFERENCE\_EU\_API\_KEY\`, so usage is tracked per key and nobody shares credentials.

Requests are processed in EU data centres, are not used for training, and are covered by a data processing agreement under Article 28 GDPR with a published subprocessor list. Whether your overall use is lawful depends on your own processing, so involve your data protection officer.

Yes. Add a \`limit\` object to a model entry, for example \`"limit": { "context": 128000, "output": 16384 }\`. OpenCode uses these numbers to show how much context remains and when to compact the session. Use the values listed for the model on inference.eu.

[Ask a question](https://inference.eu/contact/)

## Related

[All integrations](https://inference.eu/integrations/)

-   [Claude CodePoint Claude Code at inference.eu with ANTHROPIC\_BASE\_URL and run it on open-weight models processed in EU data centres. No Anthropic account needed.Coding agents](https://inference.eu/integrations/claude-code/)
-   [Kilo CodeAdd inference.eu as a custom OpenAI-compatible provider in Kilo Code for VS Code and the CLI, and run its agents on open-weight models processed in the EU.Coding agents](https://inference.eu/integrations/kilo-code/)
-   [OpenAI Codex CLIRun OpenAI's Codex CLI on open-weight models processed in EU data centres. Add a model\_providers block to config.toml and keep code in Europe.Coding agents](https://inference.eu/integrations/openai-codex/)
-   [PiAdd inference.eu to Pi's models.json and run the minimal Pi coding agent on open-weight models processed in EU data centres.Coding agents](https://inference.eu/integrations/pi/)

## Move your AI workloads to EU infrastructure

Tell us which models you use and roughly how much traffic you have. We reply within one working day with pricing and next steps.

-   Reply within one working day
-   Pricing for your volume
-   DPA ready to sign
