文档

AI 图片描述 API

使用AI技术描述图片内容

AI 图片描述 API 允许您使用先进的AI技术来描述图片内容。此端点处理图像并返回详细的文字描述。体验 AI Describe Picture 的强大AI图片描述功能。

端点

POST /api/api-call/describe-picture

认证

需要在 Authorization 头部提供有效的 API 密钥:

Authorization: Bearer YOUR_API_KEY

请求

头部

HeaderRequiredDescription
Content-TypeYes必须是 application/json
AuthorizationYes您的API密钥,格式为 Bearer YOUR_API_KEY

请求体参数

ParameterTypeRequiredDescription
imageUrlstringYes要描述的图片URL(必须是公开可访问的)
promptstringNo自定义提示词(可选)

请求示例

{
  "imageUrl": "https://example.com/image.jpg",
  "prompt": "详细描述这张图片中的所有元素、颜色和构图"
}

响应

成功响应 (200)

API 返回包含图片描述的 JSON 对象,包含 choices 数组。

{
  "choices": [
    {
      "logprobs": null,
      "finish_reason": "stop",
      "native_finish_reason": "STOP",
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "图像描绘了一只红狐狸的特写,它正对着镜头。狐狸有蓬松的橘色和白色的毛发,以及竖立的耳朵和炯炯有神的棕色眼睛。背景是模糊的,可能是在雪地里或一个明亮的环境中。",
        "refusal": null,
        "reasoning": null
      }
    }
  ]
}

说明

  • choices 数组包含AI生成的描述内容,每个choice包含完整的消息对象
  • message.content 字段包含实际的图片描述文本
  • 响应格式与OpenAI API兼容

错误响应

400 Bad Request

{
  "message": "Invalid input"
}

401 Unauthorized

{
  "message": "Invalid or expired API key"
}

402 Payment Required

{
  "message": "Insufficient credits"
}

500 Internal Server Error

{
  "message": "Service error"
}

使用限制

  • 积分消耗: 每次描述消耗 1 积分
  • 图片要求: 支持 JPG、PNG、WebP 格式,最大 5MB

使用示例

JavaScript/Node.js

async function describeImage(imageUrl, apiKey, prompt = null) {
  try {
    const response = await fetch('https://aidescribepicture.com/api/api-call/describe-picture', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`
      },
      body: JSON.stringify({
        imageUrl: imageUrl,
        prompt: prompt
      })
    });
 
    if (!response.ok) {
      const error = await response.text();
      throw new Error(`API Error: ${response.status} - ${error}`);
    }
 
    const result = await response.json();
    
    // 提取描述内容
    const description = result.choices[0].message.content;
    return description;
  } catch (error) {
    console.error('Error describing image:', error);
    throw error;
  }
}
 
// 使用示例
const description = await describeImage(
  'https://example.com/image.jpg',
  'your-api-key-here',
  '详细描述这张图片'
);
console.log('Image description:', description);

cURL

curl -X POST https://aidescribepicture.com/api/api-call/describe-picture \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "imageUrl": "https://example.com/image.jpg",
    "prompt": "详细描述这张图片中的所有元素、颜色和构图"
  }'

图片要求

  • 格式: JPG、PNG、WebP
  • 大小: 最大 5MB
  • 可访问性: 图片URL必须是公开可访问的
  • 内容: 必须是有效的图片文件

处理时间

  • 典型: 10-30 秒
  • 大图片: 可能需要 60 秒

积分

  • 成本: 每次描述消耗 1 积分
  • 扣除: 积分在处理成功后扣除

最佳实践

  1. 图片质量: 使用高质量图片以获得更好的结果
  2. 错误处理: 始终实现适当的错误处理
  3. 积分管理: 定期监控您的积分余额
  4. 提示词: 使用具体的提示词可以获得更精确的描述

故障排除

常见问题

401 Unauthorized

  • 检查您的API密钥是否正确
  • 确保API密钥是活跃的且未过期

402 Payment Required

  • 为您的账户添加积分
  • 检查您当前的积分余额

400 Bad Request

  • 验证 imageUrl 是有效的、可访问的URL
  • 确保图片格式受支持

500 Internal Server Error

  • 服务器内部错误,请稍后重试
  • 检查图片URL是否可访问

支持

如果您遇到本文档未涵盖的问题,请联系我们的支持团队。

On this page