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 | bashnpm
npm i -g opencode-aibun
bun add -g opencode-aiHomebrew
brew install anomalyco/tap/opencodeparu
paru -S opencodeInstalling the Desktop App Copy link
Use Homebrew:
brew install --cask opencode-desktopAlternatively, 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.
-
Create or edit the
opencode.jsonconfiguration 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 -
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.
-
-
Save and close the file.
-
Set your API key. Start OpenCode in the terminal:
opencode-
In the TUI, run:
/connect-
Scroll down through the provider list and select Other.
-
Enter the provider ID. This must match the provider key in
opencode.json—in this example,hostman. -
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:
/modelSearch for the provider name you set earlier, then verify the connection by sending a message in the chat.
Desktop App Copy link
-
Click the gear icon to open settings.
-
Go to the Providers tab.
-
Scroll down and select Custom provider.
-
Click Connect.
-
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
-
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. -
Click Submit to save.
Find and select your model in the chat, then verify the connection by sending a test message.