Cost Tracking

Estimate Cost

Estimate cost for a given model and token counts.

This endpoint uses the same cost calculation logic as actual requests, including any configured margins and discounts.

Parameters:

  • model: Model name (e.g., "gpt-4", "claude-3-opus")
  • input_tokens: Expected input tokens per request
  • output_tokens: Expected output tokens per request
  • cache_read_input_tokens: Cache-read tokens per request, counted within input_tokens (optional)
  • cache_creation_input_tokens: Cache-write tokens per request, counted within input_tokens (optional)
  • reasoning_tokens: Reasoning tokens per request, counted within output_tokens (optional)
  • num_requests_per_day: Number of requests per day (optional)
  • num_requests_per_month: Number of requests per month (optional)

Returns cost breakdown including:

  • Per-request costs (input, output, margin, plus the cache-read, cache-write and reasoning shares)
  • Daily costs (if num_requests_per_day provided)
  • Monthly costs (if num_requests_per_month provided)

Example:

{
    "model": "gpt-4",
    "input_tokens": 1000,
    "cache_read_input_tokens": 800,
    "output_tokens": 500,
    "reasoning_tokens": 200,
    "num_requests_per_day": 100,
    "num_requests_per_month": 3000
}
post/cost/estimate

Request

  • Base URL: https://docs.litellm.com.cn (the document declares no server; this is the origin it was published from)
  • URL: https://docs.litellm.com.cn/cost/estimate
  • Auth: API key in header x-litellm-api-key

Request body

modelstring required

Model name (from /model_group/info)

input_tokensinteger required

Expected input tokens per request

output_tokensinteger required

Expected output tokens per request

cache_read_input_tokensinteger

Input tokens read from the prompt cache; counted within input_tokens

cache_creation_input_tokensinteger

Input tokens written to the prompt cache; counted within input_tokens

reasoning_tokensinteger

Reasoning tokens the model emits; counted within output_tokens

num_requests_per_dayinteger nullable

Number of requests per day

num_requests_per_monthinteger nullable

Number of requests per month

Response

Successful Response

modelstring required
input_tokensinteger required
output_tokensinteger required
cache_read_input_tokensinteger
cache_creation_input_tokensinteger
reasoning_tokensinteger
num_requests_per_dayinteger nullable
num_requests_per_monthinteger nullable
cost_per_requestnumber required

Total cost per request (includes margin)

input_cost_per_requestnumber required

Input token cost per request (before margin)

output_cost_per_requestnumber required

Output token cost per request (before margin)

margin_cost_per_requestnumber

Margin/fee added per request

cache_read_cost_per_requestnumber

Cache-read share of input_cost_per_request

cache_creation_cost_per_requestnumber

Cache-write share of input_cost_per_request

reasoning_cost_per_requestnumber

Reasoning share of output_cost_per_request

daily_costnumber nullable

Total daily cost (includes margin)

daily_input_costnumber nullable

Daily input token cost

daily_output_costnumber nullable

Daily output token cost

daily_margin_costnumber nullable

Daily margin/fee

daily_cache_read_costnumber nullable

Cache-read share of daily_input_cost

daily_cache_creation_costnumber nullable

Cache-write share of daily_input_cost

daily_reasoning_costnumber nullable

Reasoning share of daily_output_cost

monthly_costnumber nullable

Total monthly cost (includes margin)

monthly_input_costnumber nullable

Monthly input token cost

monthly_output_costnumber nullable

Monthly output token cost

monthly_margin_costnumber nullable

Monthly margin/fee

monthly_cache_read_costnumber nullable

Cache-read share of monthly_input_cost

monthly_cache_creation_costnumber nullable

Cache-write share of monthly_input_cost

monthly_reasoning_costnumber nullable

Reasoning share of monthly_output_cost

input_cost_per_tokennumber nullable

Rate billed per input token

output_cost_per_tokennumber nullable

Rate billed per output token

cache_read_input_token_costnumber nullable

Rate billed per cache-read token

cache_creation_input_token_costnumber nullable

Rate billed per cache-write token

output_cost_per_reasoning_tokennumber nullable

Rate billed per reasoning token

providerstring nullable

Changes

No recorded changes to this operation across all 1 revision of this API.