Gemini 文本聊天
curl --request POST \
--url https://zero.cat/v1beta/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "<string>",
"data": "<string>"
}
}
]
}
],
"generationConfig": {
"temperature": 123,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": [
"<string>"
]
},
"safetySettings": [
{
"category": "<string>",
"threshold": "<string>"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
}
'import requests
url = "https://zero.cat/v1beta/models/{model}:generateContent"
payload = {
"contents": [{ "parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "<string>",
"data": "<string>"
}
}
] }],
"generationConfig": {
"temperature": 123,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": ["<string>"]
},
"safetySettings": [
{
"category": "<string>",
"threshold": "<string>"
}
],
"tools": [{}],
"systemInstruction": { "parts": [{}] }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
contents: [
{
parts: [{text: '<string>', inlineData: {mimeType: '<string>', data: '<string>'}}]
}
],
generationConfig: {
temperature: 123,
topP: 123,
topK: 123,
maxOutputTokens: 123,
stopSequences: ['<string>']
},
safetySettings: [{category: '<string>', threshold: '<string>'}],
tools: [{}],
systemInstruction: {parts: [{}]}
})
};
fetch('https://zero.cat/v1beta/models/{model}:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"candidates": [
{
"content": {
"role": "<string>",
"parts": [
{}
]
},
"finishReason": "<string>",
"safetyRatings": [
{}
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123
}
}聊天
Gemini 文本聊天
代理 Gemini API 请求。
路径格式: /v1beta/models/{model_name}:{action}
例如:
/v1beta/models/gemini-2.5-pro:generateContent/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse
POST
/
v1beta
/
models
/
{model}
:generateContent
Gemini 文本聊天
curl --request POST \
--url https://zero.cat/v1beta/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "<string>",
"data": "<string>"
}
}
]
}
],
"generationConfig": {
"temperature": 123,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": [
"<string>"
]
},
"safetySettings": [
{
"category": "<string>",
"threshold": "<string>"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
}
'import requests
url = "https://zero.cat/v1beta/models/{model}:generateContent"
payload = {
"contents": [{ "parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "<string>",
"data": "<string>"
}
}
] }],
"generationConfig": {
"temperature": 123,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": ["<string>"]
},
"safetySettings": [
{
"category": "<string>",
"threshold": "<string>"
}
],
"tools": [{}],
"systemInstruction": { "parts": [{}] }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
contents: [
{
parts: [{text: '<string>', inlineData: {mimeType: '<string>', data: '<string>'}}]
}
],
generationConfig: {
temperature: 123,
topP: 123,
topK: 123,
maxOutputTokens: 123,
stopSequences: ['<string>']
},
safetySettings: [{category: '<string>', threshold: '<string>'}],
tools: [{}],
systemInstruction: {parts: [{}]}
})
};
fetch('https://zero.cat/v1beta/models/{model}:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"candidates": [
{
"content": {
"role": "<string>",
"parts": [
{}
]
},
"finishReason": "<string>",
"safetyRatings": [
{}
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123
}
}授权
ZeroCat API 密钥(sk- 开头),在控制台「API 密钥」页面创建。
格式:Authorization: Bearer sk-xxxxxx
路径参数
模型名称
请求体
application/json

