Happy Pony API Get an API key →

Billing records

Pricing: all features

GET /api/v1/billing/records lists every charge on your account, one record per job or chat completion, so you can track consumption, reconcile what you were charged and bill your own users. It takes an API key, or your session when you are signed in on www.happypony.io (the Credits page shows the same data).

Tag requests with userId

Every create endpoint under /api/v1/jobs/ and POST /v1/chat/completions takes an optional userId in the JSON body: your own identifier for the user the request is for.

Field Type Required Description
userId string no Your identifier for the user this request belongs to: 1–128 characters, no control characters. Stored with the job and its charge, and returned on the create, status and result responses.
curl -X POST https://api.happypony.io/api/v1/jobs/text-to-video \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": "a fox runs through snow", "duration": 5, "userId": "user-1042"}'

A request without userId works exactly as before and is recorded with userId: null: all such requests form one unattributed group for the account. Anything other than a string of at most 128 characters is 400 invalid_request. On chat completions userId is removed before the request reaches the model; OpenAI's own user field is used instead when userId is absent, so an OpenAI SDK can tag requests with user= alone. userId is not accepted on video-agent runs, whose jobs are recorded without one.

List billing records

curl "https://api.happypony.io/api/v1/billing/records?userId=user-1042&from=2026-11-01T00:00:00Z&to=2026-12-01T00:00:00Z" \
  -H "Authorization: Bearer $HP_KEY"
Query Default
from, to open ISO timestamps bounding the billing time; from inclusive, to exclusive
userId every record Only this user's records. Sent empty (userId=), only the records that carry no userId
model every model Exact model name, as in a record's model
request_id every request One task: a job's request_id, or a chat completion's x-request-id
limit 50 Records per page, 1 to 200
offset 0
{
  "totals": { "records": 3, "credits": 30.047, "credits_refunded": 15, "net_credits": 15.047, "net_usd": 0.15047 },
  "records": [
    { "request_id": "48213", "userId": "user-1042", "billed_at": "2026-11-28T02:42:41.000Z", "model": "minimax_h3-turbo",
      "type": "text-to-video", "status": "COMPLETED", "credits": 15, "credits_refunded": 0, "net_credits": 15, "net_usd": 0.15,
      "usage": { "mode": "text-to-video", "tier": "turbo", "resolution": "768p", "aspect_ratio": "16:9", "duration_seconds": 5 } },
    { "request_id": "48209", "userId": "user-1042", "billed_at": "2026-11-28T02:40:04.000Z", "model": "minimax_h3-turbo",
      "type": "image-to-video", "status": "FAILED", "credits": 15, "credits_refunded": 15, "net_credits": 0, "net_usd": 0,
      "usage": { "mode": "image-to-video", "tier": "turbo", "resolution": "768p", "aspect_ratio": "9:16", "duration_seconds": 5 } },
    { "request_id": "chatcmpl-9f2c…", "userId": "user-1042", "billed_at": "2026-11-28T02:39:12.000Z", "model": "qwen3.8-27b",
      "type": "chat-completions", "status": "COMPLETED", "credits": 0.047, "credits_refunded": 0, "net_credits": 0.047, "net_usd": 0.00047,
      "usage": { "prompt_tokens": 1000, "cached_tokens": 200, "completion_tokens": 500 } }
  ],
  "limit": 50,
  "offset": 0
}
Field Type Description
request_id string The unique task ID: the job's request_id, or the chat completion's x-request-id.
userId string or null The userId the request carried, null when it had none.
billed_at string When the charge was made: the time the request was accepted (jobs are charged up front).
model string The model that ran it.
type string The job type (text-to-video, image-edit, …) or chat-completions.
status string IN_QUEUE, IN_PROGRESS, COMPLETED, FAILED or CANCELLED.
credits number What was charged. 1 credit = $0.01; chat completions cost fractions of a credit.
credits_refunded number What came back: the whole charge of a job that failed or was cancelled.
net_credits, net_usd number credits minus credits_refunded, and the same in US dollars.
usage object What the charge was worked out from. A job lists what applies to it: mode (the generation mode, same as type), tier (turbo or quality), variant, resolution (such as 768p), aspect_ratio, duration_seconds and outputs (how many images or clips). A chat completion lists prompt_tokens, cached_tokens and completion_tokens.

totals cover everything the filters match, records are one page of it, newest first. Records include jobs made on the website and by video-agent runs, with userId: null. A malformed from, to, userId, limit or offset is 400 invalid_request.

Totals per userId

GET /api/v1/billing/users takes the same filters (without limit and offset) and adds the records up per userId, largest net charge first, at most 500 users. Requests without a userId are one line with userId: null.

{
  "users": [
    { "userId": "user-1042", "records": 36, "credits": 540, "credits_refunded": 45, "net_credits": 495, "net_usd": 4.95 },
    { "userId": null, "records": 72, "credits": 108, "credits_refunded": 11, "net_credits": 97, "net_usd": 0.97 }
  ]
}

账单明细

价格:所有功能

GET /api/v1/billing/records 列出账户的每一笔扣费,每个任务或每次 chat completion 一条记录,便于跟踪用量、核对扣费,以及向你自己的用户计费。可使用 API key,或在 www.happypony.io 登录后的会话(积分页面展示的是同一份数据)。

