Skip to content

Latest commit

 

History

History

opencode

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

OpenCode on Inferit

opencode.json adds Inferit to OpenCode as a custom OpenAI-compatible endpoint (through @ai-sdk/openai-compatible) with two models: auto (Inferit picks the model) and qwen/qwen-2.5-14b-instruct. Copy it into your project, or merge it into OpenCode's global config. Guide: https://inferit.cc/docs/guides/opencode

Testnet demo: test tokens, no monetary value. Requests are paid in ITC (Inferit Test Credit).

File What it does
opencode.json The Inferit entry, with your key read from INFERIT_API_KEY. Its default model is inferit/auto; pick the named model with /models in OpenCode, or --model. Each model sets limit.output to 4096 (see Context below)
smoke.sh Runs opencode run once (OpenCode from npx) with this config and a minimal smoke agent (a one-line prompt, no tools), keeping OpenCode's own config and data in .opencode-home here. It stops OpenCode after SMOKE_TIMEOUT seconds (default 180), and refuses an INFERIT_MODEL that opencode.json does not declare

Run it

You need Node.js 20 or newer (for npx) and an API key (ik_...) from https://inferit.app/buy.

export INFERIT_API_KEY='ik_...'
bash smoke.sh

In your own project:

cp opencode.json /path/to/your/project/
cd /path/to/your/project && opencode --model inferit/qwen/qwen-2.5-14b-instruct

The base URL is written in opencode.json; INFERIT_BASE_URL does not change it.

Context: check it before you code with it

A request goes only to a seller that serves its whole context: the input plus max_tokens. On 2026-10-13 the largest live seller of each named model served 8,192 tokens.

  • max_tokens. With no limit.output on a model, OpenCode 1.19.0 asked for a context of 32,658 tokens even for the smoke agent. So every model in opencode.json sets "output": 4096. Keep that limit on any model you add.
  • OpenCode's own agents. They send their system prompt and tool definitions with every request. With this config, the default build agent needed a context of 14,543 tokens, so the API refused it: No seller of ... serves a context of 14,543 tokens now. That is why smoke.sh uses a minimal agent with no tools: it checks the endpoint, the key and the model.

When every request fails, OpenCode retries and compacts in a loop. Stop it with Ctrl-C. The API's error names the largest context a live seller of that model serves now.

verified 2026-10-13: OpenCode 1.19.0, smoke agent. Model inferit/auto: "Hello, I'm here to assist you." Model inferit/qwen/qwen-2.5-14b-instruct: "Hello, how may I assist?" The default build agent with the Qwen model: refused by the API (a context of 14,543 tokens; the largest seller served 8,192).