Skip to main content
PUT
Update 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.

Path Parameters

id
string<uuid>
required

Identifier, a UUID

Body

application/json
cache_read_cost_per_million_tokens
number<double> | null

Update prompt-cache rates. Same NULL semantics as CreatePricingRequest: omitted = leave existing value alone; JSON null = explicitly clear the override.

cache_write_cost_per_million_tokens
number<double> | null
change_reason
string | null
effective_from
string<date-time> | null

Reschedule the activation date. Past values are rejected by the db layer's update_scheduled guard, but a future timestamp is fine and a near-now() timestamp effectively "activates now".

input_cost_per_million_tokens
number<double> | null
long_context
object | null

Update the long-context surcharge (BCP-3904). Same three-state semantics as the cache rates: omitted = leave the tier alone, JSON null = remove the tier entirely, an object = set it.

The tier moves as a unit, so null clears the threshold and every tier rate together — there is no way to null out one tier rate while keeping the others, which is what the DB constraint requires anyway.

output_cost_per_million_tokens
number<double> | null
sync_mode
enum<string> | null

Omit (or pass null) to leave the mode unchanged.

Available options:
tracking,
pinned,
auto

Response

The requested 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