---
title: "Connect OpenCode to Straitly | Straitly Docs"
description: "Configure OpenCode with Straitly's OpenAI-compatible endpoint to use Claude, GPT, Gemini and open models from one key."
url: https://straitly.ai/docs/opencode
updated: 2026-11-25
publisher: Straitly (https://straitly.ai)
---

Docs

Connect your tools

# Connect OpenCode

Copy docs

**On this page**

Use your Straitly key in the OpenCode app and in the terminal (`opencode`). One paste sets up both, and the models you pick show up in OpenCode’s model menu. Works on Mac, Linux and Windows.

App + CLI setup

Have ready

OpenCode installed. On Mac and Linux, curl and python3 in your terminal. On Windows, only PowerShell, which every Windows 10 and 11 machine has. The screenshots follow macOS.

What changes

The Straitly provider in \~/.config/opencode/opencode.json (on Windows, in %USERPROFILE%\\.config\\opencode). Your key is stored separately in OpenCode's key storage.

Keep copied keys and setup commands private.

### Before you start

The command in step 3 creates a key for you, or uses one you already have. You need the OpenCode app or `opencode` installed.

### Setup

Mac or Linux Windows

#### 1. Pick your models

These are the models you will see in OpenCode. The first one is picked when it opens.

Claude Opus 5.5× GPT-6.1 Sol× Claude Fable 5.2×

- Claude Sonnet 5.5 Anthropic · $1.20 / $6 Add
- GLM-5.3 Z.ai · $0.42 / $1.39 Add
- DeepSeek V4.1 Flash 1017 DeepSeek · $0.090 / $0.36 Add

Price per million tokens, input / output. Only models that can run OpenCode are listed.

#### 2. Open a terminal

Press **⌘ Space**, type **Terminal** and press **Enter**.

![Spotlight search with Terminal selected](https://straitly.ai/shots/claude-code/1-terminal.webp?v=a012c851)

#### 3. Paste the command

Copy it, paste it into Terminal and press **Enter**. You should see `Done - OpenCode now uses Straitly.`

Copy command Show command

It adds Straitly to `~/.config/opencode/opencode.json` and keeps everything else in it. Your key goes where OpenCode keeps its keys, not in that file.

![Terminal after pasting the command, showing Done - OpenCode now uses Straitly](https://straitly.ai/shots/opencode/1-done.webp?v=16b273fe)

#### 4. Restart OpenCode

Quit the OpenCode app with **⌘ Q** and open it again, then click **New session**. In the terminal, type `opencode` and press **Enter**. Your first model is already picked.

#### 5. Pick a model

Click the model name under the message box. Your models are in the **Straitly** group. In the terminal, type `/models` instead.

#### 6. Send a message

Say anything. If OpenCode answers, you are done.

### Change your models later

Pick again in step 1 and paste the new command. It replaces the list. Restart OpenCode afterwards. Every id is on the [models page](https://straitly.ai/models).

### Context size

The command writes each model’s context size as `limit.context`, so OpenCode compacts at the right point. To set one yourself, open `~/.config/opencode/opencode.json`, find the model under `provider.straitly.models` and set `"limit": { "context": 1048576, "output": 32000 }`, using the context from the [models page](https://straitly.ai/models). Restart OpenCode afterwards.

### Verify your connection

Restart OpenCode, start a new session, and choose a model in the Straitly group. Send a short message and check Straitly Activity.

[Open request activity](https://straitly.ai/app/activity) to check the model, status, and charge for your test request.

### Setup checks

**The Straitly group is missing**

Check for the Done message, quit and reopen OpenCode, then start a new session. In the terminal, open /models.

**Your selected models are out of date**

Update the selection on this page, copy the new command, and run it again. Restart OpenCode afterwards.

If the request is rejected, check your balance and key limits in [Errors & limits](https://straitly.ai/docs/errors).

### Undo

This takes Straitly out of OpenCode and leaves the rest of your settings as they are:

bash

Copy Copied Failed

curl -fsSL https://straitly.ai/setup/opencode | STRAITLY_UNDO=1 python3 -

The first paste also saved a copy of each file it changed, next to it, ending in `.before-straitly`.

[Connect Codex](https://straitly.ai/docs/codex) [Connect Hermes](https://straitly.ai/docs/hermes)

---
Markdown version of https://straitly.ai/docs/opencode.
