## Description When the requested model has no price, price AI Gateway token usage by the model the provider reports instead of leaving it unpriced. This covers providers that resolve an alias to a specific model, such as `codex-auto-review` served as `gpt-5.6-luna`. Stacked on #30086, which records the provider model. Closes https://linear.app/codercom/issue/AIGOV-650 ## Changes - Look up the price for the requested model first, then the provider model, preferring a custom price over the price book for each model. - Store the provider model and the model used for pricing (`priced_model`) on each token usage. - Add a `provider_model` label to `unpriced_token_usage_records_total`. - Document the lookup order and the new metric label. > [!NOTE] > Generated by Claude Code on behalf of @ssncferreira.
13 lines
680 B
SQL
13 lines
680 B
SQL
-- Record the model reported by the upstream provider, which may differ from
|
|
-- the requested model when the provider resolves an alias, and the model whose
|
|
-- price was used for the cost.
|
|
ALTER TABLE aibridge_token_usages
|
|
ADD COLUMN provider_model TEXT NULL,
|
|
ADD COLUMN priced_model TEXT NULL;
|
|
|
|
COMMENT ON COLUMN aibridge_token_usages.provider_model IS
|
|
'The model reported by the upstream provider. NULL when the provider did not report one.';
|
|
|
|
COMMENT ON COLUMN aibridge_token_usages.priced_model IS
|
|
'The model whose price was used to compute the cost, either the requested model or the model reported by the provider. NULL when no price was found for either.';
|