Skip to main content

Integrate Morpheus AI with OpenCode


Learn how to set up Morpheus AI as a custom provider in OpenCode, giving you access to powerful 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 get access to powerful open-source models with OpenCode’s privacy-first architecture.

Overview

OpenCode supports multiple AI providers. By integrating Morpheus AI, you gain access to models optimized for code generation, reasoning, and development tasks.
Base URL: https://api.mor.org/api/v1

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.
  1. On the main page (API Keys) Click Create New Key
  2. Provide a descriptive name for the key
  3. Copy the generated API key (starts with sk-)
Store your API key securely. You won’t be able to view it again after the initial creation. Never commit API keys to version control.
2

Install OpenCode

If you haven’t already, install OpenCode on your system:
brew install opencode
Verify installation by running opencode --version in your terminal.
3

Launch OpenCode

Start OpenCode for the first time:
opencode
You’re now ready to configure Morpheus AI as a provider.

Configuring the Provider

Create your OpenCode configuration file to define the Morpheus AI provider and available models.

Create the Configuration File

Full Provider Configuration

Copy and paste the following configuration into your opencode.json file:
opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "morpheus-ai": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Morpheus AI",
      "options": {
        "baseURL": "https://api.mor.org/api/v1"
      },
      "models": {
        "glm-4.7": {
          "name": "GLM 4.7",
          "limit": {
            "context": 198000,
            "output": 65536
          }
        },
        "glm-4.7:web": {
          "name": "GLM 4.7 (Web)",
          "limit": {
            "context": 198000,
            "output": 65536
          }
        },
        "glm-4.7-thinking": {
          "name": "GLM 4.7 Thinking",
          "limit": {
            "context": 198000,
            "output": 65536
          }
        },
        "glm-4.7-thinking:web": {
          "name": "GLM 4.7 Thinking (Web)",
          "limit": {
            "context": 198000,
            "output": 65536
          }
        },
        "gpt-oss-120b": {
          "name": "GPT OSS 120B",
          "limit": {
            "context": 128000,
            "output": 8192
          },
          "options": {
            "timeout": 600000
          }
        },
        "gpt-oss-120b:web": {
          "name": "GPT OSS 120B (Web)",
          "limit": {
            "context": 128000,
            "output": 8192
          },
          "options": {
            "timeout": 600000
          }
        },
        "qwen3-coder-480b-a35b-instruct": {
          "name": "Qwen3 Coder 480B",
          "limit": {
            "context": 256000,
            "output": 16384
          },
          "options": {
            "timeout": 600000
          }
        },
        "qwen3-coder-480b-a35b-instruct:web": {
          "name": "Qwen3 Coder 480B (Web)",
          "limit": {
            "context": 256000,
            "output": 16384
          },
          "options": {
            "timeout": 600000
          }
        },
        "kimi-k2-thinking": {
          "name": "Kimi K2 Thinking",
          "limit": {
            "context": 256000,
            "output": 16384
          }
        },
        "kimi-k2-thinking:web": {
          "name": "Kimi K2 Thinking (Web)",
          "limit": {
            "context": 256000,
            "output": 16384
          }
        }
      }
    }
  }
}
Save the file: If using nano, press Ctrl+O to save, then Ctrl+X to exit. If using vim, press Esc then type :wq and press Enter.

Understanding the Configuration

  • npm: The AI SDK package used (@ai-sdk/openai-compatible for OpenAI-compatible APIs)
  • name: Display name shown in the OpenCode UI
  • options.baseURL: The Morpheus AI API endpoint (https://api.mor.org/api/v1)
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)
Models with the :web suffix have enhanced capabilities:
  • Web search integration
  • Current information access
  • Browser-optimized responses
Standard models without :web are optimized for pure reasoning and code generation tasks.

Minimal Configuration

If you prefer a simpler setup with just one model to start:
opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "morpheus-ai": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Morpheus AI",
      "options": {
        "baseURL": "https://api.mor.org/api/v1"
      },
      "models": {
        "glm-4.7": {
          "name": "GLM 4.7"
        }
      }
    }
  }
}
Start with a minimal configuration and add more models as needed. See the Available Models page for the full list of models you can add.

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

