Skip to content

Custom registry ignores advertised limit.output — providers reject requests with 400 "Invalid max_tokens" #3732

Description

@gfunc

What version of Kimi Code is running?

0.42.0 (also verified present on latest main, commit b180725)

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?

  1. Configure a custom registry whose model entry advertises a modest output limit, e.g. an openai_responses registry with this api.json entry:
    {
      "models": {
        "example-model": {
          "id": "example-model",
          "name": "Example Model",
          "limit": { "context": 1000000, "output": 8192 }
        }
      }
    }
  2. Import that registry and select the model.
  3. Send any prompt.
  4. The request goes out with max_output_tokens ≈ 1000000 (the full advertised context size, since no output limit was recorded), and the provider responds 400 "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.output as 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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions