Agent API
面向 AI Agent 的程序化访问与 Credits 计费说明。
快速开始
- 注册账号并在
/settings/apikeys获取 API Key。 - Moltbook Agent 使用
POST /auth/moltbook/exchange交换短期 access token。 - 使用
POST /v1/generate并携带request_id调用。
最小调用示例
POST /v1/generate
{"model":"nano-banana-pro","prompt":"...","request_id":"uuid"}鉴权
- API Key:
Authorization: Bearer <api_key> - Moltbook:
POST /auth/moltbook/exchange→access_token(15 分钟)
余额与预估
GET /v1/credits/balancePOST /v1/credits/estimateGET /v1/models/list
estimate 请求
{
"product": "image",
"model": "nano-banana-pro",
"units": { "count": 1, "resolution": "1K" },
"price_version": "2026-02-02-v1"
}生成接口(v1)
请求字段
request_id(必填)model(必填)prompt(文生场景必填)product(可选:image/video/music,不传则自动识别)units:{ count, resolution, duration, aspect_ratio }input_image_urls(图生图 / 图生视频)price_version(可选)
幂等:重复使用同一 request_id 不会重复扣费。
响应格式(仅 JSON)
{
"code": 0,
"message": "ok",
"data": {
"task_id": "...",
"provider_task_id": "...",
"status": "pending",
"usage_event_id": "..."
}
}定价(Credits)
以下均为 credits 计价。图片按 count 叠加(1/2/4/8)。
图片模型(单张)
| Model | Credits | 说明 |
|---|---|---|
google/nano-banana | 8 | 快速草图 |
nano-banana-pro | 20 | 4K = 40 |
gpt4o_image | 10 | |
qwen/text-to-image | 15 | |
qwen/image-to-image | 15 | |
xai/grok-imagine-image | 20 | |
xai/grok-imagine-image/edit | 20 | |
z-image | 20 |
视频模型
| Model | Credits | 说明 |
|---|---|---|
sora-2 | 10 | 720p 基准 |
sora-2-pro | 330 | |
veo3_fast | 50 | |
veo3 | 280 | 1080p = 350 |
doubao-seedance-1.0-pro-fast | 40 | |
wan-2.6 | 20 | 1080p = 300 |
fal-ai/ltx-2/image-to-video | 50 | |
xai/grok-imagine-video/text-to-video | 10 |
说明:
- 1080p 部分模型会按约 1.8x 计费(以
/v1/credits/estimate为准)。 - 图生视频在部分模型上会有 1.5x 乘数。
音乐模型
| Model | Credits |
|---|---|
V5 | 35 |
V4_5PLUS | 30 |
V4_5 | 25 |
V4 | 20 |
错误响应(JSON)
{
"code": 0,
"message": "ok",
"data": {
"error": "insufficient_credits",
"required": 50,
"available": 10,
"suggestion": "请使用更便宜模型或提醒 Owner 充值。"
}
}机器可读文档
- OpenAPI:
/agent/openapi.json - llms.txt:
/llms.txt与/agent/llms.txt