Skip to content
Get API key API key

OpenCode

OpenCode is an open-source AI coding agent that runs in the terminal and can be used alongside any editor or IDE.

  • LSP support that loads the right language tooling for the model
  • Multi-session workflows so you can run multiple agents on the same project
  • Shareable session links for collaboration and debugging
  • MCP support for external tools and data sources
  • Editor-agnostic workflow that works in any IDE
  1. Follow the OpenCode installation instructions on AI Coding Plugins.

  2. Run OpenCode:

    Terminal
    opencode
  3. In OpenCode, run the following command to choose your provider and sign in with your API key:

    Terminal
    /connect

    Select AI Foundation Services from the provider list, then provide your API key when prompted. You can generate an API key in LLM Serving API Keys.

You can now start a chat and use OpenCode.

If you’d rather configure OpenCode declaratively (or pin a default model and base URL), create opencode.json at your project root or ~/.config/opencode/opencode.json for a global default:

opencode.json
{
"$schema": "https://opencode.ai/config.json",
"model": "aifs/gpt-oss-120b",
"provider": {
"aifs": {
"npm": "@ai-sdk/openai-compatible",
"name": "AI Foundation Services",
"options": {
"baseURL": "https://llm-server.llmhub.t-systems.net/v2/coding",
"apiKey": "{env:OPENAI_API_KEY}"
},
"models": {
"gpt-oss-120b": { "name": "GPT-OSS 120B (T Cloud)" },
"GLM-5.3": { "name": "GLM 5.3 (T Cloud)" },
"GLM-5.3-Flash": { "name": "GLM 5.3 Flash (T Cloud)" }
}
}
},
"permission": {
"edit": "allow"
}
}

OpenCode reads the key from OPENAI_API_KEY through {env:…}. If you already connected with /connect, the key is stored and you can drop the apiKey line. Custom providers use the @ai-sdk/openai-compatible package and need every model listed under models; see the OpenCode provider docs.