OpenCode


OpenCode is an AI coding assistant that lets you ask questions about your project, edit code, and run commands—all without leaving your current workflow.

You can connect either an AI agent or an AI Gateway to OpenCode. With an AI agent, you work with a pre-configured agent setup; with AI Gateway, you call the model directly.

Installing OpenCode
Copy link

OpenCode runs on Windows, Linux, and macOS, and is available as a TUI/CLI tool or a desktop app.

Installing the TUI/CLI Version 
Copy link

Use your preferred method:

curl

curl -fsSL https://opencode.ai/install | bash

npm

npm i -g opencode-ai

bun

bun add -g opencode-ai

Homebrew

brew install anomalyco/tap/opencode

paru

paru -S opencode

Installing the Desktop App
Copy link

Use Homebrew:

brew install --cask opencode-desktop

Alternatively, download the binary directly from the OpenCode website and install it manually.

Connection Requirements
Copy link

You can connect either an AI agent or an AI Gateway to OpenCode.

To connect an AI agent, you'll need:

To connect AI Gateway, you'll need:

  • Base URL: https://ai-api.hostman.com/v1
  • An API key

Configuring the Connection
Copy link

TUI/CLI
Copy link

Use this method if you're running the TUI/CLI version of OpenCode.

  1. Create or edit the opencode.json configuration file. You can place it in one of two locations:

    • Project root: settings apply to that project only

    • ~/.config/opencode/opencode.json: settings apply globally across all projects

  2. Add the following configuration:

{
 "$schema": "https://opencode.ai/config.json",
 "provider": {
   "hostman": {
     "npm": "@ai-sdk/openai-compatible",
     "name": "Hostman",
     "options": {
       "baseURL": "https://ai-api.hostman.com/v1"
     },
     "models": {
       "openai/gpt-5-mini": {
         "name": "openai/gpt-5-mini"
       }
     }
   }
 },
 "model": "openai/gpt-5-mini"
}

Adjust the values to match your setup:

    • baseURL: if you're connecting an AI agent, replace this with your agent's base URL. For AI Gateway, leave it as-is.

    • models: the list of models that will be available in OpenCode.

    • model: for AI Gateway, specify the model name—for example, openai/gpt-5-nano. For an AI agent, use the model name from your agent settings. Check the Connection tab for the correct identifier.

    • name: optional; change the provider display name if needed.

  1. Save and close the file.

  2. Set your API key. Start OpenCode in the terminal:

opencode
  1. In the TUI, run:

/connect
  1. Scroll down through the provider list and select Other.

  2. Enter the provider ID. This must match the provider key in opencode.json —in this example, hostman.

  3. Paste your API key.

OpenCode saves the key to an encrypted global auth file.

You can now use OpenCode. If you exited the TUI, restart it, then select your model by running:

/model

Search for the provider name you set earlier, then verify the connection by sending a message in the chat.

Desktop App
Copy link

  1. Click the gear icon to open settings.

  2. Go to the Providers tab.

  3. Scroll down and select Custom provider.

  4. Click Connect.

  5. Fill in the connection details:

    • Provider ID: a unique identifier you'll use to find this provider later

    • Display name: how the provider appears in the interface

    • Base URL: your agent's base URL or the AI Gateway URL

    • API key: the key for your agent or AI Gateway

    • Models: the list of models available for selection

  6. For AI Gateway, model names must follow the AI Gateway format—for example, openai/gpt-5-nano. Check the Connection tab for the correct identifier. For an AI agent, you can use any name.

  7. Click Submit to save.

Find and select your model in the chat, then verify the connection by sending a test message.