Skip to content

[Bug/错误]: 接收改图edits请求时无法正确解析请求内容,导致报错Bad Request #1945

Description

@refined-fish

Pre-submission Checklist / 提交前检查

  • I have searched the existing issues and this bug has not been reported / 我已搜索现有 issues,此 Bug 尚未被报告
  • I have read the documentation / 我已阅读文档
  • I am using the latest version of AxonHub / 我正在使用 AxonHub 的最新版本

FAQ Check / FAQ 检查

  • I have checked the FAQ and this bug is not covered there / 我已查阅 FAQ,此 Bug 未被覆盖

Bug Description / Bug 描述

外部工具调用改图edits端点时发出的请求无法被axonhub正确解析,导致请求立刻提示失败抛出报错

Request failed: Bad Request, error: Model name not specified, model name cannot be empty (request id: 202606301030103636325758268d9d66678nne9), type: new_api_error

但是实际上请求内容如下,包含有模型名字:

{
  "size": "2048x2048",
  "image": "data:image/jpeg;base64,图片的base64编码",
  "model": "gpt-image-2",
  "prompt": "改图提示词"
}

猜测改图请求因为携带图片,导致请求头中格式变成"multipart/form-data; boundary=c397bc9f3b88bd1e934409d60bef675a",导致axonhub的json解析失败

实际请求头如下:

{
  "Accept": [
    "application/json"
  ],
  "X-Real-Ip": [
    "10.2.0.23"
  ],
  "Connection": [
    "close"
  ],
  "User-Agent": [
    "AsyncOpenAI/Python 2.44.0"
  ],
  "Content-Type": [
    "multipart/form-data; boundary=c397bc9f3b88bd1e934409d60bef675a"
  ],
  "Authorization": [
    "******"
  ],
  "Content-Length": [
    "483905"
  ],
  "X-Stainless-Os": [
    "Linux"
  ],
  "Accept-Encoding": [
    "gzip, deflate"
  ],
  "X-Forwarded-For": [
    "10.2.0.23"
  ],
  "X-Forwarded-Host": [
    "反代域名"
  ],
  "X-Stainless-Arch": [
    "x64"
  ],
  "X-Stainless-Lang": [
    "python"
  ],
  "X-Forwarded-Proto": [
    "https"
  ],
  "X-Stainless-Async": [
    "async:asyncio"
  ],
  "X-Stainless-Runtime": [
    "CPython"
  ],
  "X-Stainless-Retry-Count": [
    "0"
  ],
  "X-Stainless-Read-Timeout": [
    "300"
  ],
  "X-Stainless-Package-Version": [
    "2.44.0"
  ],
  "X-Stainless-Runtime-Version": [
    "3.12.13"
  ]
}

Steps to Reproduce / 复现步骤

使用astrbot的生图插件调用改图(文生图功能正常,此时的请求头格式为"application/json")

Expected Behavior / 期望行为

能够正确解析multipart/form-data

Error Message / 错误消息

Request failed: Bad Request, error: Model name not specified, model name cannot be empty (request id: 202606301030103636325758268d9d66678nne9), type: new_api_error

Operating System / 操作系统

Linux (Ubuntu/Debian) / Linux(Ubuntu/Debian)

AxonHub Version / AxonHub 版本

v1.0.0-beta3

Usage Scenario / 使用场景

Other / 其他

API Format / API 格式

OpenAI - Chat Completions (/v1/chat/completions) / OpenAI 聊天补全

Channel Type / 渠道类型

OpenAI / OpenAI

Logs / 日志

Additional Context / 其他补充信息

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions