Skip to content
This repository was archived by the owner on Sep 18, 2025. It is now read-only.
This repository was archived by the owner on Sep 18, 2025. It is now read-only.

How to configure Kimi K2 with the Moonshoot API? #340

@hadikhantech

Description

@hadikhantech

As the title suggests.

I updated the config.json as follows:

{
  "data": {
    "directory": ".opencode"
  },
  "providers": {
    "openai": {
      "apiKey": "your-openai-api-key",
      "disabled": false
    },
    "anthropic": {
      "apiKey": "your-anthropic-api-key",
      "disabled": false
    },
    "copilot": {
      "disabled": false
    },
    "groq": {
      "apiKey": "your-groq-api-key",
      "disabled": false
    },
    "openrouter": {
      "apiKey": "your-openrouter-api-key",
      "disabled": false
    },
    "moonshot": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Kimi K2 (Moonshot)",
      "options": {
        "baseURL": "https://api.moonshot.ai/v1",
        "apiKey": "sk-your-moonshot-api-key"
      },
      "models": {
        "kimi-k2-0711-preview": {
          "name": "kimi-k2"
        }
      }
    }
  },
  "agents": {
    "coder": {
      "model": "moonshot/kimi-k2-0711-preview",
      "maxTokens": 5000
    },
    "task": {
      "model": "moonshot/kimi-k2-0711-preview",
      "maxTokens": 5000
    },
    "title": {
      "model": "moonshot/kimi-k2-0711-preview",
      "maxTokens": 80
    }
  },
  "shell": {
    "path": "/bin/bash",
    "args": ["-l"]
  },
  "lsp": {
    "go": {
      "disabled": false,
      "command": "gopls"
    }
  },
  "debug": false,
  "debugLSP": false,
  "autoCompact": true
}

Upon running opencode for the first time, I was prompted to select a model.
Selected 'other' and added the provider name and API key.
Got stuck in this process -> opencode command would prompt to select a provider always.
Selected OpenAI
Now opencode opens with OpenAI configured.

How to revert this to configure to Moonshot AI as a provider?

There seems to be a bug - upon selecting 'Other' as a provider, the opencode initial config seems to be stuck in a loop, i.e. you cannot configure 'Other' providers.

Edit:

How to revert this........
OpenAI auth was removed by removing the auth.json via rm ~/.local/share/opencode/auth.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions