Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

调用应用 API 接口请求传输 base64 图片时出错,Body exceeded 1mb limit。 #1241

Closed
6 of 7 tasks
dimsky opened this issue Apr 19, 2024 · 4 comments
Closed
6 of 7 tasks
Labels
bug Something isn't working

Comments

@dimsky
Copy link
Contributor

dimsky commented Apr 19, 2024

例行检查

  • 我已确认目前没有类似 issue
  • 我已完整查看过项目 README,以及项目文档
  • 我使用了自己的 key,并确认我的 key 是可正常使用的
  • 我理解并愿意跟进此 issue,协助测试和提供反馈
  • 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

你的版本

  • 公有云版本
  • 私有部署版本, 具体版本号:

问题描述
调用应用 API 接口请求传输大于 1mb 的 base64 图片时出错,Body exceeded 1mb limit。
复现步骤
在 body 中传入一个 大于 1mb 的 base 64 图片
预期结果
正常请求成功,并返回。

相关截图

@dimsky dimsky added the bug Something isn't working label Apr 19, 2024
@dimsky
Copy link
Contributor Author

dimsky commented Apr 19, 2024

该问题是因为 next.js 默认将 body size limit 设置成了 1mb ,next.js 13 加个 配置即可,只有在通过调用外部 API 时 以 base64 格式传输图片超过 1mb 时才会出现, 考虑到各模型对图片大小和数量的限制不同,可根据具体情况修改。

src/pages/api/v1/chat/completions.ts

export const config = {
  api: {
    responseLimit: '20mb',
    bodyParser: {
      sizeLimit: '50mb'
    }
  }
};

@c121914yu
Copy link
Collaborator

c121914yu commented Apr 25, 2024

该问题是因为 next.js 默认将 body size limit 设置成了 1mb ,next.js 13 加个 配置即可,只有在通过调用外部 API 时 以 base64 格式传输图片超过 1mb 时才会出现, 考虑到各模型对图片大小和数量的限制不同,可根据具体情况修改。

src/pages/api/v1/chat/completions.ts

export const config = {
  api: {
    responseLimit: '20mb',
    bodyParser: {
      sizeLimit: '50mb'
    }
  }
};

可以提个pr。

@c121914yu
Copy link
Collaborator

该问题是因为 next.js 默认将 body size limit 设置成了 1mb ,next.js 13 加个 配置即可,只有在通过调用外部 API 时 以 base64 格式传输图片超过 1mb 时才会出现, 考虑到各模型对图片大小和数量的限制不同,可根据具体情况修改。
src/pages/api/v1/chat/completions.ts

export const config = {
  api: {
    responseLimit: '20mb',
    bodyParser: {
      sizeLimit: '50mb'
    }
  }
};

可以提个pr。

我改掉把

@lijiajun1997
Copy link

该问题是因为 next.js 默认将 body size limit 设置成了 1mb ,next.js 13 加个 配置即可,只有在通过调用外部 API 时 以 base64 格式传输图片超过 1mb 时才会出现, 考虑到各模型对图片大小和数量的限制不同,可根据具体情况修改。
src/pages/api/v1/chat/completions.ts

export const config = {
  api: {
    responseLimit: '20mb',
    bodyParser: {
      sizeLimit: '50mb'
    }
  }
};

可以提个pr。

我改掉把

劳模颁给你

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants