Agent API

Programmatic access for AI agents with credits-based pricing.

Quick start

  1. Sign up and get your API key at /settings/apikeys.
  2. For Moltbook agents, exchange identity for a short-lived access token at POST /auth/moltbook/exchange.
  3. Call POST /v1/generate with a request_id.

Minimal call (example)

POST /v1/generate
{"model":"nano-banana-pro","prompt":"...","request_id":"uuid"}

Authentication

  • API Key: Authorization: Bearer <api_key>
  • Moltbook: POST /auth/moltbook/exchangeaccess_token (15 min)

Balance & estimate

  • GET /v1/credits/balance
  • POST /v1/credits/estimate
  • GET /v1/models/list

Estimate request

{
  "product": "image",
  "model": "nano-banana-pro",
  "units": { "count": 1, "resolution": "1K" },
  "price_version": "2026-02-02-v1"
}

Generate (v1)

Request (common fields)

  • request_id (required)
  • model (required)
  • prompt (required for text-to-*)
  • product (optional: image/video/music; auto-detected if omitted)
  • units: { count, resolution, duration, aspect_ratio }
  • input_image_urls (for image-to-image / image-to-video)
  • price_version (optional)

Idempotency: reusing the same request_id will not double-charge.

Response (JSON-only)

{
  "code": 0,
  "message": "ok",
  "data": {
    "task_id": "...",
    "provider_task_id": "...",
    "status": "pending",
    "usage_event_id": "..."
  }
}

Pricing (credits)

All pricing is credits. For images, count multiplies the cost (1/2/4/8).

Image models (per image)

ModelCreditsNotes
google/nano-banana8fast draft
nano-banana-pro204K = 40
gpt4o_image10
qwen/text-to-image15
qwen/image-to-image15
xai/grok-imagine-image20
xai/grok-imagine-image/edit20
z-image20

Video models

ModelCreditsNotes
sora-210720p baseline
sora-2-pro330
veo3_fast50
veo32801080p = 350
doubao-seedance-1.0-pro-fast40
wan-2.6201080p = 300
fal-ai/ltx-2/image-to-video50
xai/grok-imagine-video/text-to-video10

Notes:

  • 1080p may apply ~1.8x on some models (use /v1/credits/estimate for exact pricing).
  • Image-to-video can apply a 1.5x multiplier for some models.

Music models

ModelCredits
V535
V4_5PLUS30
V4_525
V420

Errors (JSON)

Common errors:

{
  "code": 0,
  "message": "ok",
  "data": {
    "error": "insufficient_credits",
    "required": 50,
    "available": 10,
    "suggestion": "Use a cheaper model or ask the owner to top up."
  }
}

Machine-readable docs

  • OpenAPI: /agent/openapi.json
  • llms.txt: /llms.txt and /agent/llms.txt