GeminiResponse
Defined in: adapters/gemini.ts:148
Google Gemini API response structure.
Contains the response from Gemini including generated content, finish reason, and token usage. Gemini can return multiple candidates (alternative completions) though typically only one is returned. Finish reasons include safety-related stops unique to Gemini.
- GeminiRequest
- GeminiContent
- https://ai.google.dev/api/rest/v1/GenerateContentResponse
Example
Section titled “Example”const response: GeminiResponse = { candidates: [ { content: { role: 'model', parts: [{ text: 'Quantum computing uses quantum mechanics...' }] }, finishReason: 'STOP' } ], usageMetadata: { promptTokenCount: 15, candidatesTokenCount: 120, totalTokenCount: 135 }};Properties
Section titled “Properties”candidates
Section titled “candidates”candidates:
object[]
Defined in: adapters/gemini.ts:150
Array of candidate responses (usually just one)
content
Section titled “content”content:
GeminiContent
Generated content from the model
finishReason
Section titled “finishReason”finishReason:
"STOP"|"MAX_TOKENS"|"SAFETY"|"RECITATION"|"OTHER"
Reason generation stopped: ‘STOP’ (natural), ‘MAX_TOKENS’, ‘SAFETY’, ‘RECITATION’, ‘OTHER’
usageMetadata?
Section titled “usageMetadata?”
optionalusageMetadata:object
Defined in: adapters/gemini.ts:159
Token usage statistics
candidatesTokenCount
Section titled “candidatesTokenCount”candidatesTokenCount:
number
Number of tokens in all candidates
promptTokenCount
Section titled “promptTokenCount”promptTokenCount:
number
Number of tokens in the prompt
totalTokenCount
Section titled “totalTokenCount”totalTokenCount:
number
Total tokens used (prompt + candidates)