Skip to content

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:

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:

  1. Scans your project directory structure
  2. Identifies key files and components
  3. Creates an AGENTS.md file in your project root
  4. 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:

  1. Code Explanation: “Explain how the authentication flow works in this project”
  2. Bug Fixing: “Find and fix the bug in the login component”
  3. Refactoring: “Refactor the user profile component to use hooks”
  4. Documentation: “Generate documentation for the API endpoints”
  5. Testing: “Write unit tests for the checkout functionality”

Verification

To verify your setup is working correctly:

  1. Run opencode models to see the available models from your configured provider
  2. Run opencode stats to check your usage statistics
  3. 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!