Skip to content

Simplereally/opencode-kimicode-auth

Repository files navigation

OpenCode Kimi Code Auth

OpenCode plugin for Kimi Code OAuth under the Moonshot AI provider.

Authenticates via device-code OAuth (same flow as kimi-cli), manages multi-account rotation, and routes requests to the Kimi Code API.

Models

OpenCode model Mode Kimi API model
moonshotai/kimicode-kimi-k2.5 Thinking off kimi-for-coding
moonshotai/kimicode-kimi-k2.5-thinking Thinking on kimi-for-coding

Both models use 262k context and 32k output. Existing moonshotai/* API-key models are unaffected.


⚠️ Terms of Service Warning — Read Before Installing

[!CAUTION] Using this plugin may violate Moonshot AI's Terms of Service. It may result in your account being banned or shadow-banned (restricted access without explicit notification).

By using this plugin, you acknowledge:

  • This is an unofficial tool not endorsed by Moonshot AI
  • Your account may be suspended or permanently banned
  • You assume all risks associated with using this plugin

Recommendation: Try not to go overboard with the number of accounts you add. Stagger usage reasonably; don't run 24/7.

Install

Add the plugin to ~/.config/opencode/opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    "@itssimplereally/opencode-kimicode-auth@latest"
  ]
}

Then authenticate:

opencode auth login

In the picker, select Moonshot AIOAuth (Kimi Code / kimi-cli).

A browser window opens for Kimi device authorization. After approval, the plugin stores your tokens locally. You can add multiple accounts for rotation.

Verify:

opencode models moonshotai

Troubleshooting

  • Only seeing "Enter your API key" — Ensure "@itssimplereally/opencode-kimicode-auth@latest" is in your plugin array, then re-run opencode auth login.
  • Auth errors after working setup — Your refresh token may have expired. Re-run opencode auth login.

For LLMs

Copy this prompt into your coding agent to set up the plugin:

Configure OpenCode on this machine to use Kimi Code OAuth via the published plugin.

Goal:
- Use Kimi Code OAuth in OpenCode for moonshotai/kimicode-* models.

Rules:
- Never print credential values.
- Only modify config fields required for this setup.

Steps:
1. Validate tools:
   - Run: opencode --version
2. Update OpenCode config:
   - File: ~/.config/opencode/opencode.json or ~/.config/opencode/opencode.jsonc
   - Ensure the plugin array includes: "@itssimplereally/opencode-kimicode-auth@latest"
     - If no plugin array exists, create it under `$schema` key as `"plugin": ["@itssimplereally/opencode-kimicode-auth@latest"]`
   - Preserve all other existing plugin entries.
3. Verify OpenCode starts cleanly:
   - Run: opencode auth list
   - If plugin install/import errors occur, fix the plugin entry first.
4. **Do not attempt interactive auth in this session.**
   - Ask the human to run, cleanly formatted: `opencode auth login` then select "Moonshot AI" then "OAuth (Kimi Code / kimi-cli)" and they can add multiple accounts for rotation. **Logout in the browser after authorization of each account before adding the next.**
   - Wait for the human to confirm they completed authorization.
5. After human confirmation, verify:
   - Run: opencode auth list
   - Run: opencode models moonshotai
   - Confirm output includes `moonshotai/kimicode-kimi-k2.5` and `moonshotai/kimicode-kimi-k2.5-thinking`.
6. Return a concise report of changes and verification results.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •