opencode-moonshot-compatibility
v1.0.0
Published
OpenCode plugin that forces temperature to 1 for Moonshot AI / Kimi models
Maintainers
Readme
🌙 OpenCode Moonshot Compatibility Plugin
Tired of the
invalid temperature: only 1 is allowed for this modelerror?
This tiny plugin fixes it automatically — no need to change your agents! 🚀
✨ What It Does
When you use Moonshot AI (Kimi) models with OpenCode, the API only accepts temperature: 1.
But OpenCode agents (like @developer) usually set lower temperatures (e.g. 0.3) for better code quality.
This plugin hooks into every LLM call and silently forces temperature = 1 only when the active model is a Moonshot / Kimi one.
Your other agents and models stay completely untouched! 🎯
🔧 How It Works
OpenCode Agent (developer.md)
│
▼
temperature: 0.3 ← stays in the file
│
▼
┌─────────────────────┐
│ 🌙 This Plugin │ ← intercepts chat.params
│ detects Moonshot │
│ and forces temp=1 │
└─────────────────────┘
│
▼
temperature: 1 ← sent to Moonshot APIZero side effects on other providers like OpenAI, Anthropic, Ollama, etc.
📦 Installation
Option 1: Quick Copy (Recommended)
- Download
index.jsfrom this repo - Place it in your OpenCode plugins folder:
mkdir -p ~/.config/opencode/plugins cp index.js ~/.config/opencode/plugins/moonshot-temperature.js - Add to your
~/.config/opencode/opencode.json:{ "plugin": [ "file:///Users/YOUR_USERNAME/.config/opencode/plugins/moonshot-temperature.js" ] }
Option 2: npm (Coming Soon)
npm install opencode-moonshot-compatibilityThen in opencode.json:
{
"plugin": [
"opencode-moonshot-compatibility"
]
}🧪 Supported Models
| Provider | Models |
|----------|--------|
| moonshotai | kimi-k2, kimi-k2.5, kimi-k2.6, kimi-k2-thinking, ... |
| Any provider | Any model ID containing "kimi" |
🛠️ Development
git clone https://github.com/iamvaleriofantozzi/opencode-moonshot-compatibility.git
cd opencode-moonshot-compatibilityThe plugin is a single ESM file that exports a default async function returning hooks:
export default async function () {
return {
"chat.params": async (input, output) => {
// input.model.providerID → "moonshotai"
// input.model.id → "kimi-k2.6"
// output.temperature → writable!
},
};
}Learn more about OpenCode plugins: https://opencode.ai/docs/plugins
🐛 Troubleshooting
Plugin not loading?
- Check that the
file://path inopencode.jsonis absolute - Restart OpenCode completely (plugins are loaded at startup)
- Look for
[opencode-moonshot-temperature] PLUGIN LOADEDin the logs
Still getting the temperature error?
- Make sure you're using the latest version of this plugin
- Check that your model ID contains
"kimi"or provider is"moonshotai"
💡 Why This Exists
I love using different models for different tasks in OpenCode.
Switching to Kimi for coding is awesome, but the temperature mismatch was annoying.
I didn't want to create separate agents just for Moonshot, so I built this universal fix! 🎉
📄 License
MIT — do whatever you want! 🏄♂️
👤 Author
Made with ❤️ by Valerio Fantozzi
- GitHub: @iamvaleriofantozzi
- Feel free to open issues or PRs!
Happy coding with Kimi! 🌙✨
