Skip to content

Formatted Output

POST https://www.kkiai.com/v1beta/models/gemini-2.5-pro:generateContent

Official Documentation: https://ai.google.dev/gemini-api/docs/structured-output?hl=zh-cn

Request Parameters

Authorization

Add the Authorization parameter to the Header. Its value is the Token concatenated after Bearer.

Example: Authorization: Bearer ********************

Query Parameters

ParameterTypeRequiredDescriptionExample
keystringRequired{{YOUR_API_KEY}}

Header Parameters

ParameterTypeRequiredDescriptionExample
Content-TypestringRequiredapplication/json

Body Parameters (application/json)

ParameterTypeRequiredDescription
contentsarray[object]Required
  └ partsarray[object]Optional
generationConfigobjectRequired
  └ responseModalitiesarray[string]Required

Request Example

json
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "List a few popular cookie recipes, and include the amounts of ingredients."
        }
      ]
    }
  ],
  "generationConfig": {
    "responseMimeType": "application/json",
    "responseSchema": {
      "type": "ARRAY",
      "items": {
        "type": "OBJECT",
        "properties": {
          "recipeName": {
            "type": "STRING"
          },
          "ingredients": {
            "type": "ARRAY",
            "items": {
              "type": "STRING"
            }
          }
        },
        "propertyOrdering": [
          "recipeName",
          "ingredients"
        ]
      }
    }
  }
}

cURL Example

bash
curl --location -g --request POST 'https://www.kkiai.com/v1beta/models/gemini-2.5-pro:generateContent?key=' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "List a few popular cookie recipes, and include the amounts of ingredients."
        }
      ]
    }
  ],
  "generationConfig": {
    "responseMimeType": "application/json",
    "responseSchema": {
      "type": "ARRAY",
      "items": {
        "type": "OBJECT",
        "properties": {
          "recipeName": {
            "type": "STRING"
          },
          "ingredients": {
            "type": "ARRAY",
            "items": {
              "type": "STRING"
            }
          }
        },
        "propertyOrdering": [
          "recipeName",
          "ingredients"
        ]
      }
    }
  }
}'

Response

🟢 200 Success

Response Example

json
{}