{
  "tool": "AI图像生成服务",
  "description": "使用AI Studio API生成图像并上传到R2存储，支持去水印处理和格式转换功能",
  "usage": {
    "endpoint": "POST /api/v1/image",
    "method": "POST",
    "contentType": "application/json"
  },
  "parameters": {
    "model": {
      "type": "string",
      "required": false,
      "default": "gemini-3-pro-image-preview",
      "description": "AI模型名称",
      "examples": [
        "gemini-3-pro-image-preview",
        "gemini-2.5-flash-image"
      ]
    },
    "prompt": {
      "type": "string",
      "required": true,
      "description": "图像生成的文本提示"
    },
    "aspect_ratio": {
      "type": "string",
      "required": false,
      "description": "图像比例",
      "options": [
        "1:1",
        "16:9",
        "9:16",
        "4:3",
        "3:4",
        "3:2",
        "2:3",
        "5:4",
        "4:5",
        "21:9"
      ]
    },
    "image_urls": {
      "type": "string|string[]",
      "required": false,
      "description": "图片链接，支持单个链接或多个链接数组"
    },
    "output_format": {
      "type": "string",
      "required": false,
      "description": "输出格式",
      "options": [
        "png",
        "jpeg"
      ]
    },
    "image_size": {
      "type": "string",
      "required": false,
      "default": "1K",
      "description": "模型清晰度"
    },
    "bucket": {
      "type": "string",
      "required": false,
      "default": "tempfile",
      "description": "存储桶选择",
      "options": [
        "tempfile",
        "file"
      ]
    }
  },
  "features": [
    "使用AI Studio API生成高质量图像",
    "支持多种宽高比设置",
    "支持图片输入，可用于图像编辑和风格转换",
    "自动上传到R2存储",
    "支持PNG和JPEG格式转换",
    "支持去水印处理",
    "支持多个存储桶选择"
  ],
  "responseCodes": {
    "200": "成功",
    "400": "参数错误",
    "404": "未找到",
    "500": "内部服务器错误",
    "501": "AI响应中未找到图片",
    "502": "AI Studio API错误",
    "503": "服务不可用/网络连接错误"
  },
  "examples": {
    "requestParams": {
      "model": "gemini-3-pro-imagen",
      "prompt": "一只可爱的小狗",
      "aspect_ratio": "16:9",
      "output_format": "jpeg",
      "bucket": "tempfile"
    },
    "responseSuccess": {
      "code": 200,
      "msg": "",
      "data": {
        "result_urls": [
          "https://tempfile.aiquickdraw.com/workers/nano/image_1234567890_abc123.jpg"
        ]
      }
    },
    "curl": "curl -X POST https://your-domain.com/api/v1/image \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"gemini-3-pro-image-preview\",\n    \"prompt\": \"一只可爱的小狗\",\n    \"aspect_ratio\": \"16:9\",\n    \"output_format\": \"jpeg\",\n    \"bucket\": \"tempfile\"\n  }'"
  },
  "processingFlow": [
    "1. 调用 AI Studio API 生成图像",
    "2. 从响应中提取 base64 图片数据",
    "3. 上传到 R2 临时存储",
    "4. 调用去水印服务处理图片",
    "5. 如果指定了 output_format，进行格式转换",
    "6. 返回最终的图片 URL"
  ],
  "storage": {
    "path": "workers/nano/image_timestamp_random.ext",
    "buckets": {
      "tempfile": "tempfile.aiquickdraw.com",
      "file": "file.aiquickdraw.com"
    }
  }
}