Create or Schedule Pricing - Barndoor Documentation
Create or Schedule a Pricing Rule
cURL Example
curl --request POST \
--url https://app.barndoor.ai/api/llm-gateway/admin/model-pricing \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model_pattern": "gpt-4o-mini",
"input_cost_per_million_tokens": 123,
"output_cost_per_million_tokens": 123,
"model_provider": "<string>",
"effective_from": "2023-11-07T05:31:56Z",
"provider_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"catalog_slug": "<string>",
"change_reason": "Q1 negotiated pricing",
"cache_read_cost_per_million_tokens": 123,
"cache_write_cost_per_million_tokens": 123
}
'
Python Example
import requests
url = "https://app.barndoor.ai/api/llm-gateway/admin/model-pricing"
payload = {
"model_pattern": "gpt-4o-mini",
"input_cost_per_million_tokens": 123,
"output_cost_per_million_tokens": 123,
"model_provider": "<string>",
"effective_from": "2023-11-07T05:31:56Z",
"provider_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"catalog_slug": "<string>",
"change_reason": "Q1 negotiated pricing",
"cache_read_cost_per_million_tokens": 123,
"cache_write_cost_per_million_tokens": 123
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
Response
The following is the expected response format:
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"org_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"model_pattern": "gpt-4o-mini",
"input_cost_per_million_tokens": 0.15,
"output_cost_per_million_tokens": 0.6,
"effective_from": "2023-11-07T05:31:56Z",
"is_archived": true,
"model_provider": "<string>",
"provider_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"catalog_slug": "<string>",
"cache_read_cost_per_million_tokens": 123,
"cache_write_cost_per_million_tokens": 123,
"change_reason": "<string>",
"created_by_user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_by_email": "<string>"
}
Error Handling
In case of a failure, the API might return:
{
"error": "BadRequest",
"message": "request_timeout_secs must be between 1 and 3600"
}
Additional Information
Creates a new pricing version for a model. Pricing drives every cost-aware feature on the platform — usage attribution, spend reporting, and token budgets with a cost_limit.