Integrate Morpheus AI with OpenCode
Learn how to set up Morpheus AI as a custom provider in OpenCode, giving you access to powerful, decentralized AI models for coding assistance. This guide walks you through credential setup, provider configuration, and model selection.What is OpenCode?
OpenCode is an open-source AI coding agent that helps you write code in your terminal, IDE, or desktop application. It’s a powerful alternative to proprietary coding assistants like Claude Code, offering complete flexibility and privacy for developers.Open Source & Free
Over 41,000 GitHub stars and 450 contributors building the future of AI-powered coding.
Privacy First
OpenCode doesn’t store any of your code or context data, making it ideal for sensitive projects.
Any Model, Any Provider
Connect to 75+ LLM providers including Claude, GPT, Gemini, local models, and now Morpheus AI.
Multi-Platform
Available as terminal interface, desktop app (macOS, Windows, Linux), and IDE extensions.
Key Features
- LSP Enabled: Automatically loads the right Language Server Protocols for enhanced LLM understanding
- Multi-Session: Run multiple AI agents in parallel on the same project
- Share Links: Share session links for collaboration and debugging
- Claude Pro Support: Use your existing Claude Pro or Max subscription
- 400,000 Monthly Users: Trusted by developers worldwide for production use
By integrating Morpheus AI with OpenCode, you combine the power of decentralized, free AI inference with OpenCode’s privacy-first, open-source architecture.
Overview
OpenCode is an open-source AI coding assistant that supports multiple AI providers. By integrating Morpheus AI, you gain access to free, decentralized AI inference through the Morpheus marketplace with models optimized for code generation, reasoning, and development tasks.The Morpheus API Gateway is currently in Open Beta, providing free access to AI inference without requiring wallet connections or staking MOR tokens.
Prerequisites
Before you begin, ensure you have:- OpenCode installed on your system opencode.ai/docs
- A Morpheus AI account at app.mor.org
- Basic familiarity with JSON configuration files
- Access to your system’s terminal or command line
1
Get Your Morpheus AI API Key
Visit app.mor.org and create your API key.
- On the main page (API Keys) Click Create New Key
- Provide a descriptive name for the key
- Copy the generated API key (starts with
sk-)
2
Install OpenCode
If you haven’t already, install OpenCode on your system:
- macOS
- Linux
- Windows
Verify installation by running
opencode --version in your terminal.3
Launch OpenCode
Start OpenCode for the first time:You’re now ready to configure Morpheus AI as a provider.
Configuring the Provider
Create or update your OpenCode configuration to define the Morpheus AI provider and available models.Configuration Location
- Global Configuration (Recommended)
- Project Configuration
Edit the global configuration file:This makes Morpheus AI available across all your projects.
Full Provider Configuration
Add the following configuration to youropencode.json file:
opencode.json
Understanding the Configuration
Provider Settings
Provider Settings
- npm: The AI SDK package used (
@ai-sdk/openai-compatiblefor OpenAI-compatible APIs) - name: Display name shown in the OpenCode UI
- options.baseURL: The Morpheus AI API endpoint (
https://api.mor.org/api/v1)
Model Configuration
Model Configuration
Each model includes:
- name: Human-readable model name displayed in the UI
- limit.context: Maximum input tokens the model accepts
- limit.output: Maximum tokens the model can generate
- options.timeout: Optional timeout in milliseconds (used for large models)
Web Model Variants
Web Model Variants
Models with the
-web suffix have enhanced capabilities:- Web search integration
- Current information access
- Browser-optimized responses
-web are optimized for pure reasoning and code generation tasks.Minimal Configuration
If you prefer a simpler setup with just essential models:opencode.json
Adding Morpheus AI Credentials
OpenCode stores API credentials securely in~/.local/share/opencode/auth.json. Use the /connect command to add your Morpheus AI API key.
Using the /connect Command
1
Execute the connect command
In the OpenCode terminal, run:
2
Select 'Other' as the provider
When prompted to select a provider, choose Other:
3
Enter the provider ID
Type
morpheus-ai as the provider identifier:The provider ID must exactly match
morpheus-ai for the configuration to work correctly.4
Paste your API key
Enter your Morpheus AI API key when prompted:
Your Morpheus AI credentials are now securely stored and ready to use with your configured provider!
Setting Default Models
Configure your preferred models for different types of tasks:opencode.json
Default model used for main coding tasks, complex reasoning, and detailed responses.
Faster, smaller model used for quick tasks like syntax checking, simple completions, and rapid iterations.
Using Morpheus AI in OpenCode
Once configured, restart OpenCode to load the new provider settings.Restart OpenCode
Select a Model
Use the/models command to view and select from available Morpheus AI models:
Start Coding
With Morpheus AI configured, you can now:- Generate code - Ask for implementations, algorithms, or functions
- Debug issues - Get help troubleshooting errors and bugs
- Refactor code - Request improvements and optimizations
- Explain code - Understand complex codebases
- Write tests - Generate test cases and test suites
Available Models
The Morpheus marketplace offers a diverse range of models optimized for different tasks:Premium Models (Best Performance)
| Model | Context | Output | Best For |
|---|---|---|---|
| Qwen3 Coder 480B | 262K | 16K | Complex code generation, architecture design |
| Hermes 3 Llama 405B | 128K | 8K | Advanced reasoning, system design |
| Kimi K2 Thinking | 256K | 16K | Complex problem solving, multi-step reasoning |
| GLM 4.6 | 200K | 65K | Long-form code generation, documentation |
Balanced Models (Great All-Rounders)
| Model | Context | Output | Best For |
|---|---|---|---|
| Qwen3 235B | 131K | 8K | General coding tasks |
| Llama 3.3 70B | 128K | 8K | Code completion, debugging |
| Qwen3 Next 80B | 131K | 4K | Fast responses, quick iterations |
| Mistral 31 24B | 128K | 8K | Balanced performance, good reasoning |
Lightweight Models (Fast & Efficient)
| Model | Context | Output | Best For |
|---|---|---|---|
| Hermes 4 14B | 128K | 4K | Quick completions, syntax help |
| Qwen3 4B | 131K | 4K | Simple tasks, rapid iteration |
| Llama 3.2 3B | 32K | 4K | Lightweight tasks, low-latency responses |
Specialized Models
| Model | Context | Output | Best For |
|---|---|---|---|
| Venice Uncensored | 128K | 8K | Unrestricted content generation |
Model availability depends on provider availability in the Morpheus marketplace. The API automatically routes to the highest-rated provider for your selected model. Check the API documentation for the latest model availability.
Verifying Your Setup
Check Authentication Status
Verify that your Morpheus AI credentials are stored correctly:morpheus-ai in the list of configured credentials.
If
morpheus-ai appears in the list, your credentials are configured correctly.Test the Connection
Start a conversation in OpenCode and ask a simple question:Troubleshooting
Models not appearing in OpenCode
Models not appearing in OpenCode
Cause: Provider ID mismatch, configuration syntax error, or OpenCode not restarted.Solution:
- Verify the provider ID in both
/connectandopencode.jsonexactly matchesmorpheus-ai - Check that your JSON configuration is valid (no missing commas, brackets)
- Restart OpenCode completely
- Verify credentials with
opencode auth list
Authentication errors when using models
Authentication errors when using models
Cause: Invalid or expired API key, or incorrect provider configuration.Solution:
- Ensure your API key is valid and active at app.mor.org
- Verify the provider ID matches what you used in
/connect - Try regenerating your API key if needed
- Reconfigure credentials using
/connectcommand
Connection errors or timeouts
Connection errors or timeouts
Cause: Network connectivity issues, firewall blocking, or service unavailability.Solution:
- Check your internet connection
- Verify the baseURL is correct:
https://api.mor.org/api/v1 - Ensure your firewall allows HTTPS connections
- Check the Morpheus AI service status
Slow response times
Slow response times
Cause: Large model selected, high marketplace demand, or network latency.Solution:
- Use smaller models for quick tasks (e.g.,
llama-3.3-70b,hermes-4-14b) - Configure a
small_modelin youropencode.jsonfor rapid iterations - Try different models to find the best balance of performance and speed
- Check your network latency to the Morpheus API
Configuration file not found or ignored
Configuration file not found or ignored
Cause: Wrong file location or OpenCode not looking in the right directory.Solution:
- For global configuration:
~/.config/opencode/opencode.json - For project-specific:
./opencode.jsonin your project root - Ensure the file has correct permissions
- Verify JSON syntax is valid
Best Practices
Choose the right model
Select models based on your task complexity. Use large models for complex reasoning and smaller models for quick completions.
Configure small_model
Set a lightweight model as your
small_model for faster responses on simple tasks, improving your coding workflow.Secure your API key
Never commit your API key to version control. Keep it in the secure OpenCode auth storage or environment variables.
Switch models freely
Use the
/models command to try different models. Each excels at different tasks - find what works best for you.Use Web variants strategically
Leverage
-web suffix models when you need current information or web-enhanced responses. Use standard models for pure coding tasks.Monitor performance
Pay attention to response times and quality. Adjust your model selection based on your workflow needs.
Advanced Configuration
Project-Specific Models
Override global settings for specific projects:project-root/opencode.json
Custom Model Limits
Adjust context and output limits based on your needs:opencode.json
Additional Resources
Morpheus AI Portal
Manage your API keys, view usage, and access your Morpheus AI account.
API Documentation
Complete reference documentation for the Morpheus API Gateway.
OpenCode Documentation
Learn more about OpenCode provider configuration and advanced features.
Community Support
Join the OpenCode Discord community for help and discussions.
Security Notes
- Local storage: Your API key is stored locally in
~/.local/share/opencode/auth.json - Never commit keys: Don’t commit API keys or configuration files with credentials to public repositories
- Add to .gitignore: Include both
~/.config/opencode/opencode.jsonand~/.local/share/opencode/auth.jsonin your.gitignoreif sharing config files - Rotate compromised keys: If your API key is compromised, immediately rotate it via the Morpheus AI dashboard
- Use project configs carefully: Ensure project-specific
opencode.jsonfiles don’t contain sensitive information
Next Steps
Once configured, you can:1
Switch between models
Use the
/models command to select different models for various tasks and compare their performance.2
Create project configurations
Set up project-specific
opencode.json files with models optimized for each project’s needs.3
Optimize your workflow
Adjust context and output limits based on your typical use cases to balance performance and capability.
4
Monitor usage
Track your usage and billing in the Morpheus AI dashboard at app.mor.org.
Summary
You’ve successfully integrated Morpheus AI with OpenCode! Here’s what you’ve accomplished:Credentials configured: Added your Morpheus AI API key securely to OpenCode
Provider setup: Configured the Morpheus AI provider with access to powerful coding models
Model selection: Learned how to choose and switch between models for different tasks
Best practices: Understand security, performance optimization, and troubleshooting
Free inference: Enabled access to decentralized AI models during the Open Beta

