[FEATURE_REQUEST] Preserve Google usageMetadata in non-streaming Chat Completion responses

Author: XaisspeCreated Sep 17, 2026Updated Sep 17, 2026
Labels🦄 Feature Request

Have you searched for similar requests?

Yes

Is your feature request related to a problem? If so, please describe.

Google's generateContent response includes usageMetadata, which contains provider-reported token usage information.

SillyTavern currently receives the complete Google response in sendMakerSuiteRequest(), but for non-streaming requests the response is wrapped before being returned to the frontend.

As a result, generateResponseJson.usageMetadata is discarded even though it has already been returned by Google and parsed by SillyTavern.

This makes it difficult for frontend extensions to access provider-reported token usage for usage statistics, accounting, diagnostics, or other telemetry-related features.

Describe the solution you'd like

I would like SillyTavern to preserve Google's native usageMetadata field in the non-streaming response returned to the frontend.

For example, the current response is approximately:

javascript
const reply = {
    choices: [{
        message: {
            content: responseText
        }
    }],
    responseContent
};

It could instead preserve the already available metadata:

javascript
const reply = {
    choices: [{
        message: {
            content: responseText
        }
    }],
    responseContent,
    usageMetadata: generateResponseJson.usageMetadata,
};

I would prefer preserving the native Google field rather than converting it into an OpenAI-style usage object, since this avoids changing the semantics of Google's response and allows extensions to interpret provider-specific fields themselves.

This should be backwards-compatible because it only adds an additional response field and does not change the existing choices or responseContent fields.

Describe alternatives you've considered

A frontend extension could estimate token usage locally, but this would be less accurate than using the usage information reported directly by Google.

Another possibility would be intercepting or monkey-patching SillyTavern's request handling, but that would be significantly more fragile and harder to maintain than simply preserving metadata that the backend already receives.

Additional context

This appears to affect the non-streaming Google AI Studio / Vertex AI path in:

src/endpoints/backends/chat-completions.js

The complete Google response is already available as generateResponseJson; usageMetadata is only lost when the response object returned to the frontend is constructed.

Preserving this field could be useful for extensions that implement token usage tracking, cost accounting, diagnostics, or other provider-specific statistics.

No changes to the normal chat UI or message content should be required.

Priority

Low (Nice-to-have)

Are you willing to test this on staging/unstable branch if this is implemented?

Yes