Skip to main content
OpenCode is an open-source AI coding agent for developers, focused on a terminal-native experience: through a TUI/CLI, you can discuss requirements, generate code, refactor, explain, debug, and complete other workflows directly in the command line. It emphasizes being model-agnostic and can connect to model services such as Claude, GPT, and Gemini, as well as local or OpenAI-compatible endpoints, making it easy to balance cost, performance, and privacy. OpenCode also provides an extensible plugin/tool mechanism and configuration system, enabling capabilities such as project context and command execution to be integrated into automated workflows. It is well suited for heavy terminal users and teams that want to customize AI coding workflows.

Installation and Integration

Installation

For other installation methods, see the OpenCode official website: https://opencode.ai/docs/#install

Start OpenCode

Connect to the JieKou API

  • Global configuration: ~/.config/opencode/opencode.json
  • Project configuration: opencode.json in the project root directory
(If opencode.json does not exist, you can create it manually.) Configure as follows:
When configuring a third-party provider, make sure to choose the correct npm package: Note: Codex models (such as gpt-5.1-codex) need to use @ai-sdk/openai (Response API). Other models should use @ai-sdk/openai-compatible (Chat Completion API).

Configure the KEY

Enter opencode, use /connect to select a provider, then enter the API KEY and press Enter to confirm. opencode_input_api_key

Start Using

After connecting to the provider, you can use the /models command to select a model. opencode_choose_model

Other Usage

Example: Local MCP Configuration (using a calculator MCP as an example)

  1. Use python + MCP SDK to write the calculator mcp server code and save it to a local path.
  1. Add the local mcp to opencode.json.
  1. Use /mcps to view the mcp connection status. When it is Enabled, you can ask opencode to call it.
opencode_mcp