OpenCode is an AI programming intelligence designed for terminal environments. It is completely open source and allows developers to perform tasks such as code generation, modification and debugging without leaving the command line interface. The core feature of this tool is its flexibility and openness. It does not depend on any specific AI model vendor, and users can choose to access models from Anthropic, OpenAI, Google, or even private models deployed locally, according to their needs and preferences. This design not only avoids vendor lock-in, but also allows users to benefit from continuous competition in model pricing and performance.OpenCode uses a Client/Server architecture, which means that its core services can run on a single computer, and developers can connect to and operate it remotely from another device (e.g., a laptop or mobile device). For developers accustomed to using endpoint tools such as Neovim, OpenCode provides a seamless interactive experience that integrates AI programming capabilities directly into the work environments they are most familiar with.
Function List
- Endpoint Native Experience: Provide a complete Terminal User Interface (TUI) that allows developers to smoothly interact with the AI from the command line.
- Models are not locked: Supports access to a wide range of large language models, including Anthropic (recommended), OpenAI, Google, and locally run open source models.
- open source: Project 100% open source , using the MIT license , developers are free to review , modify and distribute .
- Client/Server Architecture: Allows AI Intelligent Body services to be deployed on a remote server and connected and operated via a local terminal or other client.
- Cross-platform installation: Provide a variety of convenient installation methods, support macOS, Linux and other major operating systems, and adapt different package managers.
- community-driven: The project is jointly maintained by the community and developers are encouraged to contribute code, fix bugs and improve documentation.
Using Help
OpenCode, as an end-to-end tool for developers, has a carefully designed installation and usage process designed to simplify operations and allow users to get started quickly.
Installation process
OpenCode offers several installation methods to accommodate different operating systems and user preferences. Just choose the one that best suits your environment.
1. Quick installation (recommended)
For most macOS and Linux users, the quickest way to install is to use the officially provided one-click install script. Open your terminal, copy and execute the following command:
curl -fsSL https://opencode.ai/install | bash
This script will automatically detect your system environment and install OpenCode in the appropriate directory.
2. Installation using a package manager
If you are used to using a package manager to manage your software, OpenCode provides support for that as well.
- For npm / bun / pnpm / yarn users::
You can install OpenCode as a global tool via npm.npm i -g opencode-ai@latest
- For macOS and Linux Homebrew users::
First, you need to addsst/tap
This software source and then install it directly.brew install sst/tap/opencode
- For Arch Linux users::
You can use theparu
or other AUR assistant to installopencode-bin
Theparu -S opencode-bin
Important Notes: Before installing a new version, make sure to uninstall all versions with version numbers lower than 0.1.x
of an older version to avoid conflicts.
Customizing the installation directory
By default, the installation script determines the installation path in the following order of priority:
$OPENCODE_INSTALL_DIR
: If you set this environment variable, it will be used as the highest priority installation directory.$XDG_BIN_DIR
: Paths that follow the XDG base directory specification.$HOME/bin
: This standard personal binary file directory is used if it exists or can be created.$HOME/.opencode/bin
: The default alternate installation path.
If you wish to install OpenCode to a specific location, for example /usr/local/bin
You can set the environment variables before executing the installation script:
OPENCODE_INSTALL_DIR=/usr/local/bin curl -fsSL https://opencode.ai/install | bash
Basic use
Once installed, you can launch and use OpenCode directly from the terminal, where the core interaction model is very intuitive, allowing you to give commands to the AI intelligences through a dialog in the terminal.
- Starting OpenCode::
In the terminal, typeopencode
command and enter to launch its Terminal User Interface (TUI). - Interacting with AI::
Upon launch, you will enter an interactive environment. Here, you can directly enter your requirements as if you were using a chat tool. Example:- "Please help me write a Python function to compute the Fibonacci series."
- "Analyze the performance bottlenecks in this code and give recommendations for optimization."
- "Convert this JSON file to CSV format."
- code operation::
Once the AI generates code, you can easily copy, modify, or save it directly to a file.OpenCode's TUI is designed with reference to the operating habits of terminal editors such as Neovim, making the whole process very efficient.
Configuration
An important feature of OpenCode is that it is not tied to any one AI model vendor. You need to specify the model you wish to use in the configuration file. For details on how to configure it, you can refer to its official documentation. Usually, you need to provide the API Key (API Key) of your chosen AI service provider and configure it into OpenCode's settings. This way, you have the flexibility to switch and always choose the most cost-effective model to serve you.
For more detailed configuration and advanced usage, such as how to set up a local model, how to connect remotely, etc., please visit the official documentation for further guidance.
application scenario
- Rapid development and prototyping within the terminal
When working in the terminal environment, developers do not need to switch to a browser or IDE, and when they need to write a new function, implement an algorithm, or parse a piece of data, they can launch OpenCode directly in the terminal, describe their needs in natural language, and the AI will quickly generate the corresponding code snippet. The developer can immediately use the code for the current project, which greatly improves the development efficiency. - Remote server programming and maintenance
When connecting to a remote server via SSH for development or maintenance, tools with graphical interfaces are usually not available.OpenCode, as a terminal-native tool, works perfectly on remote servers. Whether it's writing deployment scripts, analyzing log files, or quickly fixing code on the wire, it provides powerful AI-assisted capabilities. - Learn new technologies and APIs
When learning a new programming language, framework, or unfamiliar library, developers often need to consult extensive documentation. With OpenCode, it's possible to ask questions like "How do I send a POST request with authentication in Python using the requests library?" or "Show me an example of a timer using React Hooks". Or "Show me an example of using React Hooks to implement a timer", and the AI will directly give you a working code example to speed up the learning process. - Automation scripting
For system administrators and DevOps engineers, writing shell scripts, Python scripts to automate daily tasks is a common occurrence. OpenCode can be used as a powerful scripting assistant to help them quickly generate script code for file handling, system monitoring or service management, reducing errors and time spent on manual writing.
QA
- What is the difference between OpenCode and Claude Code?
They are similar in their capabilities, but there are several key differences:- open source: OpenCode is 100% open source, while Claude Code is a closed source product.
- Model Flexibility: OpenCode is not tied to any single vendor and supports OpenAI, Google, Anthropic, and local models, giving users more options.
- interactive interface: OpenCode focuses on the Terminal User Interface (TUI), providing the ultimate interactive experience for command line users.
- build: Adopts client/server architecture and supports remote operation, increasing the flexibility of use.
- What AI models are supported by OpenCode?
OpenCode supports a variety of mainstream large language modeling services, including but not limited to Anthropic (officially recommended), OpenAI (e.g., GPT series), and Google (e.g., Gemini series). It also supports connecting locally deployed open source models, giving users full freedom of choice. - How should I contribute to the OpenCode project?
The project team welcomes contributions from the community, especially in the following areas: fixing program bugs, improving the performance of LLM, adding support for new AI model vendors, resolving compatibility issues in specific environments, and improving documentation. However, major changes to core functionality need to be discussed with the core team through the design process first. It is recommended to check the project's contribution history to understand what types of merge requests are more likely to be accepted before submitting a PR (Pull Request).