Skip to main content
POST
/
v1beta
/
models
/
{model}
:generateContent
curl --request POST \
  --url https://api.getinfinityblue.com/v1beta/models/{model}:generateContent \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Hi, introduce Gemini in one sentence."
        }
      ]
    }
  ]
}
'
{
  "candidates": [
    {
      "content": {
        "role": "<string>",
        "parts": [
          {
            "text": "<string>"
          }
        ]
      },
      "finishReason": "<string>",
      "safetyRatings": [
        {
          "category": "<string>",
          "probability": "<string>"
        }
      ]
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 123,
    "candidatesTokenCount": 123,
    "totalTokenCount": 123
  }
}

Models you can use

Model IDNotes
gemini-3.1-pro-previewGemini flagship — strong multimodal, very long context
gemini-2.5-proHigh-performance multimodal, up to 1M token context
gemini-2.5-flashFast, lightweight — optimized for high-volume workloads
See GET /v1/models for the full list.

Multi-turn conversations

Alternate role: user and role: model entries in the contents array to build a multi-turn conversation.

Media recognition

Add an inlineData entry in parts with a mimeType (e.g. image/jpeg, application/pdf, audio/mpeg, video/mp4) and the base64-encoded file data.

Streaming

Replace :generateContent in the path with :streamGenerateContent?alt=sse to switch to SSE streaming mode.

Safety filtering

Use safetySettings to adjust the blocking threshold for each harm category.

System instructions

Pass a system-level prompt via systemInstruction, using the same parts format as contents.

Authorizations

Authorization
string
header
required

Bearer token authentication, format: Authorization: Bearer sk-xxxxxx. Get your API key in the console.

Path Parameters

model
string
required

Model name, e.g. gemini-2.5-pro or gemini-2.5-flash.

Example:

"gemini-2.5-pro"

Body

application/json

Gemini generateContent request body, used for both text chat and media recognition.

contents
object[]

Conversation contents in chronological order. Each element has a role (user or model) and a parts array of content fragments.

generationConfig
object

Generation parameter configuration.

safetySettings
object[]

Safety filter settings to adjust blocking thresholds per harm category.

tools
object[]

Tool list for function calling.

systemInstruction
object

System-level instruction in the same format as a contents element.

Response

Successful response

Gemini generateContent response body.

candidates
object[]

List of candidate responses generated by the model.

usageMetadata
object

Token usage statistics.