Skip to content

FelipeOFF/openclaw-kimi-code-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ” OpenClaw Kimi Code Auth Plugin

OpenClaw Kimi License

OAuth provider plugin for Kimi Code CLI integration with OpenClaw.

✨ Features

  • πŸ”‘ 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

πŸ“‹ Requirements

πŸš€ Quick Start

1. Install Kimi CLI

# Using pip
pip install kimi-cli

# Or using pipx (recommended)
pipx install kimi-cli

2. Authenticate with Kimi

kimi login

Follow the browser-based OAuth flow to authenticate with your Moonshot AI account.

3. Verify Authentication

kimi whoami

4. Install the Plugin

# 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

5. Configure OpenClaw

# Interactive setup
openclaw models auth login --provider kimi-coding

# Or use the configure wizard
openclaw configure

Select "Kimi Code OAuth" when prompted for the provider.

πŸ“– Usage

Set as Default Model

# Make Kimi Code your default model
openclaw models set kimi-coding/kimi-for-coding

Use for Specific Sessions

# 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!"

Configure for Cron Jobs

# 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"

πŸ”§ Configuration

Environment Variables

Variable Description Required
KIMI_API_KEY Fallback API key (optional) No

Available Models

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

πŸ—οΈ Architecture

This plugin integrates with the official Kimi CLI's OAuth flow:

  1. Kimi CLI handles the OAuth dance with Moonshot AI
  2. Tokens are stored securely in ~/.kimi/credentials/kimi-code.json
  3. This plugin reads those tokens and provides them to OpenClaw
  4. Auto-refresh happens automatically when you use kimi commands
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     OAuth     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Kimi CLI   β”‚ ◄──────────► β”‚ Moonshot AI  β”‚
β”‚  (kimi)     β”‚               β”‚  (OAuth)     β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”‚ stores tokens
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     reads      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ~/.kimi/    β”‚ ─────────────► β”‚  This Plugin β”‚
β”‚ credentials β”‚                β”‚              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                                      β”‚ provides
                                      β–Ό
                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                               β”‚   OpenClaw   β”‚
                               β”‚   Gateway    β”‚
                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Development

Project Structure

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

Building

No build step required - TypeScript is handled by OpenClaw's plugin loader.

Testing

# 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-coding

πŸ› Troubleshooting

"Kimi CLI not authenticated"

Run kimi login first:

kimi login

Token expired

Tokens are refreshed automatically by Kimi CLI. Just run any kimi command:

kimi --version

Then retry the OpenClaw operation.

Plugin not loading

Check the plugin status:

openclaw plugins list

If it shows "error", restart the gateway:

openclaw gateway restart

Check OAuth status

openclaw models status

Look 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

πŸ“„ License

MIT License - see LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ™ Acknowledgments


Made with ❀️ for the OpenClaw community

About

OAuth provider plugin for Kimi Code CLI integration with OpenClaw

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors