> ## Documentation Index
> Fetch the complete documentation index at: https://docs.relayapp.im/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Connect OpenCode to Relay and check its messaging setup.

## Before you start

* [OpenCode](https://opencode.ai/docs/), installed and signed in.
* Node.js 22.22.3 or newer.

## Connect

Run this in the folder where you work to connect opencode to Relay.

```bash theme={null}
npx relaymessenger connect opencode
```

Follow the prompts to choose or create an agent and approve the change. Leave the command running: it answers each message with OpenCode from the folder you ran it in. Control-C stops it. Relay's tools travel through the session, so no MCP file is written.

## Send it a message

Open Relay on your phone and message the handle. While connect runs, OpenCode answers on its own in the same chat, and each chat keeps its own ACP session.

## What it can do

These come from the connection code for `opencode` and the Relay MCP tool list.

| Relay feature                | OpenCode                                                                                                                                                |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Connect                      | Connect writes no MCP file; Relay drives OpenCode over ACP and its tools travel through the session.                                                    |
| Start                        | Connect stays running and drives `opencode acp` in its folder, one message at a time.                                                                   |
| Wakes when a message arrives | Yes, it answers on its own while connect runs, one message at a time.                                                                                   |
| Reply in the chat            | Yes, text up to 10,000 characters, with a stable idempotency key.                                                                                       |
| Send attachments             | No. The MCP tools send text only.                                                                                                                       |
| Receive attachments          | Yes. Photos and files are saved under \~/.config/relay/media and their paths are added to the message, so the agent opens them with its own file tools. |
| Read chat history            | Yes, by chat, oldest or newest first, one page at a time.                                                                                               |
| React, type, mark read       | Yes, with reactions, typing indicators, and read marks.                                                                                                 |
| Contact card                 | Yes, read and set the agent's name and picture.                                                                                                         |

## When it fails

* `No reply yet. Run: relay watch @<handle>` Connect is not running, or OpenCode is still working; run connect again and it answers from there.

Use the [CLI guide](/cli/index) for prompt, token, and restart errors.

## Next steps

* [Send messages](/messages/send)
* [Read message history](/chats/history)
* [Handle retries](/live/retries)
