Creating a Pricing Plan Object
To define a custom pricing plan using usage-based dimension pricing, you will construct a Pricing Plan object. This object is composed of one or more Price Generators. Each Price Generator corresponds to a specific meter, a resource or service you want to charge for, and defines how usage of that meter is priced based on dimension values.
Conceptual Overview:
Think of a Price Generator as the pricing definition for a single meter. For every meter you intend to bill your customer for, you will create one Price Generator. Each Price Generator will have one or more Price Tiers. Price Tiers are where you will set the price based on specific parameters such as dimensions, block size and tiered pricing. The completed Price Generator are then bundled together in the Pricing plan to create complete pricing for your customers.
Each Price Generator includes:
- A list of dimensionKeys (e.g., model_name, input-output, instance_type) that determine how pricing is calculated.
- A list of Price Tiers, where each tier defines a price for a specific combination of dimension values
Each Price Tier defines:
- A specific combination of dimensionValues (e.g., ["gpt-4", "input"])
- One or more volume-based rates (e.g., dimensional pricing, tiered pricing)
Workflow Summary:
- Define one Price Generator per meter.
- Specify the relevant dimensionKeys.
- Create one or more Price Tiers per generator, each with dimension values and rates.
- Wrap the Price Generators into a single Pricing Plan object.
- Send the full object to the API endpoint:
Pricing Plan Object Structure
{
"id": "uuid",
"type": "custom_pricing_plan",
"planName": "Name of pricing plan",
"description": "Optional plan description",
"billingPeriod": {
"interval": "month",
"intervalsCount": 1,
"frequency": "month"
},
"planLevelFreeTier": null,
"realTimePricing": false,
"lockingStatus": "open",
"isDefault": false,
"feeMap": {},
"priceGenerators": []
}Price Generator Structure
{
"id": "uuid",
"type": "usage_based_dimension",
"usageTransformer": null,
"productItemId": "uuid of the meter you are creating the pricing for",
"productItemPriceName": "uuid",
"lockingStatus": "open",
"dimensionKeys": ["model_name", "input-output"],
"priceTiers": []
}Note: To get the productItemId you need to call the Get all product items API . It will return an object with onformation on your meters for the purposes of pricing. Find the meter you want to price and use the id field for the productItemId .
Price Tier Structure
{
"dimensionValues": ["gpt-4", "input"],
"priceTiers": [
{
"startAfterUnit": 0,
"batchSize": 1,
"pricePerBatch": 0.000002
},
{
"startAfterUnit": 10000000,
"batchSize": 1,
"pricePerBatch": 0.000001
}
],
"leafNodeType": "PricePerUnitLeafNode"
}Example Variations
Basic Usage-Based Pricing
{
"type": "usage_based_no_dimension",
"productItemId": "uuid",
"priceTiers": [
{
"startAfterUnit": 0,
"batchSize": 1,
"pricePerBatch": 3.14
}
],
"leafNodeType": "PricePerUnitLeafNode"
}Dimension-Based Pricing
{
"type": "usage_based_dimension",
"dimensionKeys": ["model_name", "input-output"],
"priceTiers": [
{
"dimensionValues": ["gpt-4", "input"],
"priceTiers": [
{"startAfterUnit": 0, "batchSize": 1, "pricePerBatch": 0.000002}
],
"leafNodeType": "PricePerUnitLeafNode"
}
]
}Flat Rate Pricing
Flat rates are defined in the feeMap field within the Pricing Plan object.
"feeMap": {
"a5a5cc62-f2a0-44d2-9ffc-124664fdf69b": {
"cost": 500,
"discountable": false,
"description": "Recurring fee",
"name": "Access Fee",
"isOneTimeFee": false,
"isProrated": false,
"prorateToDay": false,
"prepayable": true,
"id": "a5a5cc62-f2a0-44d2-9ffc-124664fdf69b"
}
}Notes and Best Practices
- dimensionKeys and dimensionValues must match in order.
- Use null in dimensionValues to wildcard a dimension.
- Sort more specific price tiers before general ones. It will use the first matching condition it finds.
- Set lockingStatus to open if you want to make more changes. Lock your plan (lockingStatus: "close_to_changes") to activate.