opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Kimi K2: AI_APICallError: Incorrect API key provided

Open Berkyx opened this issue 1 year ago • 6 comments

I have trouble with running kimi models with their api.

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "http://localhost:11434/v1"
      },
      "models": {
        "qwen3:30b": {}
      }
    },
    "moonshot": {
      "id": "moonshot",
      "api": "https://api.moonshot.cn/v1",
      "npm": "@ai-sdk/openai-compatible",
      "api_key": "sk-****",
      "options": {
        "baseURL": "https://api.moonshot.cn/v1"
       },
      "models": {
        "kimi-k2-0711-preview": {
          "name": "kimi-k2-0711-preview",
          "cost": {
            "input": 0.001953125,
            "output": 0.009765625
          }
        }
      }
    }
  }
}

Berkyx avatar Jul 16 '25 16:07 Berkyx

that's not where you specify it - it's apiKey under options but also you can specify it with opencode auth login so you avoid hardcoding it into the config

thdxr avatar Jul 16 '25 18:07 thdxr

you also don't need this config at all, moonshot works normally

thdxr avatar Jul 16 '25 18:07 thdxr

Image same issue , not able to make moonshot kimi k2 model working!

mymark21 avatar Jul 18 '25 11:07 mymark21

I am facing a similar issue {"error":{"message":"Invalid Authentication","type":"invalid_authentication_error"}}

DaWei8 avatar Jul 18 '25 13:07 DaWei8

you also don't need this config at all, moonshot works normally

I'm using it directly via Moonshot, cannot set it upon entry, entering the provider and API key does not work and the opencode seems to be stuck in a loop, prompting to select a provider again

hadikhantech avatar Jul 20 '25 15:07 hadikhantech

did anyone solve this problem?

yezooz avatar Feb 09 '26 13:02 yezooz