Skip to main content

Coding agents

Coding agents that speak the OpenAI API work with Serenity Edge. They call the model with your key and their tools, and they run those tools on your machine. This page covers OpenCode, which uses chat completions. Codex CLI uses the Responses API and is configured in the Responses API guide.

OpenCode​

OpenCode talks to Serenity Edge through its OpenAI-compatible provider (@ai-sdk/openai-compatible), on POST /v1/chat/completions. Put your key in the SERENITY_EDGE_API_KEY environment variable, and declare Serenity Edge as a provider in ~/.config/opencode/opencode.json, or in an opencode.json at the root of a project:

{
"$schema": "https://opencode.ai/config.json",
"model": "serenity-edge/orion-pro",
"small_model": "serenity-edge/orion-plus",
"provider": {
"serenity-edge": {
"npm": "@ai-sdk/openai-compatible",
"name": "Serenity Edge",
"options": {
"baseURL": "https://api.serenityedge.ai/v1",
"apiKey": "{env:SERENITY_EDGE_API_KEY}"
},
"models": {
"orion-pro": {
"name": "Orion Pro",
"reasoning": true,
"options": { "reasoningEffort": "medium" },
"limit": { "context": 262144, "output": 32768 }
},
"orion-plus": {
"name": "Orion Plus",
"reasoning": true,
"options": { "reasoningEffort": "medium" },
"limit": { "context": 262144, "output": 32768 }
}
}
}
}
}

Then start opencode in your project. With this file, OpenCode 2.2.5 starts without warnings, and orion-pro reads files and runs commands through OpenCode's own tools.

  • reasoningEffort turns reasoning on. Reasoning is off on Serenity Edge unless the request asks for it, and OpenCode does not ask for it by default. "reasoning": true and "options": { "reasoningEffort": "medium" } on each model make OpenCode send reasoning_effort with every request. Any value other than none turns reasoning on; low, medium and high behave the same. Without these two settings, OpenCode works without reasoning. Reasoning tokens are billed as output tokens.
  • limit sets the context and the output. OpenCode does not know the Serenity Edge models. limit gives it the context window of the chat models (262,144 tokens) and their maximum output (32,768 tokens), so it compacts the conversation at the right time.
  • small_model writes the session titles. OpenCode names each session with a short request to its small model, and asks for reasoning on that request itself. orion-plus keeps it cheap.
  • Tools run on your machine. OpenCode sends its tools (reading and editing files, running commands) and the tools of its MCP servers as ordinary functions, and runs them locally, so there is nothing to turn off. Every request carries OpenCode's instructions and the description of every tool, several thousand input tokens; each MCP server adds its own.
  • Later requests come mostly from the cache. Those instructions and tool descriptions repeat on every request of a session, so from its second request they are served from the prompt cache and billed at the cached input price.