碳塑复材科技(郑州)有限公司
Section navigation

Oh My Pi

Connect Oh My Pi to 魔方AI with an OpenAI-compatible provider in models.yml.

Before you begin

  • Create an active 魔方AI token and note the exact model IDs available to it.
  • Use https://www.mofangai001.cn/v1 as the 魔方AI OpenAI-compatible base URL.
  • If you install with Bun, use Bun 1.3.14 or later.

Configuration steps

1. Install Oh My Pi

On macOS or Linux, run the official installer:

curl -fsSL https://omp.sh/install | sh

On Windows PowerShell, run:

irm https://omp.sh/install.ps1 | iex

You can also install OMP with Bun:

bun install -g @oh-my-pi/pi-coding-agent

Verify the installation:

omp --version

2. Set the 魔方AI token

On macOS, Linux, or WSL:

export MOFANG_API_KEY="sk-your-api-key"

On Windows PowerShell:

$env:MOFANG_API_KEY = "sk-your-api-key"

OMP first interprets an apiKey value in models.yml as an environment variable name, so the configuration can safely reference MOFANG_API_KEY.

3. Add the 魔方AI provider

Open ~/.omp/agent/models.yml, creating it if necessary. Add the following configuration, or merge the mofang entry into an existing providers object:

providers:
    mofang:
        baseUrl: https://www.mofangai001.cn/v1
        apiKey: MOFANG_API_KEY
        api: openai-completions
        authHeader: true
        models:
            - id: your-model-id
              name: Your Model

Replace your-model-id with the complete model ID shown in 魔方AI. openai-completions calls /v1/chat/completions, so keep the trailing /v1 in baseUrl and do not create /v1/v1.

4. Select the 魔方AI model

Start OMP with an explicit model:

omp --model mofang/your-model-id

Alternatively, start omp and use /model in the session to choose mofang/your-model-id. The current preferred option is --model; --provider is legacy.

Verify the connection

Send a simple test request, such as asking the model to describe the current project directory. A streamed response with mofang/your-model-id shown as the active model confirms the connection.

You can also list loaded models:

omp models

Troubleshooting

Why must the base URL include /v1?

OMP's openai-completions transport calls /chat/completions relative to the base URL. The 魔方AI OpenAI-compatible base URL is https://www.mofangai001.cn/v1.

Why does the model not appear under /model?

Check the YAML indentation, the model id, and the MOFANG_API_KEY environment variable. If configuration validation fails, OMP continues with built-in models but the custom provider will not load correctly.

Why do requests return 401?

Confirm that the process starting OMP can read MOFANG_API_KEY, and that the token is unexpired and has available quota. authHeader: true sends it as a Bearer token.

Should I copy another provider's compat configuration?

Usually not. compat handles endpoint-specific request differences and should only be added after confirming that a particular 魔方AI model needs it. Do not copy provider-specific values blindly.

Security

Do not commit the token directly to models.yml or a source repository. Use an environment variable, and do not share configuration screenshots or logs containing request headers. Create a dedicated OMP token with model, quota, and IP restrictions.

Official resources