代码执行

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": "GsBYee3kKi",
      "type": "string",
      "enable": true,
      "sampleValue": "{{YOUR_API_KEY}}"
    }
  ],
  "header": [
    {
      "name": "Content-Type",
      "required": true,
      "description": "",
      "id": "f9z3Ac0sW3",
      "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": {
                  "inline_data": {
                    "type": "object",
                    "properties": {
                      "mime_type": {
                        "type": "string"
                      },
                      "data": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "mime_type",
                      "data"
                    ]
                  },
                  "text": {
                    "type": "string"
                  }
                },
                "required": []
              }
            }
          }
        }
      }
    },
    "required": [
      "contents"
    ]
  },
  "required": false,
  "mediaType": "",
  "examples": [
    {
      "mediaType": "application/json",
      "value": "{\n      \"contents\": [\n          {\n               \"role\": \"user\",\n              \"parts\": [\n                  {\"text\": \"What is the sum of the first 50 prime numbers? Generate and run code for the calculation, and make sure you get all 50.\"}\n              ]\n          }\n      ],\n      \"tools\": [\n          {\n              \"codeExecution\": {}\n          }\n      ]\n  }",
      "name": "示例"
    }
  ],
  "oasExtensions": ""
}

响应

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