Skip to content

fix: price AI usage by configured provider type (#27836) - #28104

Open
ssncferreira wants to merge 1 commit into
release/2.36from
ssncf/2.36-backport-27836
Open

fix: price AI usage by configured provider type (#27836)#28104
ssncferreira wants to merge 1 commit into
release/2.36from
ssncf/2.36-backport-27836

Conversation

@ssncferreira

Copy link
Copy Markdown
Contributor

Backport of #27836

Original PR: #27836 - fix: price AI usage by configured provider type
Merge commit: db88ec3
Requested by: @ssncferreira

## Problem

AI Gateway records the aibridge provider on each interception, which is
the upstream wire format and only ever `anthropic`, `openai`, or
`copilot`. Prices are matched on exact provider and model equality, so a
provider configured as Azure, Bedrock, Google, OpenRouter, or Vercel is
priced as if it were native OpenAI or Anthropic, matching either the
wrong price or no price at all.

## Changes

- Resolve the configured provider type from `ai_providers` by provider
name, which is unique among live providers, and key the price lookup on
it instead of the aibridge provider. No schema change is needed.
- Label `unpriced_token_usage_records_total` with the same provider
value used for the lookup, so it names a provider an operator actually
configured.
- Treat a provider that cannot be resolved as unpriced, consistent with
how a missing price is handled today.

Closes
https://linear.app/codercom/issue/AIGOV-570/resolve-ai-model-prices-using-the-configured-provider-type
Depends on the follow-up that extends the shipped price book to the
remaining provider types:
https://linear.app/codercom/issue/AIGOV-571/ship-prices-for-all-ai-governance-provider-types

> [!NOTE]
> Initially generated by Claude Opus 5, modified and reviewed by
@ssncferreira

(cherry picked from commit db88ec3)
@ssncferreira
ssncferreira marked this pull request as ready for review August 13, 2026 10:39
@ssncferreira
ssncferreira requested a review from a team as a code owner August 13, 2026 10:39
@github-actions

Copy link
Copy Markdown

Docs preview

Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here.

@ssncferreira
ssncferreira requested a review from mtojek August 13, 2026 10:45
@ssncferreira ssncferreira added the backport/v2.36 Backport PR targeting release/2.36 label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/v2.36 Backport PR targeting release/2.36

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant