Get cost summary

Endpoint
GET/v1/billing/costs

Returns the cost summary for the authenticated API key over a time range. Only the summary is returned, not per-request details.

Request

Authenticate with Authorization: Bearer sk-moyiapi-xxxxxx.

Parameters

Parameter In Type Required Notes
start_time query integer Yes Start time (Unix seconds), inclusive
end_time query integer Yes End time (Unix seconds), exclusive

The range may span at most 90 days; longer ranges return 400 invalid_request.

Response

json
{
  "start_time": 1784044800,
  "end_time": 1784131200,
  "total_amount": {"value": "1.280000", "currency": "USD"},
  "requests": 86
}
Field Notes
start_time / end_time The range that was applied
total_amount Total cost in the range; value is a string amount
requests Number of requests in the range

Prices may change. Use the returned amounts for historical bills rather than recomputing from the current price table.

Examples

bash
curl "https://moyiapi.com/v1/billing/costs?start_time=1784044800&end_time=1784131200" \
  -H "Authorization: Bearer sk-moyiapi-xxxxxx"

Errors

HTTP status error.code When it happens
400 invalid_request Invalid parameters, such as end_time not after start_time or a range over 90 days
Ready? Three steps to startLog in to the console · top up · create an API key
DiscordGet community help instantly
Get cost summary · Docs