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

# OpenCode

> Run OpenCode agents under authsome. Same proxy and library patterns as the rest of the CLI.

[OpenCode](https://opencode.ai) is an open-source AI coding agent. It runs as a CLI, calls LLMs over HTTPS, and shells out to local tools. Authsome plugs in via the same two patterns we use everywhere: wrap the agent under `authsome run --`, or call the library from inside.

<Note>
  **The agent drives login.** When OpenCode hits a missing credential it can run `authsome login <provider>` itself, opening a browser on your machine for OAuth consent. Don't paste keys into prompts; pre-seed a credential only when an agent can't reach a browser (CI, SSH).
</Note>

## Recommended pattern: wrap the agent

```bash theme={null}
authsome login github
authsome login openai
authsome run -- opencode
```

OpenCode sees placeholder env vars (`OPENAI_API_KEY=authsome-proxy-managed`) but never the real key. Outbound HTTPS to matched provider hosts is authenticated by the proxy.

## Embedding the library

If you're orchestrating OpenCode from a larger Python program and need explicit per-call control, drop below the proxy:

```bash theme={null}
authsome run -- python my_agent.py
# or: eval "$(authsome export <provider> --format env)"
```

See [Python library](/reference/python-library).

## Multi-account

```bash theme={null}
authsome login github --connection personal
authsome login github --connection work
authsome login github --connection work --force
authsome run -- opencode
```

The proxy uses each provider's default connection. To switch which connection the proxy uses, set it as default with `--force`. See [Multiple connections per provider](/guides/multiple-connections).

## Troubleshooting

| Symptom                              | Fix                                                                                |
| ------------------------------------ | ---------------------------------------------------------------------------------- |
| `OPENAI_API_KEY` rejected as invalid | OpenCode is running outside `authsome run`. Wrap it.                               |
| TLS errors against `api.openai.com`  | Trust the mitmproxy CA. See [Proxy networking](/troubleshooting/proxy-networking). |

## What's next

<Columns cols={2}>
  <Card title="Run agents with the proxy" icon="shield-halved" href="/guides/run-agents-with-proxy">
    Full proxy walkthrough.
  </Card>

  <Card title="Generic Python agent" icon="python" href="/integrations/agents/python">
    The library pattern for any Python script.
  </Card>
</Columns>
