OpenCode

OpenCode is a CLI + TUI AI coding agent that runs in the terminal. By configuring it, you can connect to AI models on the Unisound Maas Platform through two access methods: pay-as-you-go and U Plan.

1. Preparation

Get configuration credentials

Two usage methods are supported, but the way to obtain the corresponding credentials differs.

Usage
Description
How to get it (the API Key below is an example)
Pay-as-you-go API calls
Billed based on actual usage, suitable for light usage
  • Base URL OpenAI-compatible protocol: https://maas-api.unisound.com/v1
  • API Key
  • Format: sk-xxxxx

Go to API Key Management to create an API Key

U Plan
Fixed subscription pricing with usage quotas based on the selected plan
  • Base URL OpenAI-compatible protocol: https://maas-api.unisound.com/v1
  • API Key
  • Format: tp-xxxxx

After subscribing successfully, go to Subscription Management to get the dedicated API Key

2. Install OpenCode

  1. Install Node.js (v18.0 or later).
  2. Run the following command in the terminal to install OpenCode

Install Command

Bash
npm install -g opencode-ai

Run the following command to verify the installation. If a version number is returned, the installation was successful.

Bash
opencode -v

3. Configure the U2-Flash model

1. Configure basic information

Edit or create the opencode.json configuration file at the following path:

  • macOS/Linux: ~/.config/opencode/opencode.json
  • Windows: <user directory>\.config\opencode\opencode.json

Copy the following content in full into the configuration file (replace UNISOUND_API_KEY as needed in actual use):

JSON
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "unisound": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "U2-Flash",
      "options": {
        "baseURL": "https://maas-api.unisound.com/v1",
        "apiKey": "UNISOUND_API_KEY"
      },
      "models": {
        "u2-flash": {
          "name": "u2-flash"
        }
      }
    }
  }
}

Use OpenCode CLI

After the configuration is complete, enter the project directory and run the following command to start OpenCode:

Bash
opencode

After startup, enter /models  to view and switch the model in use.

4. Model Skill

We provide built-in U2-ASR, U2-TTS, U2-TTS-Clone, and U2-OCR capabilities. You only need to add the corresponding model Skill in OpenCode to quickly call these model services without integrating each model API separately.

Click the links below to open the corresponding Skill pages. You can install each Skill via chat or the command line. After installation, the Skill will guide you through configuring the related models.

Model
Skill Name
Skill Description
Action
U2-OCR
u1-ocr-parser-pro
Document Parsing
U2-OCR
u1-ocr-extract-pro
Document Information Extraction and Classification
U2-OCR-Med
u1-ocr-med-pro
Medical Document Information Extraction and Classification
U2-ASR
u2-asr-pro
Speech Transcription
U2-TTS
u2-tts-pro
Speech Synthesis
U2-TTS-Clone
u2-tts-clone-pro
Voice Cloning