fix(proxy): track spend for OpenAI passthrough /v1/embeddings - #36660
Merged
mateo-berri merged 3 commits intoAug 14, 2026
Conversation
OpenAI passthrough embeddings returned 200 but wrote no spend because the route was unsupported and Cohere's /v1/embed prefix stole the match.
Contributor
Greptile SummaryThe PR adds spend accounting for OpenAI passthrough embedding requests and prevents the Cohere embed matcher from intercepting that route.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/proxy/pass_through_endpoints/llm_provider_handlers/openai_passthrough_logging_handler.py | Adds OpenAI embedding-response normalization and cost calculation to the existing passthrough logging handler. |
| litellm/proxy/pass_through_endpoints/llm_provider_handlers/cohere_passthrough_logging_handler.py | Excludes OpenAI’s plural embeddings route from Cohere’s singular embed handling. |
| litellm/proxy/pass_through_endpoints/success_handler.py | Dispatches supported OpenAI embedding requests correctly while refining Cohere route detection. |
| tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_openai_passthrough_logging_handler.py | Adds coverage for OpenAI passthrough embedding recognition, conversion, and cost propagation. |
| tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_cohere_passthrough_logging_handler.py | Adds regression coverage ensuring OpenAI embeddings do not enter Cohere embed processing. |
Reviews (3): Last reviewed commit: "fix(proxy): drop unreachable embeddings ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Inline embeddings cost tracking to avoid new LIT001/002 hits, trim redundant doc comments, and cover the Cohere /v1/embeddings collision.
Contributor
Author
|
@greptileai please rereview |
convert_to_model_response_object with response_type=embedding already returns EmbeddingResponse; the isinstance check was dead patch coverage.
Contributor
Author
Contributor
Contributor
|
Just tested it. Works on a DB-backed proxy: /openai_passthrough/v1/embeddings now writes a spend log and bills the key exactly (6 tokens, $0.00000012), while before this pr, we bill nothing |
mateo-berri
approved these changes
Aug 14, 2026
mateo-berri
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Thanks for the contribution!
mateo-berri
enabled auto-merge
August 14, 2026 03:48
mateo-berri
merged commit Aug 14, 2026
7a519e2
into
BerriAI:litellm_internal_staging
81 of 82 checks passed
This was referenced Aug 18, 2026
fix(router): honor key-level tag filtering in pre-routing and pin auto-router e2e regressions
#37366
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Problem this solves:
/openai_passthrough/v1/embeddingsHow it solves it:
/v1/embeddingslike other supported OpenAI routes/v1/embedmatching from stealing OpenAI/v1/embeddingsUser Flow
Before: a developer embeds via OpenAI passthrough and their key spend never moves, so budgets are under-enforced
{"model":"text-embedding-3-small","input":"PROOF_SENTINEL_TEXT"}using a virtual keyusage.prompt_tokens: 6info.spendafter flushAfter: the same passthrough embedding increases key spend by the embedding cost
{"model":"text-embedding-3-small","input":"PROOF_SENTINEL_TEXT"}usage.prompt_tokens: 6info.spendincreased by1.2e-7Relevant issues
Fixes #36646
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Proxy:
Before (first live passthrough run on this branch while the proxy was still serving pre-fix behavior; HEAD
f64479e74d)Translated control billed correctly:
Result:
Passthrough returned success but did not bill the key:
Result:
Key spend did not increase until the proxy was restarted onto the fix. Missing
x-litellm-response-coston passthrough is expected on this path and is not the success signal for this bugAfter (commit
1eaca98690acfefe9f0640d5940b6b4a0324b530)Result:
Translated control on the same key/model still works: HTTP 200 with
x-litellm-response-cost: 1.2e-07A second live run on the same fix also showed spend move
2.4e-7->3.6e-7(+1.2e-7)Type
🐛 Bug Fix
✅ Test
Caveats (if any)
/openai/deployments/.../embeddingsis out of scopex-litellm-response-costbecause cost is computed after headers are sent; key spend after flush is the success signal for this bugFinal Attestation