Gemini API Request Builder

Build Google Gemini API request payloads and cURL commands.

JSON Request Body
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Hello!"
        }
      ]
    }
  ],
  "generationConfig": {
    "temperature": 0.7,
    "maxOutputTokens": 1024
  },
  "system_instruction": {
    "parts": [
      {
        "text": "You are a helpful assistant."
      }
    ]
  }
}
cURL Command
curl -X POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:generateContent?key=$GOOGLE_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Hello!"
        }
      ]
    }
  ],
  "generationConfig": {
    "temperature": 0.7,
    "maxOutputTokens": 1024
  },
  "system_instruction": {
    "parts": [
      {
        "text": "You are a helpful assistant."
      }
    ]
  }
}'
Endpointhttps://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:generateContent?key=$GOOGLE_API_KEY

Related Tools

Learn More

FAQ

What is different about Gemini's API format?
Gemini uses a contents array with parts sub-arrays, and maps the assistant role to 'model'. The API key goes in the URL as a query parameter rather than a header.
How is the system prompt sent to Gemini?
Gemini uses a system_instruction field with a parts array containing text objects, separate from the contents array.
Does Gemini use Bearer token authentication?
The basic Gemini API uses an API key as a URL query parameter (?key=YOUR_KEY). No Authorization header is needed for this approach.

Generate ready-to-use JSON request bodies and cURL commands for the Google Gemini generateContent API. Handles system_instruction, contents array with parts, generationConfig, and the API key URL parameter format.