token count not working for some providers (moonshot.ai for example)
i added moonshot.ai directly in configuration.json and it works fine, but the counter and the cost is not calculated at runtime of opencode
"moonshot_ai_direct": {
"npm": "@ai-sdk/openai-compatible",
"name": "Moonshot AI (Direct)",
"options": {
"baseURL": "https://api.moonshot.ai/v1",
"apiKey": "sk-sadöfjsdklöfjaösdlkjfasdköjfködfjdjfa"
},
"models": {
"kimi-k2-0711-preview": {
"name": "Kimi K2 (Direct)",
"cost": { "input": 0.6, "output": 2.5, "cache_read": 0.15 },
"limit": { "context": 131072, "output": 131072 }
}
}
}
the token count is always showing "0/0%"
moonshot with openrouter works by the way
moonshot with openrouter works by the way
yes, but due to different providers - the toolcalls work or don't (issues already exist). I changed to moonshot.ai to give it a try if the toolcalls work consistantly (which i can confirm).
the token count is just a minor thing - but it would be nice if it works, since 132k context size is reached mid "working" if i forget to /compact
moonshot with openrouter works by the way
It's not the same as directly from moonshot.
- No prompt caching
- Many providers use a quantised version and do not support tool calls (openrouter routes to them)
This is a duplicate of https://github.com/sst/opencode/issues/423. It's a problem with providers that use @ai-sdk/openai-compatible.
[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!