Pricing Rules¶
Pricing rules describe how provider and model usage maps to customer cost.
Example¶
curl "$SPENDWARE_BASE_URL/api/v1/pricing-rules/" \
-H "Authorization: Bearer $SPENDWARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"project_id":"PROJECT_ID","title":"OpenAI GPT-4o","provider_name":"openai","model_name":"gpt-4o","strategy_type":"custom","currency":"USD","custom_cost_per_input_token":0.0000025,"custom_cost_per_output_token":0.00001}'
from spendware_provider_sdk.management import PricingRuleCreate
rule = client.pricing_rules.create(
PricingRuleCreate(
project_id="PROJECT_ID",
title="OpenAI GPT-4o",
provider_name="openai",
model_name="gpt-4o",
strategy_type="custom",
custom_cost_per_input_token=0.0000025,
custom_cost_per_output_token=0.00001,
)
)
const rule = await client.pricingRules.create({
project_id: "PROJECT_ID",
title: "OpenAI GPT-4o",
provider_name: "openai",
model_name: "gpt-4o",
strategy_type: "custom",
custom_cost_per_input_token: 0.0000025,
custom_cost_per_output_token: 0.00001,
});
Common Errors¶
- Pricing rules should use raw per-token or per-request costs.
- Currency should match the project, customer, and billing workflow expectations.
- Use provider settings when you need layered provider catalog behavior across organization or user scopes.