# OpenCode

## Install

```bash
npm install -g opencode-ai
```

For other installation methods, see the [OpenCode documentation](https://opencode.ai/docs/install).

## Authenticate

Set the API key for your preferred provider:

```bash
export ANTHROPIC_API_KEY="sk-ant-..."

export OPENAI_API_KEY="sk-..."
```

See [opencode.ai/docs/providers](https://opencode.ai/docs/providers) for all supported providers.

## Launch

Open a terminal with <KeyCombo keys={["⌘", "⌥", "1"]} />, then type `opencode`.

<TerminalPreview lines={[
  { type: "command", text: "opencode --model claude-sonnet-4-5" },
  { type: "output",  text: "OpenCode ready. Type your task below." },
  { type: "output",  text: "" },
  { type: "command", text: "Add input validation to the signup form" },
  { type: "success", text: "Updated src/components/SignupForm.tsx" },
  { type: "success", text: "Updated src/lib/validation.ts" }
]} />

<Toggle title="Useful flags">

| Flag | Description |
|------|-------------|
| `--model <model>` | Choose the AI model (e.g. `claude-sonnet-4-5`, `gpt-4o`) |
| `--provider <provider>` | Select the provider (e.g. `anthropic`, `openai`) |
| `--no-auto-apply` | Preview changes before they are written to disk |
| `--verbose` | Show detailed tool call output |

Full reference: [opencode.ai/docs](https://opencode.ai/docs)

</Toggle>
