> ## Documentation Index
> Fetch the complete documentation index at: https://docs-vip.apigo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude 图片生成示例

> Claude 官方图片能力边界与推荐工作流。

## 官方能力边界

* Anthropic 官方 API 没有独立的图片生成 endpoint
* Claude 官方强项是图像理解，而不是直接产出图片资产

## 推荐工作流

1. 用 [Claude /v1/messages](/api-reference/endpoints/claude/image) 生成或改写图片提示词
2. 将整理后的 prompt 交给支持生图的 provider
3. 再用 Claude 做图片审核、解释或二次改写

## 最小请求

```json theme={null}
{
  "model": "claude-sonnet-4-20250514",
  "max_tokens": 600,
  "system": "You turn product briefs into image-generation prompts.",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "把这段需求整理成适合生图模型的英文 prompt：为 ApiGo 做一张简洁、科技感、浅色背景的产品海报。"
        }
      ]
    }
  ]
}
```

## cURL 示例

```bash theme={null}
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 600,
    "system": "You turn product briefs into image-generation prompts.",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "把这段需求整理成适合生图模型的英文 prompt：为 ApiGo 做一张简洁、科技感、浅色背景的产品海报。"
          }
        ]
      }
    ]
  }'
```

## Python 示例

```python theme={null}
from anthropic import Anthropic

client = Anthropic(api_key="<ANTHROPIC_API_KEY>")

response = client.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=600,
    system="You turn product briefs into image-generation prompts.",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "把这段需求整理成适合生图模型的英文 prompt：为 ApiGo 做一张简洁、科技感、浅色背景的产品海报。",
                }
            ],
        }
    ],
)

print(response.content[0].text)
```

## Node.js 示例

```js theme={null}
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
});

const response = await client.messages.create({
  model: "claude-sonnet-4-20250514",
  max_tokens: 600,
  system: "You turn product briefs into image-generation prompts.",
  messages: [
    {
      role: "user",
      content: [
        {
          type: "text",
          text: "把这段需求整理成适合生图模型的英文 prompt：为 ApiGo 做一张简洁、科技感、浅色背景的产品海报。"
        }
      ]
    }
  ]
});

console.log(response.content[0].text);
```

## 最佳实践

* 不要伪造一个“Claude 生图接口”给前端
* Claude 更适合做 prompt refinement、素材审核和视觉理解
* 生成链路和理解链路应拆成两条后端流程
