feat: add OAuth 2.1 support for Claude.ai Connectors#26
Merged
acedatacloud-dev merged 2 commits intomainfrom Mar 20, 2026
Merged
feat: add OAuth 2.1 support for Claude.ai Connectors#26acedatacloud-dev merged 2 commits intomainfrom
acedatacloud-dev merged 2 commits intomainfrom
Conversation
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.
Problem
OpenAI models return
cached_tokensinprompt_tokens_details, but_chat_models.jsonhad no discount terms for cached tokens on any OpenAI model. This caused overcharging when the upstream returned cached tokens:Root Cause
OpenAI's
prompt_tokensincludescached_tokens(unlike Claude whereprompt_tokensexcludes them). So the discount must be applied as a negative offset — subtracting the discount portion of cached tokens from the total.Changes
cost/api/_chat_models.json— 19 model rules modifiedEach rule's consumption formula now includes a third term:
Where
cached_mult = -(prompt_mult * discount_rate), so it subtracts the discounted portion.50% discount (matching OpenAI pricing):
75% discount (matching OpenAI pricing):
Also added
official_price.cached_tokensto each rule for transparency.tests/api_cost/test_claude_cache_tokens.pytest_non_claude_model_unaffected(tested OLD behavior) with two new tests verifying cached_tokens discount IS now appliedTestOpenAICachedTokensclass with 14 test cases covering all discount tiers, edge cases (zero cached, all cached, cached_creation_tokens ignored)Backwards Compatibility
When
cached_tokens = 0(or absent), the new term evaluates to0, so billing for non-cached requests is completely unchanged.