Skip to main content
POST
Create a model pricing rule

Authorizations

Authorization
string
header
required

A Barndoor API key, sent as Authorization: Bearer <key>. Keys are prefixed bdai_ and are opaque — do not attempt to decode one. Interchangeable with an OAuth 2.0 access token.

Body

application/json
input_cost_per_million_tokens
number<double>
required
model_pattern
string
required
output_cost_per_million_tokens
number<double>
required
cache_read_cost_per_million_tokens
number<double> | null

Per-million-tokens rate billed for prompt-cache reads. Omit to inherit the Barndoor default (or leave NULL if the default has none, in which case the cost calculator falls back to the full input rate). Storing NULL preserves the "no override" semantics so a future seeder update can repopulate the default rate without the org row blocking it.

cache_write_cost_per_million_tokens
number<double> | null

Per-million-tokens rate billed for the cache-creation premium that Anthropic-family models charge on the request that populates the prompt cache. Same NULL semantics as cache_read_cost.

catalog_slug
string | null
change_reason
string | null

Optional free-text note ("Q1 pricing review", "Negotiated discount") surfaced on the History dialog timeline.

effective_from
string<date-time> | null

When the price should take effect. Omit (or pass null) for "right now". A timestamp in the future schedules the change and records the row with change_source = 'admin_schedule' so the History dialog can distinguish it from an immediate edit.

long_context
object | null

Optional context-tiered surcharge (BCP-3904). Omit for the normal case of one rate set at every prompt size.

model_provider
string | null
provider_id
string<uuid> | null
sync_mode
enum<string>

Per-row sync behavior. Stored as a VARCHAR(16) constrained to tracking | pinned | auto (see migration V33).

Available options:
tracking,
pinned,
auto

Response

The created record

Admin-API response shape for a single pricing row. Wraps the ai_governance::ModelPricing used by the cost calculator so that the hot path stays sync-mode-agnostic, while the admin surface still gets the metadata it needs to render badges, the Review-updates dialog, and (as of BCP-2830 v2 / V34) the per-row history timeline.

effective_from
string<date-time>
required
id
string<uuid>
required
input_cost_per_million_tokens
number<double>
required
model_pattern
string
required
org_id
string<uuid>
required
output_cost_per_million_tokens
number<double>
required
change_source
enum<string>
required

How a model_pricing version was produced. Persisted as a VARCHAR(20) constrained to one of these eight values (see migrations V34 + V35). Surfaced to admins as the "source" badge on each entry of the PricingHistoryDialog.

Available options:
admin_create,
admin_edit,
admin_schedule,
import,
sync_manual,
sync_auto,
admin_archive,
admin_restore
is_archived
boolean
required

True for tombstone rows produced by archive_rule (V35). When the latest effective version of a group has is_archived = true, the rule is considered archived: the cost calculator skips it and the admin summary list hides it by default. Past non-archived versions remain in the timeline so the History dialog can show the rule's full life including the archive event.

sync_mode
enum<string>
required

Per-row sync behavior. Stored as a VARCHAR(16) constrained to tracking | pinned | auto (see migration V33).

Available options:
tracking,
pinned,
auto
cache_read_cost_per_million_tokens
number<double> | null

Per-million-token cost for input tokens served from the prompt cache. None ⇒ the calculator bills cached input at input_cost_per_million_tokens.

cache_write_cost_per_million_tokens
number<double> | null

Per-million-token cost for input tokens added to the prompt cache. None ⇒ same fallback as cache_read_cost_per_million_tokens.

catalog_slug
string | null

Catalog slug for provider-level pricing (e.g. "openai", "aws_bedrock").

long_context
object | null

Optional context-tiered surcharge (BCP-3904). None ⇒ one rate set at every prompt size, i.e. exactly the pre-BCP-3904 behaviour.

Serialized as long_context, not as the Rust field name. This struct reaches the admin API through AdminModelPricing's #[serde(flatten)], so the field name here is the wire key — and every sibling surface (DefaultPricingEntry, EffectivePricing, the create/update request bodies) already spells it long_context. Left unrenamed, the pricing tab would write a tier successfully and then read back nothing, which is precisely how it behaved before this attribute existed: the surcharge saved, the dialog reopened unchecked, and the edit looked silently discarded. Pinned by admin_model_pricing_serializes_the_tier_as_long_context.

model_provider
string | null
provider_id
string<uuid> | null

Optional reference to a specific LLM Gateway provider instance.

provider_name
string | null
change_reason
string | null
created_by_email
string | null
created_by_name
string | null
created_by_user_id
string<uuid> | null