# Connect Claude Code and opencode

Use the **Connect your tooling** panel in the web app to get ready-to-paste configuration for Claude Code, opencode or any other tool.

## Before you begin

- You need a personal API key with an acting context (a space or project). See [Create and manage your API keys](https://docs.atlas.ilionx.dev/guides/user/api-keys-create-and-manage.md).
- You need at least one model in the key's acting context. Claude Code, and opencode with the Anthropic SDK, need a Claude model. Without one, the panel says "No Claude models available in this context. Ask your admin."
- With the OpenAI-compatible SDK on the **opencode** tab, the panel says "No models available in this context. Ask your admin." when the context has no model at all.
- Install Claude Code or opencode first.

## Open the panel

1. Open **My API keys**.
2. Do one of the following:
   - After creating a key, select **Set up a tool** in the **API Key Created** dialog. The panel is filled in with your real key.
   - Select a key in **Your keys** and choose **Connect a tool** in its row menu. The **Connect your tooling** panel opens beside the list. It shows the placeholder `<your-atlas-key>`. Select **Copy key** and paste your key in its place.
3. Pick a tab: **Claude Code**, **opencode** or **Other tools**.

## Connect Claude Code

1. On the **Claude Code** tab, choose the model for each tier: **Fable**, **Opus**, **Sonnet** and **Haiku**. Each tier offers the Claude models available to your key.
2. Choose a **Format**:
   - **settings.json** gives a snippet to merge into `~/.claude/settings.json`.
   - **Shell** gives `export` lines for your shell profile.
3. Copy the snippet and add it to your settings file or profile. The shell format looks like this:

   ```bash
   export ANTHROPIC_BASE_URL="https://<atlas-host>/gateway/anthropic"
   export ANTHROPIC_AUTH_TOKEN="<your-atlas-key>"
   export ANTHROPIC_DEFAULT_MODEL="<sonnet model id>"
   export ANTHROPIC_DEFAULT_FABLE_MODEL="<model id>"
   export ANTHROPIC_DEFAULT_OPUS_MODEL="<model id>"
   export ANTHROPIC_DEFAULT_SONNET_MODEL="<model id>"
   export ANTHROPIC_DEFAULT_HAIKU_MODEL="<model id>"
   ```

4. Start Claude Code with `claude`.

Claude Code sessions start on the Sonnet tier. Switch tiers with `/model`. The panel preselects a model for each tier by name. If no model matches a tier, it falls back from Fable to Opus to Sonnet, and finally to the first Claude model available.

## Connect opencode

1. On the **opencode** tab, choose the **Main** and **Small** models.
2. Choose the **SDK**: **OpenAI-compatible** (the default) or **Anthropic**. Use Anthropic only for Claude models.
3. Choose the **Version**. Keep **V2** (the default). Choose **V1 (deprecated)** only if your opencode installation still reads the older configuration format. The two versions use different key names, so a config for one doesn't work in the other.
4. Copy the generated config into `~/.config/opencode/opencode.json`, or into an `opencode.json` in your project. Merge it with any existing content.
5. Start opencode and select the `atlas/<model id>` model.

## Connect other tools

The **Other tools** tab lists the two endpoints and the authentication headers. The **Models** card lists the model ids your key can use. Enter them in your tool as described in [Connect an OpenAI- or Anthropic-compatible client](https://docs.atlas.ilionx.dev/guides/user/gateway-connect-openai-and-anthropic-clients.md). For IDEs, see [Connect your IDE](https://docs.atlas.ilionx.dev/guides/user/gateway-connect-your-ide.md).

## Check that it works

Run a request from a terminal to confirm the key, acting context and URL:

```bash
curl -s https://<atlas-host>/gateway/openai/v1/models -H "Authorization: Bearer <your-atlas-key>"
```

**Result:** a list of models means the connection is correct. Start your tool. Its requests go through the ATLAS gateway, appear in **My usage** and count against the budget of the key's acting context.

## Troubleshooting

| Symptom                                                                                                 | Remedy                                                                                                                            |
| ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| The panel says "The models for this key could not be loaded."                                           | Select **Try again**.                                                                                                             |
| The panel says "No models available in this context. Ask your admin." (opencode, OpenAI-compatible SDK) | The space or project has no model enabled. Ask an Admin.                                                                          |
| A Claude model is missing from the Claude Code tiers                                                    | Claude models that ATLAS reaches through an OpenAI-compatible connection, for example OpenRouter, are not offered to Claude Code. |
| Gateway errors such as `401` or `404 model_not_found`                                                   | See the [troubleshooting table](https://docs.atlas.ilionx.dev/guides/user/gateway-connect-openai-and-anthropic-clients.md#troubleshooting).                                 |

## Related

- [Create and manage your API keys](https://docs.atlas.ilionx.dev/guides/user/api-keys-create-and-manage.md)
- [Connect an OpenAI- or Anthropic-compatible client](https://docs.atlas.ilionx.dev/guides/user/gateway-connect-openai-and-anthropic-clients.md)
- [Connect your IDE](https://docs.atlas.ilionx.dev/guides/user/gateway-connect-your-ide.md)
- [API keys concepts](https://docs.atlas.ilionx.dev/concepts/api-keys.md)
- [API keys reference](https://docs.atlas.ilionx.dev/reference/api-keys.md)
