Skip to main content

opencode

opencode is an open-source AI coding agent that runs in your terminal. This guide adds Entrim as a provider so opencode can use Entrim models.

opencode gets its built-in providers from models.dev, and Entrim isn't listed there yet. Until it is, you add Entrim to your opencode config yourself, which takes one block of JSON.

Prerequisites​

To follow this guide, you need:


Set up opencode​

1. Install opencode​

Run the install script:

curl -fsSL https://opencode.ai/install | bash

You can also install it with npm (npm install -g opencode-ai) or one of the other methods in the opencode docs.

2. Add Entrim as a provider​

Add the entrim provider to your global opencode config, ~/.config/opencode/opencode.json. Create the file if it doesn't exist. If you already have one, which may be called opencode.jsonc, add the entrim entry to its existing provider object.

~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"entrim": {
"npm": "@ai-sdk/openai-compatible",
"name": "Entrim",
"options": {
"baseURL": "https://api.entrim.ai/v1"
},
"models": {
"zai-org/GLM-5.3-Flash": {
"name": "GLM-5.3-Flash",
"attachment": true,
"reasoning": true,
"tool_call": true,
"modalities": { "input": ["text", "image"], "output": ["text"] },
"limit": { "context": 1048576, "output": 131072 }
}
}
}
}
}

To use Entrim in a single project only, put the same block in an opencode.json at the root of that project instead.

The fields under the model describe it to opencode:

FieldMeaning
attachmentThe model accepts images, so you can paste screenshots into the chat
reasoningThe model reasons before it answers
tool_callThe model can call tools, which opencode needs to read files, edit code and run commands
modalitiesWhat the model takes as input and produces as output
limitThe model's token limits: context is max_input_tokens and output is max_output_tokens from GET /v1/models

3. Add your API key​

Start opencode:

opencode

Then connect it to Entrim:

  1. Run the /connect command and choose Other.
  2. Enter entrim as the provider ID. It must match the key under provider in your config.
  3. Paste your Entrim API key.

opencode keeps the key in its own credentials file (~/.local/share/opencode/auth.json), so it never ends up in your config.

Prefer an environment variable?

Instead of /connect, you can have opencode read the key from your environment. Add "apiKey": "{env:ENTRIM_API_KEY}" to the provider's options next to baseURL, and export ENTRIM_API_KEY in your shell.

4. Select the model​

Run /models and choose GLM-5.3-Flash from the Entrim group. To make it the default model, add a model entry at the top level of your config:

"model": "entrim/zai-org/GLM-5.3-Flash"

Check that it works​

Send a one-off prompt from the terminal:

opencode run -m entrim/zai-org/GLM-5.3-Flash "Reply with the word pong"

opencode prints the model it used, followed by the reply. opencode models entrim lists every Entrim model in your config.

Add more models​

To use another Entrim model, add it next to zai-org/GLM-5.3-Flash under models:

  • Use the model's id from GET /v1/models as the key
  • Set limit.context and limit.output from its max_input_tokens and max_output_tokens
  • Set attachment, reasoning and tool_call to match what the model supports. Its page in the model library lists its capabilities.

Troubleshooting​

ProblemFix
401 or "No api key passed in"opencode has no key for the entrim provider. Run /connect again with the provider ID entrim, or export the variable your {env:...} setting points to.
Entrim is missing from /modelsopencode didn't load the config. Check the file path and the JSON syntax, then run opencode models entrim.
400 "Invalid model name"The model key in your config doesn't match an Entrim model ID. Compare it with GET /v1/models, including upper and lower case.