Quick Start
Get up and running with Opencode in less than 5 minutes.
Prerequisites
- macOS or Linux (Windows WSL2 supported)
- Node.js 18+ (for some language servers)
- An API Key (OpenAI, Anthropic, or Gemini)
Installation
Run the following command in your terminal to download and install the binary:
curl -sL opencode.ai/install | bash
Configuring API Key
Once installed, you need to configure your API key for the AI provider of your choice. This allows Opencode to make requests to the AI models.
Step 1: Obtain API Key
First, you need to obtain an API key from your preferred AI provider:
- Anthropic: Sign up at Anthropic Console and create an API key
- OpenAI: Sign up at OpenAI Platform and create an API key
- Gemini: Sign up at Google AI Studio and create an API key
Step 2: Configure API Key
Run the opencode auth login command to configure your API key:
# Start interactive authentication
opencode auth login
# Or authenticate with a specific provider
opencode auth login --provider anthropic
You will be prompted to enter your API key. Once entered, it will be securely stored in ~/.local/share/opencode/auth.json.
Project Initialization
To help Opencode understand your project structure better, you should initialize your project with the /init command. This creates an AGENTS.md file that documents your project’s structure and key components.
Using the /init Command
Option 1: From the Terminal
Navigate to your project directory and run:
opencode init
Option 2: From the TUI
Start the Opencode TUI:
opencode tui
Then type the /init command:
/init
What the /init Command Does
The /init command:
- Scans your project directory structure
- Identifies key files and components
- Creates an
AGENTS.mdfile in your project root - Documents important project information for the AI to reference
This helps the AI understand your codebase better, leading to more accurate and relevant responses.
Your First Task
Now that you’ve configured your API key and initialized your project, you’re ready to start using Opencode.
Start the TUI
opencode tui
Example Tasks
Here are some example tasks you can try:
- Code Explanation: “Explain how the authentication flow works in this project”
- Bug Fixing: “Find and fix the bug in the login component”
- Refactoring: “Refactor the user profile component to use hooks”
- Documentation: “Generate documentation for the API endpoints”
- Testing: “Write unit tests for the checkout functionality”
Verification
To verify your setup is working correctly:
- Run
opencode modelsto see the available models from your configured provider - Run
opencode statsto check your usage statistics - Try a simple query like “Explain how to use promises in JavaScript”
Next Steps
- Explore the Configuration page to customize Opencode to your workflow
- Check out the CLI Reference for more commands
- Visit the Ecosystem page to discover community tools and resources
Happy coding with Opencode!