Store apps can charge per run using CEL expressions evaluated against task data and output metadata.
Overview
| Piece | Role |
|---|---|
output_meta | Per-task usage your app reports (tokens, pixels, seconds, and so on) |
AppPricing | Store listing config: price variables and CEL formulas |
| Task cost | What the user was charged — see Get task cost |
All monetary values in pricing config are in microcents (1 microcent = $0.000001). Use to_dollars(microcents) in descriptions for human-readable strings.
AppPricing fields
| Field | Description |
|---|---|
prices | Named price variables (microcents), referenced as prices.name in expressions |
upstream_pricing | Optional note about upstream app pricing (display only) |
resource_expression | GPU/CPU time cost (default sums resource rates × elapsed seconds) |
inference_expression | Platform inference fee |
royalty_expression | Royalty to upstream app authors |
partner_expression | Partner revenue share |
total_expression | Final charge (defaults to sum of fee components when empty) |
description | Human-readable pricing blurb (see below) |
description_rendered | Evaluated description returned by the API after save |
estimate | Optional CEL expression for pre-execution cost estimation when fee formulas depend on post-execution data. Returns an int (exact microcents) or {"min": int, "max": int}. Only has access to task_inputs, prices, fees, and task_function. Not needed when all fee expressions are input-based (estimable: true). |
estimable | Computed at save time — true when all fee expressions can be evaluated from pre-execution data alone |
Empty fee expressions use platform defaults. Patch updates merge prices keys; setting a price to 0 removes that key.
Description field
The description is evaluated as CEL against the static prices map only (no per-task variables). Helpers like to_dollars(prices.base) format amounts for display.
Plain text is supported. If you send a normal sentence (not starting with "), the API wraps it as a CEL string literal on save — you do not need to quote descriptions yourself. Use explicit CEL when you want dynamic text from prices:
1"$" + to_dollars(prices.per_image) + " per image"Fee expressions and output_meta
Inference and total formulas can read output_meta from completed tasks — the same structure you set in app code (inputs / outputs with type, tokens, dimensions, seconds, extra, and so on).
Common CEL helpers for usage-based pricing include:
| Helper | Use |
|---|---|
text_tokens(output_meta.inputs) | Sum prompt tokens |
text_tokens(output_meta.outputs) | Sum completion tokens |
image_count(output_meta.outputs) | Count generated images |
video_seconds(output_meta.outputs) | Sum video duration |
resolution(width, height) | Tier string (720p, 1080p, …) for lookup in prices |
get(task_inputs, "field", default) | Read task input fields |
get_extra(item, "key", default) | Read extra on meta items |
Expressions also receive resources, elapsed_seconds, and intermediate fee variables (resource_fee, inference_fee, and so on) where applicable.
Populate accurate output_meta on every priced run so formulas have data to evaluate. Public task APIs do not return output_meta in output — billing reads the stored metadata internally.
Cost estimation
Apps can provide pre-execution cost estimates via the estimate field and the public estimate endpoint.
How it works
When a user calls POST /store/apps/{appId}/estimate with their intended input, the system:
- Checks if all fee expressions are input-based — if they only reference
task_inputs,prices,fees, andtask_function, the system evaluates the real expressions directly and returns an exact cost. - Falls back to the estimate expression — if any fee expression depends on post-execution data (
outputs,inputs,elapsed_seconds, etc.), the system evaluates theestimateCEL expression instead. - Returns unknown — if no estimate expression is configured and the pricing depends on post-execution data.
The estimate field
A single CEL expression on AppPricing that returns the estimated total cost. Only has access to pre-execution variables: task_inputs, prices, fees, task_function.
Returns either:
- A single int — exact estimate in microcents (confidence:
exact) - A map
{"min": int, "max": int}— cost range in microcents (confidence:range)
1{2 "prices": {3 "per_image": 5000004 },5 "inference_expression": "image_count(outputs) * prices.per_image",6 "estimate": "get_int(task_inputs, \"n\", 1) * prices.per_image"7}The estimate field is not needed when all fee expressions already use only pre-execution variables — the system detects this and evaluates them directly.
The estimable field
Computed automatically at save time. true when all fee expressions can be evaluated from pre-execution data alone. Used as a fast path to skip AST analysis on every estimate request.
Estimate endpoint
POST /store/apps/{appId}/estimate (public, no auth required)
1curl -X POST https://api.inference.sh/store/apps/{appId}/estimate \2 -H "Content-Type: application/json" \3 -d '{"input": {"prompt": "a cat", "quality": "high"}, "function": "run"}'Response:
1{2 "confidence": "exact",3 "microcents": 210720,4 "pricing_description": "$0.21 per image at high quality"5}| Field | Description |
|---|---|
confidence | exact, range, or unknown |
microcents | Cost in microcents (when exact) |
min, max | Cost range in microcents (when range) |
depends_on | Post-execution variables needed (when unknown) |
pricing_description | Rendered pricing description string |
Example
1{2 "prices": {3 "per_1k_tokens": 50000,4 "per_image": 2000005 },6 "inference_expression": "text_tokens(output_meta.outputs) * prices.per_1k_tokens / 1000",7 "description": "About to_dollars(prices.per_1k_tokens) per 1K output tokens plus to_dollars(prices.per_image) per image"8}Draft pricing is edited in the store admin UI; publishing moves draft_pricing to live pricing on the listing version.
Preview formulas before publish with POST /usage/cel/evaluate — see Usage API. For published store apps, call POST /store/apps/{appId}/estimate with draft task inputs to preview what end users see before they run — see Store API — Estimate app cost.
Next
→ Output metadata — what to report from your app
→ Task cost — how users see charges
→ Get task cost — REST breakdown per task
→ Usage API — team spend breakdown and CEL preview