fix(aio): match Bedrock pricing by inference profile - #74380
Conversation
|
😎 Merged successfully - details. |
|
@richardsolomou I found this while following the Bedrock pricing path from #71323. The fix keeps the catalog as the source of truth and only uses the raw profile ID when it maps safely to an existing provider row. Would you mind taking a look when you have time? |
|
@greptileai review |
|
Reviews (1): Last reviewed commit: "fix(aio): match Bedrock pricing by infer..." | Re-trigger Greptile |
|
@rafaeelaudibert The PostHog × Tractian meetup in São Paulo was a major catalyst for this contribution. It was great meeting you there, and everyone at MOVEdot is genuinely excited to start contributing back to PostHog. I hope this is the first of many! |
|
@gouveags loved meeting y'all there! We'd love to get your contributions in. I can help routing requests to the right teams if GitHub doesn't do it automatically :) |
|
/trunk merge |
|
An error occurred while submitting your PR to the queue: |
|
Can you guys help with the merge? @richardsolomou or @rafaeelaudibert |
Problem
Bedrock events can use a generic
$ai_providerwhile the raw model contains routing information, such asus.anthropic...or a full inference-profile ARN.After model lookup found the catalog row, provider resolution only used the generic Bedrock provider. It could therefore fall back to the first matching catalog entry instead of the existing regional entry. This can price a US inference profile using Global-equivalent rates.
Closes #74366
This is separate from #71323. That PR corrected Anthropic cache-write pricing after a provider price is selected. This PR corrects the provider selection itself.
Changes
The matcher does not hardcode model names or prices. It only selects among provider rows already present in the catalog.
Note
A profile prefix changes selection only when the matched catalog row contains an exact provider key or one unambiguous regional match. Otherwise, the existing fallback remains unchanged.
How did you test this code?
git diff --checkpassed.I did not run the full PostHog stack or the full monorepo test suite.
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
Automatic notifications
Docs update
No docs update. This corrects provider selection for an existing event shape; it adds no fields, configuration, or workflow.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
I directed the work and used Codex sub-agents and GitHub CLI for research, regression-first tests, implementation, validation, and review. Skills invoked:
development-workflow,create-pr, and the repository's/writing-testsskill. No public agent session link is available.The implementation keeps the existing pricing catalog as the source of truth. It avoids model-specific pricing rules, preserves explicit-provider precedence, and retains the existing fallback when the routing information cannot identify a catalog provider safely.