Skip to content
Sign in

OpenCode integration guide

Developer toolCLI toolUpdated: 2026-04-17

Introduction

OpenCode is an open-source AI coding assistant that runs in your terminal, helping you write, debug and refactor code conversationally. Point it at the SeaWhale AI API and you can use Claude, GPT-5, Qwen and other powerful models.

Key capabilities

  • 💻 Code generation — generate code from a natural language description
  • 🐛 Debugging — locate and fix bugs quickly
  • ♻️ Refactoring — improve code structure and performance
  • 📝 Documentation — add comments and docs to your code
  • 🔍 Code explanation — make sense of complex logic
  • 🚀 Many languages — Python, JavaScript, Java, Go and more

Why SeaWhale AI?

AdvantageDescription
🌐 Direct accessReachable directly, stable connectivity
💰 Flexible billingPay as you go, no subscription required
High performanceLow latency, fast responses
🔒 Data securityCode is not stored, protecting your privacy
🤖 Many modelsClaude, GPT-5, Qwen and more
🆓 New user creditNew accounts receive free credit

Supported models

Through the OpenAI-compatible endpoint, SeaWhale AI supports:

FamilyRecommended modelStrengthsBest for
Claude Sonnetclaude-sonnet-4-6Strong at code, accurate reasoning, 200K contextComplex projects, refactoring
Claude Opusclaude-opus-4-7Highest capability, deep reasoningArchitecture, complex algorithms
GPT-5gpt-5.4Strong multimodal, well balancedEveryday work, varied tasks
DeepSeekdeepseek-v3Flagship open model, excellent at codeCoding tasks
Qwenqwen-maxStrong in Chinese, fast responsesChinese-language projects

Choosing a model

  • Everyday coding: claude-sonnet-4-6 (strong at code, good value)
  • Complex tasks: claude-opus-4-7 (highest capability)
  • Best value: deepseek-v3 (low cost, strong at code)

Before you begin

1. Get a SeaWhale AI API key

  1. Open the SeaWhale AI console
  2. Sign up and log in
  3. Generate an API key on the API management page
  4. Make sure your account has enough balance or free credit
New user credit

New SeaWhale AI accounts receive free starter credit, usable across all model inference services.

2. System requirements

ItemRequirement
Operating systemmacOS 10.15+, Windows 10+, Linux
Node.jsv18.0 or later
npmv7.0+
TerminalA modern terminal with color support

Checking your Node.js version

bash
node -v

Version v18.x.x or later meets the requirement. If Node.js is missing, download it from the Node.js website.

Installing OpenCode

Global install

bash
npm install -g opencode-ai

Verify the installation

bash
opencode -v

A version number means the install succeeded.

Installation notes

  • If installation fails, check that Node.js is version 18 or later
  • To speed up npm, you can switch registries: npm config set registry https://registry.npmmirror.com
  • On macOS/Linux, permission errors can be resolved with sudo npm install -g opencode-ai

Configuring SeaWhale AI

Configuration file (recommended)

Create or edit the OpenCode configuration file:

  • macOS / Linux: ~/.config/opencode/opencode.json
  • Windows: C:\Users\YourName\.config\opencode\opencode.json

About the Base URL

baseURL must end with /v1, otherwise you get a 404 Not Found error.

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "seawhale": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "SeaWhale AI",
      "options": {
        "baseURL": "https://api.atalk-ai.com/v1",
        "apiKey": "sk-xxxxxxxxxxxxxxxx"
      },
      "models": {
        "claude-sonnet-4-6": {
          "name": "Claude Sonnet 4.6",
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 200000,
            "output": 64000
          }
        },
        "claude-opus-4-7": {
          "name": "Claude Opus 4.7",
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 200000,
            "output": 32000
          }
        },
        "deepseek-v3": {
          "name": "DeepSeek V3",
          "modalities": {
            "input": ["text"],
            "output": ["text"]
          },
          "limit": {
            "context": 128000,
            "output": 8192
          }
        },
        "gpt-5.4": {
          "name": "GPT-5.4",
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 128000,
            "output": 16384
          }
        },
        "qwen-max": {
          "name": "Qwen Max",
          "modalities": {
            "input": ["text"],
            "output": ["text"]
          },
          "limit": {
            "context": 32768,
            "output": 8192
          }
        }
      }
    }
  }
}
json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "seawhale": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "SeaWhale AI",
      "options": {
        "baseURL": "https://api.atalk-ai.com/v1",
        "apiKey": "sk-xxxxxxxxxxxxxxxx"
      },
      "models": {
        "claude-sonnet-4-6": {
          "name": "Claude Sonnet 4.6",
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          },
          "limit": {
            "context": 200000,
            "output": 64000
          }
        }
      }
    }
  }
}