用 userId 标记请求

/api/v1/jobs/ 下的所有创建接口和 POST /v1/chat/completions 都接受 JSON 请求体中的可选字段 userId:你自己系统里该请求所属用户的标识。

字段 类型 必填 说明
userId string 否 该请求所属用户的标识:1–128 个字符,不能包含控制字符。它会随任务和扣费一起保存,并在创建、状态和结果响应中返回。
curl -X POST https://api.happypony.io/api/v1/jobs/text-to-video \
  -H "Authorization: Bearer $HP_KEY" -H "Content-Type: application/json" \
  -d '{"prompt": "a fox runs through snow", "duration": 5, "userId": "user-1042"}'

不带 userId 的请求与以前完全一样,记录为 userId: null:这类请求在账户下合并为一个未归属的分组。不是字符串或超过 128 个字符时返回 400 invalid_request。在 chat completions 中,userId 会在请求到达模型之前移除;没有 userId 时改用 OpenAI 自带的 user 字段,因此 OpenAI SDK 只传 user= 也能标记请求。video-agent run 不接受 userId,它产生的任务不带用户标识。

查询账单记录

curl "https://api.happypony.io/api/v1/billing/records?userId=user-1042&from=2026-11-01T00:00:00Z&to=2026-12-01T00:00:00Z" \
  -H "Authorization: Bearer $HP_KEY"
查询参数 默认值
from、to 不限 限定计费时间的 ISO 时间戳;包含 from,不包含 to
userId 所有记录 只看该用户的记录。传空值(userId=)时只看没有 userId 的记录
model 所有模型 模型名,须与记录中的 model 完全一致
request_id 所有请求 某一个任务:任务的 request_id,或 chat completion 的 x-request-id
limit 50 每页记录数,1 到 200
offset 0
{
  "totals": { "records": 3, "credits": 30.047, "credits_refunded": 15, "net_credits": 15.047, "net_usd": 0.15047 },
  "records": [
    { "request_id": "48213", "userId": "user-1042", "billed_at": "2026-11-28T02:42:41.000Z", "model": "minimax_h3-turbo",
      "type": "text-to-video", "status": "COMPLETED", "credits": 15, "credits_refunded": 0, "net_credits": 15, "net_usd": 0.15,
      "usage": { "mode": "text-to-video", "tier": "turbo", "resolution": "768p", "aspect_ratio": "16:9", "duration_seconds": 5 } },
    { "request_id": "48209", "userId": "user-1042", "billed_at": "2026-11-28T02:40:04.000Z", "model": "minimax_h3-turbo",
      "type": "image-to-video", "status": "FAILED", "credits": 15, "credits_refunded": 15, "net_credits": 0, "net_usd": 0,
      "usage": { "mode": "image-to-video", "tier": "turbo", "resolution": "768p", "aspect_ratio": "9:16", "duration_seconds": 5 } },
    { "request_id": "chatcmpl-9f2c…", "userId": "user-1042", "billed_at": "2026-11-28T02:39:12.000Z", "model": "qwen3.8-27b",
      "type": "chat-completions", "status": "COMPLETED", "credits": 0.047, "credits_refunded": 0, "net_credits": 0.047, "net_usd": 0.00047,
      "usage": { "prompt_tokens": 1000, "cached_tokens": 200, "completion_tokens": 500 } }
  ],
  "limit": 50,
  "offset": 0
}
字段 类型 说明
request_id string 任务的唯一 ID:任务的 request_id,或 chat completion 的 x-request-id。
userId string 或 null 请求携带的 userId,没有时为 null。
billed_at string 扣费时间:请求被接受的时间(任务在创建时预先扣费)。
model string 执行该请求的模型。
type string 任务类型(text-to-video、image-edit 等)或 chat-completions。
status string IN_QUEUE、IN_PROGRESS、COMPLETED、FAILED 或 CANCELLED。
credits number 扣除的积分。1 积分 = $0.01;chat completions 的费用不足 1 积分。
credits_refunded number 退回的积分:失败或取消的任务会全额退回。
net_credits、net_usd number credits 减去 credits_refunded,以及对应的美元金额。
usage object 计费依据。任务只列出与它相关的项:mode(生成模式,与 type 相同)、tier(turbo 或 quality)、variant、resolution(如 768p)、aspect_ratio、duration_seconds 和 outputs(图片或视频的数量)。chat completion 列出 prompt_tokens、cached_tokens 和 completion_tokens。

totals 统计筛选条件匹配的全部记录,records 是其中一页,按时间从新到旧。记录也包含在网站上创建的任务和 video-agent run 产生的任务,它们的 userId 为 null。from、to、userId、limit 或 offset 格式错误时返回 400 invalid_request。

按 userId 汇总

GET /api/v1/billing/users 接受同样的筛选条件(不含 limit 和 offset),按 userId 汇总记录,净消费从高到低,最多 500 个用户。没有 userId 的请求合并为一行,userId 为 null。

{
  "users": [
    { "userId": "user-1042", "records": 36, "credits": 540, "credits_refunded": 45, "net_credits": 495, "net_usd": 4.95 },
    { "userId": null, "records": 72, "credits": 108, "credits_refunded": 11, "net_credits": 97, "net_usd": 0.97 }
  ]
}