OhMyGPT
Billing

Estimate request cost

POST
/v1/cost-estimates

Estimates what a request would cost without sending it or charging the account. Send the body you would send to the model's endpoint. Video models are priced exactly as POST /v1/videos freezes the job price, from seconds, size and media; text to speech is priced by the characters of input; chat models get an upper bound from the text of messages and max_tokens. Image models are estimated from the output tokens per image the provider publishes for the requested quality and size (listed in limits.image of GET /v1/models), times n, plus the estimated tokens of prompt; reference images of edits are not included. Image models, sizes or qualities without published numbers return confidence: unavailable with zero cost. The model string is resolved the same way a request is, at the prices your account pays; when several providers could serve it at different prices, the most expensive is returned, because the serving provider depends on availability at request time. Time-window pricing (peak/off-peak) is resolved at the current UTC time.

授权

ApiKeyAuth
headerAuthorization<token>

请求主体

application/json
  1. body

The body you would send to the model's endpoint; fields the estimate does not read are ignored.

input?string

Text to speech models, the text to read aloud.

max_completion_tokens?integer
max_tokens?integer
media?array<>

Video models.

messages?array<unknown>

Chat models.

model*string
n?integer

Image models, the number of images.

范围1 <= value
默认1
prompt?string

Video models, required as in POST /v1/videos; image models, the prompt whose text tokens are estimated.

quality?string

Image models, such as low, medium or high. A missing quality or auto lets the model choose, so the estimate uses the highest published quality for the size and returns upper_bound.

seconds?integer

Video models.

size?string

Video models; image models, one of the sizes in the model's limits.image.output_tokens, such as 1024x1024, 1536x1024 or 1024x1536. A missing size or auto gives unavailable.

[key: string]?any

响应主体

Cost estimate.

application/json
  1. response
confidence*string

exact is what the request is charged (for video, the price the job freezes); upper_bound is the most it can cost; estimate is an image request whose output size is fixed by the provider's published table and whose prompt tokens are estimated, so the charge can differ slightly; unavailable means no price can be given before the request runs, and the costs and credits are zero.

值于"exact""upper_bound""estimate""unavailable"
credits*integer

The estimate in Credits, the number in max_total_cost.

estimated_input_cost*string
estimated_input_tokens?integer
max_output_cost*string
max_output_tokens?integer
max_total_cost*string
model*string
示例请求
curl -X POST 'https://api.ohmygpt.com/v1/cost-estimates' \  -H 'Content-Type: application/json' \  -d '{  "model": "string"}'
示例响应
{  "confidence": "exact",  "credits": 0,  "estimated_input_cost": "string",  "estimated_input_tokens": 0,  "max_output_cost": "string",  "max_output_tokens": 0,  "max_total_cost": "string",  "model": "string"}