MoonshotAI / MoonshotAI/kimi-code
Custom registry ignores advertised limit.output — providers reject requests with 400 "Invalid max_tokens"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 1.2k
- Avg merge
- 11h 53m
- Merged PRs (30d)
- 350
Description
What version of Kimi Code is running?
0.42.0 (also verified present on latest main, commit b1807253c)
Which open platform/subscription were you using?
A custom registry (api.json, models.dev format) with OpenAI/Anthropic-compatible providers.
Which model were you using?
Any model imported from a custom registry whose advertised limit.output is below its context size (e.g. models with an 8k output cap).
What platform is your computer?
Linux x86_64 (platform-independent — the issue is in how registry data is imported).
What issue are you seeing?
When models are imported from a custom registry (api.json), each entry's advertised limit.output is ignored: the generated model alias never records maxOutputSize. The request's completion-token cap then falls back to the model's full context size and is sent as the protocol's output-token field — max_output_tokens for openai_responses, max_completion_tokens/max_tokens for openai chat-completions, and max_tokens for anthropic (which additionally falls back to a 128000 default for unrecognized model ids). Any registry model whose real output cap is smaller rejects the request, e.g.:
400 "Invalid max_output_tokens"
What steps can reproduce the bug?
- Configure a custom registry whose model entry advertises a modest output limit, e.g. an
openai_responsesregistry with thisapi.jsonentry:{ "models": { "example-model": { "id": "example-model", "name": "Example Model", "limit": { "context": 1000000, "output": 8192 } } } } - Import that registry and select the model.
- Send any prompt.
- The request goes out with
max_output_tokens≈ 1000000 (the full advertised context size, since no output limit was recorded), and the provider responds400 "Invalid max_output_tokens"because that exceeds the model's real 8192 output cap.
What is the expected behavior?
kimi-code records the registry's advertised limit.output as the model's max output size and sends a compliant output-token cap, the same way limit.context is already honored for maxContextSize.
Additional information
- Verified against the live models.dev dataset (~7700 models): every chat model publishes
limit.outputas a positive integer, so the field is reliable to consume. - The models.dev integration path already maps this field to
maxOutputSize; the custom-registry import path is the only one that drops it. - Affects all custom-registry provider types (
openai,openai_responses,anthropic,kimi) since the completion-budget cap is protocol-agnostic. - I am willing to submit a PR for this bug fix myself (waiting for maintainer approval in this issue first, per the contributing policy).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the custom-registry import path and compare it with the existing models.dev integration, which already maps limit.output to maxOutputSize. Reproduce the issue with the provided api.json entry and inspect the generated model alias and outgoing provider request. Done means the advertised 8192 output limit is recorded and used for the protocol's output-token field.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 70/100