Skip to content

[Bug] gpt-6-sol / gpt-6-luna 参数兼容问题:max_tokens 未转换 #7626

Description

@axuan-xuan-xuan

Read This First

  • Docs: https://docs.newapi.ai/
  • Usage questions first: https://deepwiki.com/QuantumNous/new-api
  • Do not report issues when pass-through is enabled; pass-through sends content as-is and does not go through new-api processing logic.
  • State facts and evidence concisely. Do not paste unfiltered AI-generated text in the issue body or in later comments.
  • Relay reports must first establish that the issue occurs in the new-api layer. Use equivalent redacted requests to compare the direct upstream result with the result through new-api, including response status, error body, and server logs. Reports that skip this comparison or only show an upstream error are not accepted.
  • Reports about Coding Plan services, reverse-engineered channels, third-party API wrappers, or compatibility issues caused by exposing a Codex endpoint through a reverse proxy as a general-purpose API are not accepted. Protocols or behavior specific to the Codex API should not be treated as standard OpenAI API behavior; confirm such issues with the channel or API provider first.
  • This project does not operate an official hosted service or provide technical support for third-party hosting sites, relay services, or API services. Contact the relevant operator for those issues.
  • Warning: issues with this template removed, section headings deleted, or content cleared may be closed directly. Repeated submissions of unfiltered AI-generated text, or repeated abusive submissions, may result in a block.

Deployment source

Repository release / official image (self-hosted)

Your current newapi version

实际接口复现:v1.0.0-rc.39 - 源码审计:v1.0.0-rc.37、v1.0.0-rc.39、v1.0.0-rc.40 - rc.40 未在实际部署接口上运行;结论来自官方 tag 源码和版本差异核对。

Submission Checks

  • Non-duplicate issue: I have searched existing Issues and confirmed there are no similar issues.
  • Read this first: I have fully read the section above, reviewed the docs at https://docs.newapi.ai/ and the project README, and asked AI first, confirming this is not a usage, configuration, or integration question.
  • Supported version: I have provided an exact version, commit, or image tag (not latest or unknown) and confirmed that the issue reproduces on an unmodified, supported version from this repository.
  • Not a third-party service: I confirm that this issue is not exclusive to a third-party hosting site, relay, API service, or fork that has not been verified against the unmodified repository. Third-party instance issues must be reported to their operator.
  • Not pass-through: I confirm that pass-through is not enabled on the relevant channel. Pass-through sends content as-is and does not go through new-api processing logic; such reports are not accepted.
  • Issue attribution: I have provided evidence that distinguishes the client, new-api, and upstream layers. For relay issues, I compared equivalent redacted requests sent directly upstream and through new-api, confirming that new-api introduces or changes the error rather than merely forwarding the upstream error unchanged.
  • Channel and protocol boundary: I confirm that the issue is not caused by a Coding Plan service, reverse-engineered channel, third-party API wrapper, Codex reverse-proxy endpoint, or behavior specific to the Codex API. If first observed through such an interface, I have reproduced it using a standard API protocol supported by this repository.
  • Maintainer time: I understand that maintainers have limited time. Do not paste unfiltered AI-generated text in the issue body or in later comments; extract the points needed for review first. Submissions that do not follow this template, or that omit the necessary points and cannot be reviewed, may be ignored or closed. Repeated submissions of this kind may result in a block.

Issue Description

在 OpenAI 兼容的 Chat Completions 请求中,模型为 gpt-6-sol 或 gpt-6-luna 时,客户端发送 max_tokens,new-api 没有将其转换为 max_completion_tokens,上游返回 400:

{
  "error": {
    "message": "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.",
    "type": "invalid_request_error",
    "param": "max_tokens",
    "code": "unsupported_parameter"
  }
}

该问题在流式和非流式请求中均出现。

源码定位:Chat token 字段

三个版本的 GetOpenAIChatCapabilities() 都使用以下判断:

isGPT5Model := IsOpenAIGPT5Model(modelName)
if !isGPT5Model && !isOpenAIModelSnapshot(modelName, "gpt-6-astra") {
    return capabilities
}
capabilities.UseMaxCompletionTokens = true

gpt-6-sol、gpt-6-luna 以及对应日期快照不满足上述条件,因此 UseMaxCompletionTokens 保持 Go 布尔零值 false。后续转换逻辑只有在该标志为 true 时才执行:

if capabilities.UseMaxCompletionTokens {
    if lo.FromPtrOr(request.MaxCompletionTokens, uint(0)) == 0 &&
        lo.FromPtrOr(request.MaxTokens, uint(0)) != 0 {
        request.MaxCompletionTokens = request.MaxTokens
        request.MaxTokens = nil
    }
}

因此,正常适配器路径收到只包含 max_tokens 的 gpt-6-sol / gpt-6-luna 请求时,发送给上游的请求仍可能包含旧字段。

源码位置:

三个版本该能力函数规范化后的 SHA-256 完全相同:

2EACDD772C1D13CD518D31ACEFD554ED5228A5FDD021344DBAE7171385149570

Steps to Reproduce

Chat Completions / max_tokens

发送非流式请求:

curl "$BASE_URL/chat/completions" \
  -H "Authorization: Bearer <REDACTED>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6-sol",
    "messages": [{"role": "user", "content": "Reply OK only."}],
    "max_tokens": 16,
    "stream": false
  }'

预期复现:HTTP 400,错误参数为 max_tokens。

把请求唯一相关字段改为 max_completion_tokens:

{
  "model": "gpt-6-sol",
  "messages": [{"role": "user", "content": "Reply OK only."}],
  "max_completion_tokens": 16,
  "stream": false
}

预期结果:HTTP 200,返回 OK。

将两个请求的 stream 都改为 true,可以得到相同的失败/成功差异;失败流式请求返回 400 和 SSE 错误事件,不会收到正常的完成事件。

对 gpt-6-luna 重复上述步骤,结果相同。

Expected Result

  1. 对模型能力明确要求 max_completion_tokens 的 Chat 模型,new-api 应在正常适配器路径中把客户端的 max_tokens 转换为 max_completion_tokens,并删除旧字段。
  2. 该判断应覆盖 gpt-6-sol、gpt-6-luna 及其日期快照,而不是只覆盖 GPT-5 和 gpt-6-astra。

Related Screenshots

Image

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions