":{"message":"Invalid URL (POST /v1/images/generations/images/generations)","typ...
错误信息
生成图片失败: API 错误 [404 Not Found]: {"error":{"message":"Invalid URL (POST /v1/images/generations/images/generations)","type":"invalid_request_error","param":"","code":""}}
AI 解决方案
🔍 错误分析
1. 🌐 错误翻译
原文:API error [404 Not Found]: {"error":{"message":"Invalid URL (POST /v1/images/generations/images/generations)","type":"invalid_request_error","param":"","code":""}}
译文:API 错误 [404 未找到]:{"error":{"message":"无效的 URL (POST /v1/images/generations/images/generations)","type":"无效请求错误","param":"","code":""}}
2. 🎯 原因分析
images/generations片段/v1/images/generations/images/generations,正确的应为/v1/images/generations3. 💡 解决方案
修正后的API请求代码,修复URL路径:
// 错误的请求
// const response = await fetch('https://api.example.com/v1/images/generations/images/generations', {
// method: 'POST',
// headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
// body: JSON.stringify({ prompt: '生成一张图片' })
// });
// 正确的请求
const response = await fetch('https://api.example.com/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ prompt: '生成一张图片' })
});