Read Gemini usage metadata correctly
This commit is contained in:
@@ -147,7 +147,9 @@ class AiService
|
||||
|
||||
private function getUsage(array $body, string $provider, string $model): ?array
|
||||
{
|
||||
$usage = $body['usage'] ?? null;
|
||||
// Gemini uses camelCase UsageMetadata at the response root; the
|
||||
// OpenAI-compatible providers return their counters in `usage`.
|
||||
$usage = $body['usageMetadata'] ?? $body['usage'] ?? null;
|
||||
if (!is_array($usage)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user