Skip to content

Documentation OpenCode

Tool integrations

OpenCode

Add Morfac as a custom provider in OpenCode.

Prepare a key#

Install OpenCode and prepare a Morfac key from the console. Set it in the terminal where you will launch OpenCode:

Shell
export MORPH_API_KEY="your-api-key"

Configure the provider#

Create or update opencode.json in your project or ~/.config/opencode/. Merge the morph provider into any existing configuration. This example uses the OpenCode 1.x configuration format.

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "morph": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Morfac",
      "options": {
        "baseURL": "https://api.dev.morphfactory.io/v1",
        "apiKey": "{env:MORPH_API_KEY}"
      },
      "models": {
        "motif/motif-3": { "name": "Motif-3" }
      }
    }
  },
  "model": "morph/motif/motif-3"
}

Start opencode from the same terminal. Check the selected provider and model; use /models to select Motif-3 under Morfac if needed. Ask a short text question in a new conversation.

Troubleshooting#

The model selector includes the provider prefix: morph/motif/motif-3. The API model ID itself is motif/motif-3. Check that MORPH_API_KEY is available to the process. See OpenCode custom providers for version-specific configuration and API troubleshooting for response errors.