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

# 快速開始

> 估價、提交工作、輪詢取得結果，再查詢用量。

**1. 確認金鑰與餘額**

到[開發者主控台](https://blon.ai/console/keys)建立 API 金鑰，以 Bearer token 帶入。詳見[認證](https://docs.blon.ai/zh-TW/authentication.md)。

```bash theme={null}
curl https://api.blon.ai/v1/balance \
  -H "Authorization: Bearer $BLON_API_KEY"
```

```json theme={null}
{
  "currency": "USD",
  "available": "18.425",
  "held": "0.0042",
  "usage_this_month": "1.5708",
  "spend_limit": {
    "amount": "50.00",
    "spent": "1.5708",
    "window": "month",
    "resets_at": "2026-11-01T00:00:00.000Z"
  }
}
```

**2. 估價**

估價不扣款、不建立工作，回傳此刻提交同一個請求時會預留的金額。

```bash theme={null}
curl https://api.blon.ai/v1/estimate \
  -H "Authorization: Bearer $BLON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-image-2","input":{"prompt":"A ceramic teapot on a linen table, soft morning light"}}'
```

```json theme={null}
{
  "model": "gpt-image-2",
  "cost": {
    "currency": "CREDITS",
    "amount": "8"
  },
  "kind": "exact",
  "reason": null
}
```

**3. 提交工作**

`POST /jobs` 回 `202 Accepted` 與工作內容。請帶 `Idempotency-Key`，重送時才不會建立第二筆工作。

```bash theme={null}
curl https://api.blon.ai/v1/jobs \
  -H "Authorization: Bearer $BLON_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"model":"gpt-image-2","input":{"prompt":"A ceramic teapot on a linen table, soft morning light"},"webhook_url":"https://example.com/hooks/blon","metadata":{"order":"A-17"}}'
```

```json theme={null}
{
  "id": "cmh2x0f6k0001qv8z9d4c1a7e",
  "object": "job",
  "model": "gpt-image-2",
  "status": "queued",
  "provider_status": null,
  "queue_position": null,
  "cancelable": true,
  "next_poll_after_seconds": 5,
  "urls": {
    "get": "https://api.blon.ai/v1/jobs/cmh2x0f6k0001qv8z9d4c1a7e",
    "cancel": "https://api.blon.ai/v1/jobs/cmh2x0f6k0001qv8z9d4c1a7e/cancel"
  },
  "input": {
    "prompt": "A ceramic teapot on a linen table, soft morning light"
  },
  "metadata": {
    "order": "A-17"
  },
  "cost": {
    "currency": "CREDITS",
    "estimated": "8",
    "charged": null,
    "refunded": "0"
  },
  "usage": null,
  "artifacts": null,
  "expires_at": null,
  "error": null,
  "webhook": {
    "url": "https://example.com/hooks/blon",
    "status": "pending",
    "attempts": 0
  },
  "idempotency_hit": false,
  "request_id": "cmh2x0f6k0001qv8z9d4c1a7e",
  "created_at": "2026-10-30T08:00:00.000Z",
  "started_at": null,
  "completed_at": null,
  "updated_at": "2026-10-30T08:00:00.000Z"
}
```

**4. 輪詢取得結果**

持續讀取工作，直到 `status` 為 `completed`、`failed` 或 `canceled`。兩次讀取之間至少間隔 `next_poll_after_seconds`。完成的工作在 `artifacts` 列出產物。

```bash theme={null}
curl https://api.blon.ai/v1/jobs/cmh2x0f6k0001qv8z9d4c1a7e \
  -H "Authorization: Bearer $BLON_API_KEY"
```

```json theme={null}
{
  "id": "cmh2x0f6k0001qv8z9d4c1a7e",
  "object": "job",
  "model": "gpt-image-2",
  "status": "completed",
  "provider_status": "succeeded",
  "queue_position": null,
  "cancelable": false,
  "next_poll_after_seconds": null,
  "urls": {
    "get": "https://api.blon.ai/v1/jobs/cmh2x0f6k0001qv8z9d4c1a7e",
    "cancel": null
  },
  "input": {
    "prompt": "A ceramic teapot on a linen table, soft morning light"
  },
  "metadata": {
    "order": "A-17"
  },
  "cost": {
    "currency": "CREDITS",
    "estimated": "8",
    "charged": "8",
    "refunded": "0"
  },
  "usage": null,
  "artifacts": [
    {
      "id": "cmh2x0g2p0002qv8zb3n5k8wd",
      "name": "default",
      "type": "image",
      "url": "https://blon.ai/api/assets/cmh2x0g2p0002qv8zb3n5k8wd?ticket=…",
      "url_expires_at": "2026-10-30T08:15:00.000Z",
      "content_type": "image/png",
      "size_bytes": 1482113,
      "width": 1024,
      "height": 1024,
      "duration_ms": null
    }
  ],
  "expires_at": "2026-11-06T08:00:00.000Z",
  "error": null,
  "webhook": {
    "url": "https://example.com/hooks/blon",
    "status": "delivered",
    "attempts": 1
  },
  "idempotency_hit": false,
  "request_id": "cmh2x0f6k0001qv8z9d4c1a7e",
  "created_at": "2026-10-30T08:00:00.000Z",
  "started_at": "2026-10-30T08:00:01.000Z",
  "completed_at": "2026-10-30T08:00:09.000Z",
  "updated_at": "2026-10-30T08:00:09.000Z"
}
```

**5. 查詢用量**

依 UTC 時間桶、模型與金鑰彙總已結算的工作，最長 31 天。這是用量報表，不是帳單。

```bash theme={null}
curl "https://api.blon.ai/v1/usage?timeframe=day" \
  -H "Authorization: Bearer $BLON_API_KEY"
```

```json theme={null}
{
  "currency": "USD",
  "timeframe": "day",
  "start": "2026-10-24T00:00:00.000Z",
  "end": "2026-10-31T00:00:00.000Z",
  "data": [
    {
      "bucket_start": "2026-10-30T00:00:00Z",
      "model": "gpt-image-2",
      "api_key_id": "key_7d2f9a",
      "jobs": 12,
      "units": {
        "output_images": 12
      },
      "cost": "0.48"
    }
  ]
}
```

> [!NOTE]
>
> 金額以呼叫者錢包的幣別表示。`blon_api_` 金鑰一律是 `USD`；本頁的工作與估價範例顯示的 `CREDITS` 是 CLI 與 MCP 看到的點數。

## 下一步

> [card] [工作請求](https://docs.blon.ai/zh-TW/concepts/requests.md)
>
> 工作的狀態與欄位。

> [card] [Webhooks](https://docs.blon.ai/zh-TW/how-to/webhooks.md)
>
> 改由通知取代輪詢。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.