OAuth provider plugin for Kimi Code CLI integration with OpenClaw.
- π OAuth Authentication - More secure than API keys
- π Token Reuse - Leverages existing Kimi CLI authentication
- β‘ Auto-refresh - Tokens refreshed automatically by Kimi CLI
- π― Zero Config - Works out of the box after
kimi login - π Secure - Tokens stored in OpenClaw's encrypted auth profiles
# Using pip
pip install kimi-cli
# Or using pipx (recommended)
pipx install kimi-clikimi loginFollow the browser-based OAuth flow to authenticate with your Moonshot AI account.
kimi whoami# Clone this repository
git clone https://github.com/FelipeOFF/openclaw-kimi-code-auth.git
# Install the plugin
openclaw plugins install ./openclaw-kimi-code-auth
# Restart the gateway
openclaw gateway restart# Interactive setup
openclaw models auth login --provider kimi-coding
# Or use the configure wizard
openclaw configureSelect "Kimi Code OAuth" when prompted for the provider.
# Make Kimi Code your default model
openclaw models set kimi-coding/kimi-for-coding# Use Kimi Code for a one-off message
openclaw agent --model kimi-coding/kimi-for-coding --message "Write a Python function to calculate fibonacci"
# Or via the Gateway API
openclaw agent --to telegram:YOUR_CHAT_ID --model kimi-coding/kimi-for-coding --message "Hello from Kimi Code!"# Add a cron job using Kimi Code
openclaw cron add \
--name "daily-code-review" \
--cron "0 9 * * *" \
--model kimi-coding/kimi-for-coding \
--message "Review yesterday's code commits and suggest improvements"| Variable | Description | Required |
|---|---|---|
KIMI_API_KEY |
Fallback API key (optional) | No |
| Model | Context | Features | Auth |
|---|---|---|---|
kimi-coding/kimi-for-coding |
262k | Thinking, code completion, agentic coding | OAuth |
moonshot/kimi-k2.5 |
256k | General purpose conversation | API Key |
This plugin integrates with the official Kimi CLI's OAuth flow:
- Kimi CLI handles the OAuth dance with Moonshot AI
- Tokens are stored securely in
~/.kimi/credentials/kimi-code.json - This plugin reads those tokens and provides them to OpenClaw
- Auto-refresh happens automatically when you use
kimicommands
βββββββββββββββ OAuth ββββββββββββββββ
β Kimi CLI β ββββββββββββΊ β Moonshot AI β
β (kimi) β β (OAuth) β
ββββββββ¬βββββββ ββββββββββββββββ
β
β stores tokens
βΌ
βββββββββββββββ reads ββββββββββββββββ
β ~/.kimi/ β ββββββββββββββΊ β This Plugin β
β credentials β β β
βββββββββββββββ ββββββββ¬ββββββββ
β
β provides
βΌ
ββββββββββββββββ
β OpenClaw β
β Gateway β
ββββββββββββββββ
openclaw-kimi-code-auth/
βββ index.ts # Main plugin entry point
βββ oauth.ts # OAuth credential reader
βββ openclaw.plugin.json # Plugin manifest
βββ package.json # Package metadata
βββ README.md # This file
No build step required - TypeScript is handled by OpenClaw's plugin loader.
# Check if plugin loads
openclaw plugins list
# Verify provider is registered
openclaw models status | grep kimi-coding
# Test authentication
openclaw models auth login --provider kimi-codingRun kimi login first:
kimi loginTokens are refreshed automatically by Kimi CLI. Just run any kimi command:
kimi --versionThen retry the OpenClaw operation.
Check the plugin status:
openclaw plugins listIf it shows "error", restart the gateway:
openclaw gateway restartopenclaw models statusLook for:
- kimi-coding effective=profiles:~/.openclaw/agents/main/agent/auth-profiles.json
| profiles=1 (oauth=1, token=0, api_key=0)
| kimi-coding:default=OAuth
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- OpenClaw - The autonomous AI agent platform
- Moonshot AI - Creators of Kimi
- Kimi CLI - Official CLI for Kimi
Made with β€οΈ for the OpenClaw community