opencode icon indicating copy to clipboard operation
opencode copied to clipboard

token count not working for some providers (moonshot.ai for example)

Open kajdo opened this issue 1 year ago • 5 comments

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

Image

kajdo avatar Jul 16 '25 20:07 kajdo

moonshot with openrouter works by the way

onlyargon avatar Jul 17 '25 07:07 onlyargon

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

kajdo avatar Jul 17 '25 12:07 kajdo

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)

hadikhantech avatar Jul 23 '25 08:07 hadikhantech

This is a duplicate of https://github.com/sst/opencode/issues/423. It's a problem with providers that use @ai-sdk/openai-compatible.

jessevdp avatar Jul 24 '25 07:07 jessevdp

[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

rekram1-node avatar Dec 28 '25 01:12 rekram1-node