Skip to main content
Gemini puts turns in contents[].parts[] and authenticates with x-goog-api-key. Choose the path model ID from the live model page.

Text generation

For multi-turn conversations, append ordered contents entries with user and model roles. Use top-level systemInstruction for system guidance and generationConfig for temperature, stops, output limits, and structured output.

Response shape

Read text from candidates[0].content.parts[]. If safety filters block a request, inspect promptFeedback and candidate safety ratings.