Skip to content

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.

const response: GeminiResponse = {
candidates: [
{
content: {
role: 'model',
parts: [{ text: 'Quantum computing uses quantum mechanics...' }]
},
finishReason: 'STOP'
}
],
usageMetadata: {
promptTokenCount: 15,
candidatesTokenCount: 120,
totalTokenCount: 135
}
};

candidates: object[]

Defined in: adapters/gemini.ts:150

Array of candidate responses (usually just one)

content: GeminiContent

Generated content from the model

finishReason: "STOP" | "MAX_TOKENS" | "SAFETY" | "RECITATION" | "OTHER"

Reason generation stopped: ‘STOP’ (natural), ‘MAX_TOKENS’, ‘SAFETY’, ‘RECITATION’, ‘OTHER’


optional usageMetadata: object

Defined in: adapters/gemini.ts:159

Token usage statistics

candidatesTokenCount: number

Number of tokens in all candidates

promptTokenCount: number

Number of tokens in the prompt

totalTokenCount: number

Total tokens used (prompt + candidates)