curl --request POST \
--url 'https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
"你好,请介绍一下你自己"
],
"generationConfig": {
"temperature": 1
},
"safetySettings": [
{
"category": "category",
"threshold": "threshold"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
}'
import requests
url = "https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"contents": [
"你好,请介绍一下你自己"
],
"generationConfig": {
"temperature": 1
},
"safetySettings": [
{
"category": "category",
"threshold": "threshold"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"contents": [
"你好,请介绍一下你自己"
],
"generationConfig": {
"temperature": 1
},
"safetySettings": [
{
"category": "category",
"threshold": "threshold"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"candidates": [
{
"content": "你好,请介绍一下你自己",
"finishReason": "finishReason",
"safetyRatings": [
{}
]
}
],
"usageMetadata": {
"promptTokenCount": 1,
"candidatesTokenCount": 1,
"totalTokenCount": 1
}
}
原生 Gemini 格式
Gemini 文本聊天
- 代理 Gemini API 请求。
- 路径格式:
/v1beta/models/{model_name}:{action} - 例如:
/v1beta/models/gemini-2.5-pro:generateContent
POST
/
v1beta
/
models
/
{model}
:generateContent
curl --request POST \
--url 'https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
"你好,请介绍一下你自己"
],
"generationConfig": {
"temperature": 1
},
"safetySettings": [
{
"category": "category",
"threshold": "threshold"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
}'
import requests
url = "https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"contents": [
"你好,请介绍一下你自己"
],
"generationConfig": {
"temperature": 1
},
"safetySettings": [
{
"category": "category",
"threshold": "threshold"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"contents": [
"你好,请介绍一下你自己"
],
"generationConfig": {
"temperature": 1
},
"safetySettings": [
{
"category": "category",
"threshold": "threshold"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"candidates": [
{
"content": "你好,请介绍一下你自己",
"finishReason": "finishReason",
"safetyRatings": [
{}
]
}
],
"usageMetadata": {
"promptTokenCount": 1,
"candidatesTokenCount": 1,
"totalTokenCount": 1
}
}
curl --request POST \
--url 'https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
"你好,请介绍一下你自己"
],
"generationConfig": {
"temperature": 1
},
"safetySettings": [
{
"category": "category",
"threshold": "threshold"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
}'
import requests
url = "https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent"
headers = {
"Authorization": "Bearer <token>"
}
headers["Content-Type"] = "application/json"
payload = {
"contents": [
"你好,请介绍一下你自己"
],
"generationConfig": {
"temperature": 1
},
"safetySettings": [
{
"category": "category",
"threshold": "threshold"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.json())
const url = "https://api.elkapi.com/v1beta/models/gemini-3.1-pro-preview:generateContent";
const headers = {
"Authorization": "Bearer <token>"
};
headers["Content-Type"] = "application/json";
const payload = {
"contents": [
"你好,请介绍一下你自己"
],
"generationConfig": {
"temperature": 1
},
"safetySettings": [
{
"category": "category",
"threshold": "threshold"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
};
const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify(payload)
});
console.log(await response.json());
{
"candidates": [
{
"content": "你好,请介绍一下你自己",
"finishReason": "finishReason",
"safetyRatings": [
{}
]
}
],
"usageMetadata": {
"promptTokenCount": 1,
"candidatesTokenCount": 1,
"totalTokenCount": 1
}
}
Authorizations
string
必填
所有接口均需要使用 Bearer Token 进行认证。在请求头中添加:
Authorization: Bearer YOUR_API_KEY
Path Parameters
string
默认值:"gemini-3.1-pro-preview"
必填
模型名称示例:
gemini-3.1-pro-previewBody
array<object>
Response
⌘I