使用 Gemini API 进行函数调用
开发中
正式环境
https://generativelanguage.googleapis.com
正式环境
https://generativelanguage.googleapis.com
POST
https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location -g --request POST 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=' \
--header 'Content-Type: application/json' \
--data-raw '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "What'\''s the temperature in London?"
}
]
}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_current_temperature",
"description": "Gets the current temperature for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city name, e.g. San Francisco"
}
},
"required": ["location"]
}
}
]
}
]
}'
响应示例响应示例
{}
请求参数
Query 参数
key
string
必需
示例值:
{{GEMINI_API_KEY}}
Header 参数
Content-Type
string
必需
示例值:
application/json
Body 参数application/json