POST
/
v1beta
/
models
/
{model}
:generateContent
curl -X POST "https://api.example.com/v1beta/models/gemini-2.5-flash:generateContent?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "Summarize this document"
          },
          {
            "inline_data": {
              "mime_type": "application/pdf",
              "data": "BASE64_ENCODED_PDF_DATA"
            }
          }
        ]
      }
    ]
  }'
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "This document discusses the quarterly financial results, showing a 15% increase in revenue compared to the previous quarter..."
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ]
}
Official documentation: https://ai.google.dev/gemini-api/docs/document-processing
Process and extract information from various document formats including PDFs, Word documents, and other text-based files using Google Gemini models.

Request Parameters

key
string
required
API key.
contents
array
required
Content array containing document data.Each content object contains:
  • role (string): Role (user or model)
  • parts (array): Content parts array, can include:
    • text (string): Text prompt or question about the document
    • inline_data (object): Document data
      • mime_type (string): Document MIME type (e.g., “application/pdf”)
      • data (string): Base64-encoded document data
generationConfig
object
Generation configuration.
  • temperature (number): Sampling temperature
  • topP (number): Nucleus sampling parameter
  • maxOutputTokens (integer): Maximum output tokens

Response

Returns extracted information and analysis from the document.
curl -X POST "https://api.example.com/v1beta/models/gemini-2.5-flash:generateContent?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "Summarize this document"
          },
          {
            "inline_data": {
              "mime_type": "application/pdf",
              "data": "BASE64_ENCODED_PDF_DATA"
            }
          }
        ]
      }
    ]
  }'
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "This document discusses the quarterly financial results, showing a 15% increase in revenue compared to the previous quarter..."
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP"
    }
  ]
}