Notes

  • Replace sk-xxxxxxxxxxxxxxxx with your real SeaWhale AI API key
  • Quit and restart OpenCode after editing the config for changes to take effect
  • Keep your API key safe and never commit it to a repository

Getting started

Starting OpenCode

bash
cd your-project    # Change into your project
opencode           # Start OpenCode

OpenCode chat interface

TIP

OpenCode uses the current directory as project context, so start it in the right place. If you do not have a project yet, run mkdir my-project && cd my-project first.

Common commands

CommandWhat it does
/connectConnect or switch providers
/modelsBrowse and switch models
/clearClear conversation history
/helpShow help

Switching models

Type /models, search for SeaWhale AI or a model name (such as claude or deepseek), and select the model you want.

OpenCode model selection

Worked examples

Example 1: code generation

👤 User:
Write a Python function that parses a JSON file and returns the values of a given field

🤖 OpenCode:
def extract_field(filepath, field):
    import json
    with open(filepath, 'r', encoding='utf-8') as f:
        data = json.load(f)
    if isinstance(data, list):
        return [item.get(field) for item in data if isinstance(item, dict)]
    elif isinstance(data, dict):
        return data.get(field)
    return None

Example 2: debugging

👤 User:
This function raises KeyError — please fix it:
def get_user_name(user):
    return user['name']

🤖 OpenCode:
Use .get() for safe access with a default value:
def get_user_name(user):
    return user.get('name', 'Unknown user')

Saving tokens

1. Start in the specific project directory

Best practices

  • Start OpenCode inside the specific project directory, not a parent directory
  • Use .gitignore to exclude node_modules/, dist/ and similar
  • Delete or move large binary files (images, archives and so on)

2. Manage conversation history

CommandWhen to useEffect
/clearBefore a new taskClears all history and resets the context

3. Give precise instructions

❌ Vague✅ Precise
"Optimize this code""Refactor parse_data in utils.py to use a list comprehension"
"Fix this for me""Add error handling at line 45 of index.js to catch API failures"
"Something's wrong""Fix the division-by-zero in calc.py and add input validation"

FAQ

Q1: How do I switch to a specific model?

Type /models and search by name (such as claude or gpt-5), then select the model. An empty result means the current version does not support that model yet.

Q2: Connection failures, 401 or 404 errors

  1. Check the API key is correct (it starts with sk-)
  2. Confirm the config path is ~/.config/opencode/opencode.json (the file is opencode.json, not config.json)
  3. Confirm baseURL ends with /v1: https://api.atalk-ai.com/v1
  4. Sign in to the SeaWhale AI console and check your balance
  5. Quit and restart OpenCode after editing the config

Q3: Responses are slow

  • Switch to a lighter model (such as gpt-5-mini or claude-haiku-4-5-20251001)
  • Use /clear to drop a long conversation history and shorten the context

Q4: How do I update OpenCode?

bash
npm install -g opencode-ai@latest

Q5: Which programming languages are supported?

OpenCode supports all mainstream programming languages, including:

Supported languages

Web development: JavaScript, TypeScript, HTML, CSS, Vue, React

Backend development: Python, Java, Go, Rust, C/C++, C#, PHP, Ruby

Mobile development: Swift, Kotlin, Dart (Flutter)

Data science: Python (NumPy/Pandas), R, SQL

Other: Shell, YAML, JSON, Markdown


Error codes

HTTP statusMeaningHow to fix
401API key auth failedCheck the API key; confirm the Base URL points at SeaWhale AI
403Insufficient permissionCheck API key permissions and model access
429Rate limitedWait a moment and retry, or increase your account quota
500Server errorRetry later, or contact support

Other AI coding tools

ToolPlatformCharacteristics
OpenCodeCLIOpen source, lightweight, terminal-based
Claude CodeCLIOfficial Anthropic tool, deep code understanding
ClineVSCodeIDE extension, plans and runs multi-step tasks
Cherry StudioDesktop appGraphical interface, multi-model management

Support

ChannelResponse timeBest for
📖 DocumentationImmediateCommon questions
💬 Live supportWeekdays 9:00–18:00Real-time technical questions
📧 Email supportWithin 24 hoursDetailed reports and feedback

© 2024 SeaWhale AI. All rights reserved.

Last updated 2026-04-17