# Dimensional Pricing [API Reference](https://docs.credyt.ai/api/products-create.md) Dimensional Pricing allows pricing to adapt based on custom attributes (billable dimensions) of a usage event; such as speed, quality, or model type. Instead of creating separate prices for each dimension value, you define a single price and assign values for each variation of your billable dimensions. This reduces your setup and maintenance effort and ensures pricing consistency across dimensions. You can use `*` as the value to specify fallback pricing for your product. In the following example we charge a different price based on the `speed` of the video generation task. This field is included in the usage events sent to Credyt. Here we charge $1.00/minute for "fast" workloads and $0.40/minute for "regular" speed workloads. A fallback of $0.40/minute is specified if an unknown speed is sent through. * REST API * TypeScript SDK * Python SDK POST https\://api.credyt.ai/products ```json { "name": "Glitch Video Advanced", "code": "glitch_video_adv", "prices": [ { "name": "Video Generation Compute", "type": "usage_based", "billing_model": { "type": "real_time" }, "usage_calculation": { "event_type": "video_generated", "usage_type": "unit_and_volume", "volume_field": "minutes", "source_reference_field": "video_id", "billable_dimensions": [ "speed" ] }, "pricing": [ { "asset": "USD", "values": [ { "name": "Video Generation Minutes (Fast)", "dimensions": { "speed": "fast" }, "values": [ { "volume_rate": 1 } ] }, { "name": "Video Generation Minutes (Regular)", "dimensions": { "speed": "regular" }, "values": [ { "volume_rate": 0.4 } ] }, { "name": "Video Generation Minutes (Default)", "dimensions": { "speed": "*" }, "values": [ { "volume_rate": 0.4 } ] } ] } ] } ], "publish": true } ``` **Response** ```json { "id": "prp_4e28n8kk41931f5yt5em49ecw7", "code": "glitch_video_adv", "version": 1, "status": "published", "is_default": true } ``` ```typescript await client.products.create({ name: "Glitch Video Advanced", code: "glitch_video_adv", prices: [ { name: "Video Generation Compute", type: "usage_based", billingModel: { type: "real_time", }, usageCalculation: { eventType: "video_generated", usageType: "unit_and_volume", volumeField: "minutes", sourceReferenceField: "video_id", billableDimensions: [ "speed", ], }, pricing: [ { asset: "USD", values: [ { name: "Video Generation Minutes (Fast)", dimensions: { speed: "fast", }, values: [ { volumeRate: 1, }, ], }, { name: "Video Generation Minutes (Regular)", dimensions: { speed: "regular", }, values: [ { volumeRate: 0.4, }, ], }, { name: "Video Generation Minutes (Default)", dimensions: { speed: "*", }, values: [ { volumeRate: 0.4, }, ], }, ], }, ], }, ], publish: true, }); ``` [View full sample on GitHub](https://github.com/credyt/sdk-ts/blob/main/samples/productsCreateSample.ts#L11) **SDK response object** ```typescript const response = { id: "prp_4e28n8kk41931f5yt5em49ecw7", code: "glitch_video_adv", version: 1, status: "published", isDefault: true, }; ``` ```python response = client.products.create( body={ "name": "Glitch Video Advanced", "code": "glitch_video_adv", "prices": [ { "name": "Video Generation Compute", "type": "usage_based", "billing_model": { "type": "real_time", }, "usage_calculation": { "event_type": "video_generated", "usage_type": "unit_and_volume", "volume_field": "minutes", "source_reference_field": "video_id", "billable_dimensions": [ "speed", ], }, "pricing": [ { "asset": "USD", "values": [ { "name": "Video Generation Minutes (Fast)", "dimensions": { "speed": "fast", }, "values": [ { "volume_rate": 1, }, ], }, { "name": "Video Generation Minutes (Regular)", "dimensions": { "speed": "regular", }, "values": [ { "volume_rate": 0.4, }, ], }, { "name": "Video Generation Minutes (Default)", "dimensions": { "speed": "*", }, "values": [ { "volume_rate": 0.4, }, ], }, ], }, ], }, ], "publish": True, }, ) ``` [View full sample on GitHub](https://github.com/credyt/sdk-python/blob/main/samples/products_create_dimensional_usage_based_price.py#L20) **SDK response object** ```python response = { "id": "prp_4e28n8kk41931f5yt5em49ecw7", "code": "glitch_video_adv", "version": 1, "status": "published", "is_default": True, } ``` When sending usage for a customer subscribed to the above product, the price will be matched based on the `event_type` and billing dimensions included in the `data` object of the incoming usage event. In the following example, the price for "Video Generation Minutes (Fast)" would be matched since `data.speed = "fast"`. * REST API * TypeScript SDK * Python SDK POST https\://api.credyt.ai/events ```json { "customer_id": "cust_4td6grpw680sgewcaz5p89pf40", "events": [ { "id": "ba15987a-7b68-4a9d-b2e6-eadeff29e657", "event_type": "video_generated", "occurred_at": "2025-11-04T21:53:21.392Z", "subject": "video_defc8524", "description": "Video Generated", "data": { "minutes": 10, "speed": "fast" } } ] } ``` ```typescript await client.events.sendUsage({ customerId: "cust_4td6grpw680sgewcaz5p89pf40", events: [ { id: "ba15987a-7b68-4a9d-b2e6-eadeff29e657", eventType: "video_generated", occurredAt: "2025-11-04T21:53:21.392Z", subject: "video_defc8524", description: "Video Generated", data: { minutes: 10, speed: "fast", }, }, ], }); ``` [View full sample on GitHub](https://github.com/credyt/sdk-ts/blob/main/samples/eventsSendUsageSample.ts#L35) ```python response = client.events.send_usage( body={ "customer_id": "cust_4td6grpw680sgewcaz5p89pf40", "events": [ { "id": "ba15987a-7b68-4a9d-b2e6-eadeff29e657", "event_type": "video_generated", "occurred_at": "2025-11-04T21:53:21.392Z", "subject": "video_defc8524", "description": "Video Generated", "data": { "minutes": 10, "speed": "fast", }, }, ], }, ) ``` [View full sample on GitHub](https://github.com/credyt/sdk-python/blob/main/samples/events_send_usage_video_generated.py#L20)