compute_price
Compute a price for a product/context via the Last Price Pricing Compute Network. Returns the computed price, the function that produced it, token metering/cost, and a trace listing each stage the request passed through (cache, route, execute, fallback, constrain, meter). For a competitor offer, put competitor_price, competitor_currency and competitive_action in metadata, then supply min_price or unit_cost with target_margin_pct. Missing business inputs return an error naming them.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geo | No | Optional geography hint, e.g. US. | |
| currency | Yes | Three-letter ISO currency code, e.g. USD. | |
| metadata | No | Optional context. For competitive pricing: competitor_price, competitor_currency and competitive_action (match or undercut); undercut requires undercut_pct. Confirm product comparability before calling. | |
| max_price | No | Optional maximum acceptable price. | |
| min_price | No | Optional minimum acceptable price. A competitive offer needs this or a declared unit_cost and target_margin_pct. | |
| unit_cost | No | What the work costs you. It lets lastprice/cost-plus price with no current_price, which is the usual case when pricing a task you are about to run. Routing picks a function that can use it; to require cost-plus, pass its UUID from list_functions as function_id. | |
| product_id | No | Optional identifier of what is being priced. | |
| function_id | No | Optional explicit pricing function UUID to use. | |
| product_type | No | Optional category. Defaults to "custom". | |
| current_price | No | The current or reference price. Optional: functions that price relative to an incumbent need it, but lastprice/cost-plus prices from unit_cost instead. | |
| customer_segment | No | Optional segment, e.g. enterprise. | |
| target_margin_pct | No | Margin on price for cost-plus, not markup on cost: price = unit_cost / (1 - margin). Defaults to 30. | |
| routing_preference | No | How to route across pricing functions. Defaults to "default". | |
| include_explanation | No | If true, ask for an explanation and confidence with the price. |