Launch OpenCode

Open your terminal and start OpenCode:
opencode
This will open the OpenCode TUI (terminal user interface).
2

Execute the connect command

Inside OpenCode, run the connect command:
/connect
3

Select Morpheus AI

Type morpheus to filter the providers, then select Morpheus AI from the list:
┌  Connect a provider

│  morpheus

│  Other
│  Morpheus AI

4

Enter your API key

Paste your Morpheus AI API key when prompted:
┌  Add credential

│ ◇  Enter your API key
│  sk-xxxxxxxxxxxxx

5

Select a model

Choose the model you want to use from the list. All models from your configuration will appear:
┌  Morpheus AI

│  Search

│  Morpheus AI
│  GLM 4.7
│  GLM 4.7 (Web)
│  ● GLM 4.7 Thinking
│  GLM 4.7 Thinking (Web)
│  GPT OSS 120B

You’re now connected to Morpheus AI and ready to start coding!

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
> Create a Python function that validates email addresses using regex

> Debug this TypeScript error: Type 'number' is not assignable to type 'string'

> Refactor this code to use async/await instead of callbacks

> Explain how this binary search algorithm works

Available Models

The following models are included in the configuration above:
ModelContextOutputBest For
GLM 4.7198K65KGeneral purpose, long context, documentation
GLM 4.7 Thinking198K65KExtended thinking, analysis, reasoning
GPT OSS 120B128K8KGPT-style responses, function calling
Qwen3 Coder 480B256K16KComplex code generation, architecture design
Kimi K2 Thinking256K16KComplex problem solving, multi-step reasoning
For additional models, see the Available Models page. You can add any model from that page to your configuration by following the same format shown above.

Verifying Your Setup

Check Authentication Status

Verify that your Morpheus AI credentials are stored correctly:
opencode auth list
You should see 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:
> What is Python?
If you receive a response from the selected Morpheus AI model, your integration is working correctly!

Troubleshooting

Cause: Provider ID mismatch, configuration syntax error, or OpenCode not restarted.Solution:
  1. Verify the provider ID in both /connect and opencode.json exactly matches morpheus-ai
  2. Check that your JSON configuration is valid (no missing commas, brackets)
  3. Restart OpenCode completely
  4. Verify credentials with opencode auth list
# Validate JSON syntax
cat ~/.config/opencode/opencode.json | python -m json.tool

# Check credentials
opencode auth list
Cause: Invalid or expired API key, or incorrect provider configuration.Solution:
  1. Ensure your API key is valid and active at app.mor.org
  2. Verify the provider ID matches what you used in /connect
  3. Try regenerating your API key if needed
  4. Reconfigure credentials using /connect command
# Remove old credentials and reconfigure
opencode auth remove morpheus-ai
opencode
/connect
Cause: Network connectivity issues, firewall blocking, or service unavailability.Solution:
  1. Check your internet connection
  2. Verify the baseURL is correct: https://api.mor.org/api/v1
  3. Ensure your firewall allows HTTPS connections
  4. Check the Morpheus AI service status
For large models like Qwen3 Coder 480B and Hermes 3 Llama 405B, timeouts are pre-configured to 600000ms (10 minutes). If you still experience timeouts, consider using a smaller model or checking your network connection.
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_model in your opencode.json for rapid iterations
  • Try different models to find the best balance of performance and speed
  • Check your network latency to the Morpheus API
{
  "model": "morpheus-ai/qwen3-coder-480b-a35b-instruct",
  "small_model": "morpheus-ai/hermes-4-14b"
}
Cause: Wrong file location or OpenCode not looking in the right directory.Solution:
  1. For global configuration: ~/.config/opencode/opencode.json
  2. For project-specific: ./opencode.json in your project root
  3. Ensure the file has correct permissions
  4. Verify JSON syntax is valid
# Create config directory if missing
mkdir -p ~/.config/opencode

# Set proper permissions
chmod 644 ~/.config/opencode/opencode.json

Security Notes

Follow these security best practices to protect your API credentials:
  • 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
  • Rotate compromised keys: If your API key is compromised, immediately rotate it via the Morpheus AI dashboard

Additional Resources

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
Happy coding with Morpheus AI!