agent37-opencode template runs OpenCode, SST’s open-source coding agent, on an Agent37 instance: an always-on computer with the same chat API, sessions, files, and URLs as every other template. The image is lean, with no browser and no desktop. OpenCode works out of the box on the managed Agent37 model: no login, no account, no keys. The first chat turn just runs, metered like Hermes against your wallet. Point it at your own provider key when you want a specific model.
Create the instance
One call to the hosting API athttps://api.agent37.com:
curl
201 response carries the instance id and its URL, https://{instanceId}.agent37.app, which routes to the gateway on port 3737. The terminal is on port 7681 and the file browser on 8080, each at https://{instanceId}-{port}.agent37.app; see Instance and preview URLs.
Send the first message
Chat is the instance URL plus a path, with the samesk_live_ key sent as the X-Agent37-Key header. opencode is the template’s default agent, so there is no agent field to pass:
curl
agent37/default. Set "stream": true to receive the turn as Server-Sent Events instead of one JSON body, and reuse the returned session_id to continue the thread. See Send a message and Streaming.
Sessions
OpenCode manages sessions natively: thesession_id on a response is OpenCode’s own session id, and every session read works against it. GET /v1/sessions?agent=opencode lists them, GET /v1/sessions/{id} reads a thread’s history, PATCH /v1/sessions/{id} renames one, and DELETE /v1/sessions/{id} removes it. Sessions you start in the instance terminal appear in the list on their own. Omit session_id on a turn to start a thread, then reuse the id the response returns.
Models
GET /v1/models?agent=opencode on the instance lists every model OpenCode can run, each as a provider/model id: agent37/default (the managed model) plus every model of any provider you have registered, for example openai/gpt-5.2. Pass one as model on a turn. Omit model and the turn runs on OpenCode’s configured default, agent37/default. A bare or malformed id (one that is not a provider/model entry from the list) is rejected with model_error. See Models.
Set reasoning_effort per turn. It maps onto OpenCode’s per-model variant, minimal, low, medium, high, xhigh, or max, clamped to what the target model advertises, and none omits it. See Send a message.
Usage on agent37/default is managed: it meters against your Agent37 wallet like Hermes, bounded by the instance’s budget. A turn on a model you brought yourself bills the provider key behind it instead.
Bring your own provider
To run OpenCode on a specific provider, set that provider’s API key as instance env on the create call. OpenCode registers the provider automatically at boot, and its models then appear inGET /v1/models?agent=opencode as provider/model ids:
curl
OPENAI_API_KEY registers OpenAI, ANTHROPIC_API_KEY Anthropic, GEMINI_API_KEY Google, and OPENROUTER_API_KEY OpenRouter. Set more than one to register more than one. Then pass the model you want on a turn, for example "model": "anthropic/claude-sonnet-4-5". Model usage bills the key you set, not your Agent37 wallet. The managed agent37/default model stays available alongside any provider you add, so a turn that omits model still runs managed.
Connect apps
App integrations work here like on every system template: drive the/v1/integrations endpoints to connect your users’ Gmail, Slack, Notion, and hundreds of other apps, and the platform registers its Composio MCP server with OpenCode automatically.
Custom image
To add your own tools, build on the clean base image, which ships OpenCode and the gateway with no managed integrations, the same pattern ashermes-base: