Google Gemini API
  1. Text generation
Google Gemini API
  • Get API key
  • Release notes
  • Libraries
  • Run Gemini on Google Cloud
  • Model Capabilities
    • Overview
    • Long context
    • Structured output
    • Document understanding
    • Image understanding
    • Video understanding
    • Audio understanding
    • Text generation
      • Text input
        POST
      • Image input
        POST
      • Streaming output
        POST
      • Multi-turn conversations
        POST
      • Multi-turn conversations (Streaming)
        POST
      • Configuration parameters
        POST
    • Generate images
      • Generate images using Gemini
      • Image editing with Gemini
      • Generate images using Imagen 3
    • Gemini thinking
      • Use thinking models
      • Set budget on thinking models
    • Function calling
      • Function Calling with the Gemini API
  • models
    • All Model
    • Pricing
    • Rate limits
    • Billing info
  • Safety
    • Safety settings
    • Safety guidance
  1. Text generation

Image input

POST
https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent
The Gemini API supports multimodal inputs that combine text and media files. The following example shows how to generate text from text and image input
Request Request Example
Shell
JavaScript
Java
Swift
curl --location -g --request POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=' \
--header 'Content-Type: application/json' \
--data-raw '@$TEMP_JSON'
Response Response Example
{}

Request

Query Params
key
string 
required
Example:
{{GEMINI_API_KEY}}
Header Params
Content-Type
string 
required
Example:
application/json
Body Params application/json
contents
array [object {1}] 
required
parts
array [object {2}] 
required
Examples

Responses

🟢200成功
application/json
Body
object {0}
Previous
Text input
Next
Streaming output
Built with