{'success': True, 'data': {'candidates': [{'content': {'parts': None}, 'finishRe...

2026年03月02日 12:20 状态: processing

🚨 错误信息

{'success': True, 'data': {'candidates': [{'content': {'parts': None}, 'finishReason': 'MALFORMED_FUNCTION_CALL', 'finishMessage': 'Malformed function call: call:google:image_gen{image_url:image_0.png,prompt:Based on image_0.png, the image now shows only the pregnant woman in the beige ribbed sleepwear lying peacefully on the bed with white linens and blue-lit background. All text, logos, including the "Domiamia" brand, "A类一等品" label, "SF 顺丰包邮" logos, the Tmall banner, price, and promotional details at the bottom have been completely removed, leaving a clean photograph. }', 'index': 0}], 'promptFeedback': {'safetyRatings': None}, 'usageMetadata': {'promptTokenCount': 306, 'candidatesTokenCount': 0, 'totalTokenCount': 306, 'promptTokensDetails': [{'modality': 'TEXT', 'tokenCount': 48}, {'modality': 'IMAGE', 'tokenCount': 258}]}, 'modelVersion': 'gemini-3-pro-image-preview', 'responseId': 'Uw-laeLFE_f4jrEPqtDxkQ8'}, 'status_code': 200, 'duration_ms': 10211}

🤖 AI解决方案

报错分析报告

1. 错误翻译



原文:Malformed function call: call:google:image_gen{image_url:image_0.png,prompt:Based on image_0.png, the image now shows only the pregnant woman in the beige ribbed sleepwear lying peacefully on the bed with white linens and blue-lit background. All text, logos, including the "Domiamia" brand, "A类一等品" label, "SF 顺丰包邮" logos, the Tmall banner, price, and promotional details at the bottom have been completely removed, leaving a clean photograph. }
译文:函数调用格式错误:调用google:image_gen时参数格式不正确(键名未加引号、字符串内双引号未转义)

2. 原因分析


  • 根本原因:调用google:image_gen函数的参数不符合语法规范(键名无引号、字符串未正确转义)。

  • 发生位置:函数调用的参数构造阶段,上下文是传递image_urlprompt生成图片时格式错误。
  • 3. 解决方案


    javascript
    // 修复后的JavaScript调用示例(参数格式合规)
    callGoogleImageGen({
    "image_url": "image_0.png",
    "prompt": "Based on image_0.png, the image now shows only the pregnant woman in the beige ribbed sleepwear lying peacefully on the bed with white linens and blue-lit background. All text, logos, including the \"Domiamia\" brand, \"A类一等品\" label, \"SF 顺丰包邮\" logos, the Tmall banner, price, and promotional details at the bottom have been completely removed, leaving a clean photograph."
    });

    python

    修复后的Python调用示例(参数格式合规)


    call_google_image_gen(
    image_url="image_0.png",
    prompt="Based on image_0.png, the image now shows only the pregnant woman in the beige ribbed sleepwear lying peacefully on the bed with white linens and blue-lit background. All text, logos, including the \"Domiamia\" brand, \"A类一等品\" label, \"SF 顺丰包邮\" logos, the Tmall banner, price, and promotional details at the bottom have been completely removed, leaving a clean photograph."
    )

    4.️ 预防措施


  • 调用前对照官方文档验证参数格式(重点检查引号、转义规则);

  • 使用语法检查工具(如VS Code ESLint/Pylint、JSONLint)实时拦截格式错误。

  • 推荐工具:Postman(模拟API调用测试)、JSONLint(验证JSON参数)。