fix: add openai-compatible provider support for token usage display #8544
+149
−4
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.
Summary
This PR fixes the issue where token usage displays as 0 when using OpenAI Compatible API providers.
Problem
When users select "OpenAI Compatible" as their API provider and use a custom API endpoint, the token usage counter shows 0 instead of the actual token count.
Solution
Added proper support for the "openai-compatible" provider throughout the codebase:
Changes
Testing
Fixes #8543
Important
Adds support for
openai-compatibleprovider, ensuring correct token usage tracking and behavior similar toopenai.openai-compatibleprovider, ensuring token usage is tracked correctly.openai-compatibletoOpenAiHandlerinbuildApiHandler()inindex.ts.openai-compatibletocustomProvidersandproviderNamesinprovider-settings.ts.providerSettingsSchemaDiscriminatedto includeopenai-compatible.getModelIdFromProfile()inProfileValidator.tsto handleopenai-compatible.getSelectedModel()inuseSelectedModel.tsto supportopenai-compatible.openai-compatible.spec.tsto testOpenAiHandlercreation and token usage tracking foropenai-compatible.This description was created by
for c48c870. You can customize this summary. It will automatically update as commits are pushed.