Overview
OpenCode is an open-source AI coding assistant that runs in your terminal. It supports multiple LLM providers and can be configured to use LemonData’s API for access to 300+ models.Installation
- Install Script
- Homebrew
- Go
Configuration
Step 1: Set Environment Variables
~/.bashrc or ~/.zshrc:
Step 2: Configure OpenCode
Create or edit~/.config/opencode/opencode.json (global) or opencode.json in your project root:
Basic Usage
Start interactive mode:Available Models
| Model | Best For |
|---|---|
gpt-4o | Complex tasks, code architecture |
gpt-4o-mini | Quick fixes, simple queries |
claude-sonnet-4-5 | Code review, documentation |
claude-opus-4-5 | Complex reasoning |
gemini-2.5-flash | Fast responses |
deepseek-r1 | Algorithm design |
Common Commands
Analyze code:Interactive Commands
| Command | Description |
|---|---|
/help | Show available commands |
/model <name> | Switch to a different model |
/clear | Clear conversation history |
/exit | Exit OpenCode |
Troubleshooting
Connection Error
Connection Error
- Verify
LOCAL_ENDPOINTis set tohttps://api.lemondata.cc/v1 - Check network connectivity
- Try
curl https://api.lemondata.cc/v1/modelsto test
Authentication Failed
Authentication Failed
- Verify
OPENAI_API_KEYenvironment variable is set - Check that the key starts with
sk- - Ensure the key is active in LemonData dashboard
Model Not Found
Model Not Found
- Check model name in config matches exactly
- Verify model availability at lemondata.cc/en/models
Best Practices
Use project context
Use project context
Run OpenCode from your project root for better understanding of your codebase.
Choose appropriate models
Choose appropriate models
Use faster models (gpt-4o-mini) for simple tasks, powerful models (gpt-4o, claude) for complex ones.
Review generated code
Review generated code
Always review AI-generated code before applying changes to your project.