code: 400 - {'error': {'message': 'image resolution exceeds limit', 'type': 'inv...

2026年08月05日 13:44 17.39 秒 success

错误信息

- 结果: **unresolved** | matchType: - - 说明: LLM 调用失败: API 调用失败: Error code: 400 - {'error': {'message': 'image resolution exceeds limit', 'type': 'invalid_request_error', 'param': '', 'code': 10045}} - pinNumberByVLM: - - pinNameByVLM: -

AI 解决方案

🔍 报错分析

1. 🌐 错误翻译


原文:image resolution exceeds limit
译文:图像分辨率超出限制

2. 🎯 原因分析


该错误表明向LLM模型API请求中提交的图像分辨率超过了API允许的最大限制。这是API服务端的限制策略,拒绝处理分辨率过高的图像,以控制资源消耗和服务稳定性。

3. 💡 解决方案


在调用API前,先对图像进行压缩或调整分辨率,确保图像符合API的限制要求。以下是一个使用Node.js配合sharp库压缩图像分辨率的示例:

const sharp = require('sharp');

async function compressImage(inputPath, outputPath, maxWidth, maxHeight) {
  try {
    // 调整图像分辨率,确保宽高不超过指定限制
    await sharp(inputPath)
      .resize(maxWidth, maxHeight, {
        fit: 'inside',
        withoutEnlargement: true
      })
      .toFile(outputPath);
    console.log(`图像压缩成功:${outputPath}`);
  } catch (error) {
    console.error('图像压缩失败:', error);
    throw error;
  }
}

// 使用示例:将图像分辨率调整为不超过1024x1024
compressImage('original.jpg', 'compressed.jpg', 1024, 1024);

4. 🛡️ 预防措施


  • 提前校验分辨率:在调用API前,主动检查图像分辨率,使用工具如sharpPillow(Python)等提前处理图像,确保符合API要求。

  • 查看API文档:严格遵循API官方文档中关于图像分辨率、格式、大小的具体要求,在参数校验环节增加对应的检查逻辑,提前拦截不符合条件的请求。