格式化输出

POST /v1beta/models/gemini-2.5-pro:generateContent

MethodPOST
Path/v1beta/models/gemini-2.5-pro:generateContent
Typehttp
Status1
Module2102810
Folder61214320

说明

概览

MethodPOST
Path/v1beta/models/gemini-2.5-pro:generateContent
Typehttp
Status1
Module2102810
Folder61214320

参数

{
  "query": [
    {
      "name": "key",
      "required": true,
      "description": "",
      "id": "fNkAG1L7Ct",
      "type": "string",
      "enable": true,
      "sampleValue": "{{YOUR_API_KEY}}"
    }
  ],
  "header": [
    {
      "name": "Content-Type",
      "required": true,
      "description": "",
      "id": "DxzZ9GHHTb",
      "type": "string",
      "enable": true,
      "sampleValue": "application/json"
    }
  ]
}

请求体

{
  "type": "application/json",
  "parameters": [],
  "jsonSchema": {
    "type": "object",
    "properties": {
      "contents": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "parts": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "inline_data": {
                    "type": "object",
                    "properties": {
                      "mime_type": {
                        "type": "string"
                      },
                      "data": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "mime_type",
                      "data"
                    ]
                  }
                },
                "required": []
              }
            }
          }
        }
      },
      "generationConfig": {
        "type": "object",
        "properties": {
          "responseModalities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "responseModalities"
        ]
      }
    },
    "required": [
      "contents",
      "generationConfig"
    ]
  },
  "required": false,
  "mediaType": "",
  "examples": [
    {
      "mediaType": "application/json",
      "value": "{\n  \"contents\": [\n    {\n      \"role\": \"user\",\n      \"parts\": [\n        {\n          \"text\": \"List a few popular cookie recipes, and include the amounts of ingredients.\"\n        }\n      ]\n    }\n  ],\n  \"generationConfig\": {\n    \"responseMimeType\": \"application/json\",\n    \"responseSchema\": {\n      \"type\": \"ARRAY\",\n      \"items\": {\n        \"type\": \"OBJECT\",\n        \"properties\": {\n          \"recipeName\": {\n            \"type\": \"STRING\"\n          },\n          \"ingredients\": {\n            \"type\": \"ARRAY\",\n            \"items\": {\n              \"type\": \"STRING\"\n            }\n          }\n        },\n        \"propertyOrdering\": [\n          \"recipeName\",\n          \"ingredients\"\n        ]\n      }\n    }\n  }\n}",
      "name": "示例"
    }
  ],
  "oasExtensions": ""
}

响应

[
  {
    "id": 698884219,
    "name": "成功",
    "code": 200,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {}
    },
    "itemSchema": {},
    "description": "",
    "mediaType": "",
    "headers": [],
    "oasExtensions": ""
  }
]