Skip to main content
Opencode is an interactive CLI tool that helps developers with software engineering tasks. It provides an AI-powered coding assistant directly in your terminal, enabling you to build, debug, and maintain code with intelligent support. For installation instructions, see the official Opencode documentation.

Setup Steps

1

Create a Gateway Token

Before configuring Opencode, you need a Gateway Token from Zylon.See Token Management for detailed instructions on creating Gateway tokens.
2

Set Environment Variables

Add the following to your shell configuration file (~/.zshrc or ~/.bashrc):
echo 'export ZYLON_BASE_URL="https://your-host/api/gpt"' >> ~/.zshrc
echo 'export ZYLON_API_TOKEN="your-gateway-token"' >> ~/.zshrc
echo 'export ZYLON_MODEL="default"' >> ~/.zshrc
source ~/.zshrc
Replace your-host with your Zylon instance URL and your-gateway-token with your actual Gateway token. The model defaults to default.
Never commit environment variables containing tokens to version control. Add them to your .gitignore.
Confirm the variables are set correctly:
echo $ZYLON_BASE_URL
echo $ZYLON_API_TOKEN
echo $ZYLON_MODEL
3

Configure Opencode

Create the Opencode configuration directory:
mkdir -p ~/.config/opencode
Create the configuration file at ~/.config/opencode/opencode.json:
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": {
      "options": {
        "baseURL": "{env:ZYLON_BASE_URL}/v1",
        "apiKey": "{env:ZYLON_API_TOKEN}"
      },
      "models": {
        "{env:ZYLON_MODEL}": {
          "name": "Zylon - {env:ZYLON_MODEL}",
          "limit": {
            "context": 128000,
            "output": 20000
          }
        }
      }
    }
  }
}
For more details on Opencode configuration options, see the official Opencode documentation.
4

Run Opencode

Test your configuration by running:
opencode
On first launch, you’ll need to switch to the Zylon model:
  1. Press Ctrl+P to open the command palette
  2. Select “Switch Model”
  3. Search for and select “Zylon - Default”
Once selected, Opencode will connect to your Zylon instance and be ready to assist with coding tasks.

Limitations

  • Images are not supported

Troubleshooting

Connection Errors

  • Verify ZYLON_BASE_URL is correct and accessible
  • Ensure your Gateway token is valid and not expired
  • Check network connectivity to your Zylon instance

Authentication Failures

  • Confirm the token is copied correctly without extra whitespace
  • Regenerate the token if it may have been compromised
  • Verify the token has appropriate permissions