生成 Gemini 内容
curl --request POST \
--url https://api.ttapi.io/v1beta/models/{model}:generateContent \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"contents": [
{
"parts": [
{
"text": "<string>",
"functionCall": {
"name": "<string>",
"args": {}
},
"functionResponse": {
"name": "<string>",
"response": {}
},
"executableCode": {},
"codeExecutionResult": {},
"thought": true,
"thoughtSignature": "<string>"
}
]
}
],
"tools": [
{}
],
"toolConfig": {},
"safetySettings": [
{}
],
"generationConfig": {
"stopSequences": [
"<string>"
],
"responseSchema": {},
"responseJsonSchema": {},
"responseModalities": [],
"candidateCount": 1,
"maxOutputTokens": 2,
"temperature": 1,
"topP": 0.5,
"topK": 2,
"seed": 123,
"presencePenalty": 123,
"frequencyPenalty": 123,
"responseLogprobs": true,
"logprobs": 10,
"enableEnhancedCivicAnswers": true,
"thinkingConfig": {
"includeThoughts": true,
"thinkingBudget": 123
},
"imageConfig": {
"aspectRatio": "<string>"
},
"responseFormat": {}
},
"cachedContent": "cachedContents/abc123",
"store": true
}
'import requests
url = "https://api.ttapi.io/v1beta/models/{model}:generateContent"
payload = {
"contents": [{ "parts": [
{
"text": "<string>",
"functionCall": {
"name": "<string>",
"args": {}
},
"functionResponse": {
"name": "<string>",
"response": {}
},
"executableCode": {},
"codeExecutionResult": {},
"thought": True,
"thoughtSignature": "<string>"
}
] }],
"tools": [{}],
"toolConfig": {},
"safetySettings": [{}],
"generationConfig": {
"stopSequences": ["<string>"],
"responseSchema": {},
"responseJsonSchema": {},
"responseModalities": [],
"candidateCount": 1,
"maxOutputTokens": 2,
"temperature": 1,
"topP": 0.5,
"topK": 2,
"seed": 123,
"presencePenalty": 123,
"frequencyPenalty": 123,
"responseLogprobs": True,
"logprobs": 10,
"enableEnhancedCivicAnswers": True,
"thinkingConfig": {
"includeThoughts": True,
"thinkingBudget": 123
},
"imageConfig": { "aspectRatio": "<string>" },
"responseFormat": {}
},
"cachedContent": "cachedContents/abc123",
"store": True
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
contents: [
{
parts: [
{
text: '<string>',
functionCall: {name: '<string>', args: {}},
functionResponse: {name: '<string>', response: {}},
executableCode: {},
codeExecutionResult: {},
thought: true,
thoughtSignature: '<string>'
}
]
}
],
tools: [{}],
toolConfig: {},
safetySettings: [{}],
generationConfig: {
stopSequences: ['<string>'],
responseSchema: {},
responseJsonSchema: {},
responseModalities: [],
candidateCount: 1,
maxOutputTokens: 2,
temperature: 1,
topP: 0.5,
topK: 2,
seed: 123,
presencePenalty: 123,
frequencyPenalty: 123,
responseLogprobs: true,
logprobs: 10,
enableEnhancedCivicAnswers: true,
thinkingConfig: {includeThoughts: true, thinkingBudget: 123},
imageConfig: {aspectRatio: '<string>'},
responseFormat: {}
},
cachedContent: 'cachedContents/abc123',
store: true
})
};
fetch('https://api.ttapi.io/v1beta/models/{model}:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ttapi.io/v1beta/models/{model}:generateContent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contents' => [
[
'parts' => [
[
'text' => '<string>',
'functionCall' => [
'name' => '<string>',
'args' => [
]
],
'functionResponse' => [
'name' => '<string>',
'response' => [
]
],
'executableCode' => [
],
'codeExecutionResult' => [
],
'thought' => true,
'thoughtSignature' => '<string>'
]
]
]
],
'tools' => [
[
]
],
'toolConfig' => [
],
'safetySettings' => [
[
]
],
'generationConfig' => [
'stopSequences' => [
'<string>'
],
'responseSchema' => [
],
'responseJsonSchema' => [
],
'responseModalities' => [
],
'candidateCount' => 1,
'maxOutputTokens' => 2,
'temperature' => 1,
'topP' => 0.5,
'topK' => 2,
'seed' => 123,
'presencePenalty' => 123,
'frequencyPenalty' => 123,
'responseLogprobs' => true,
'logprobs' => 10,
'enableEnhancedCivicAnswers' => true,
'thinkingConfig' => [
'includeThoughts' => true,
'thinkingBudget' => 123
],
'imageConfig' => [
'aspectRatio' => '<string>'
],
'responseFormat' => [
]
],
'cachedContent' => 'cachedContents/abc123',
'store' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ttapi.io/v1beta/models/{model}:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"functionCall\": {\n \"name\": \"<string>\",\n \"args\": {}\n },\n \"functionResponse\": {\n \"name\": \"<string>\",\n \"response\": {}\n },\n \"executableCode\": {},\n \"codeExecutionResult\": {},\n \"thought\": true,\n \"thoughtSignature\": \"<string>\"\n }\n ]\n }\n ],\n \"tools\": [\n {}\n ],\n \"toolConfig\": {},\n \"safetySettings\": [\n {}\n ],\n \"generationConfig\": {\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {},\n \"responseJsonSchema\": {},\n \"responseModalities\": [],\n \"candidateCount\": 1,\n \"maxOutputTokens\": 2,\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 2,\n \"seed\": 123,\n \"presencePenalty\": 123,\n \"frequencyPenalty\": 123,\n \"responseLogprobs\": true,\n \"logprobs\": 10,\n \"enableEnhancedCivicAnswers\": true,\n \"thinkingConfig\": {\n \"includeThoughts\": true,\n \"thinkingBudget\": 123\n },\n \"imageConfig\": {\n \"aspectRatio\": \"<string>\"\n },\n \"responseFormat\": {}\n },\n \"cachedContent\": \"cachedContents/abc123\",\n \"store\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ttapi.io/v1beta/models/{model}:generateContent")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"functionCall\": {\n \"name\": \"<string>\",\n \"args\": {}\n },\n \"functionResponse\": {\n \"name\": \"<string>\",\n \"response\": {}\n },\n \"executableCode\": {},\n \"codeExecutionResult\": {},\n \"thought\": true,\n \"thoughtSignature\": \"<string>\"\n }\n ]\n }\n ],\n \"tools\": [\n {}\n ],\n \"toolConfig\": {},\n \"safetySettings\": [\n {}\n ],\n \"generationConfig\": {\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {},\n \"responseJsonSchema\": {},\n \"responseModalities\": [],\n \"candidateCount\": 1,\n \"maxOutputTokens\": 2,\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 2,\n \"seed\": 123,\n \"presencePenalty\": 123,\n \"frequencyPenalty\": 123,\n \"responseLogprobs\": true,\n \"logprobs\": 10,\n \"enableEnhancedCivicAnswers\": true,\n \"thinkingConfig\": {\n \"includeThoughts\": true,\n \"thinkingBudget\": 123\n },\n \"imageConfig\": {\n \"aspectRatio\": \"<string>\"\n },\n \"responseFormat\": {}\n },\n \"cachedContent\": \"cachedContents/abc123\",\n \"store\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/v1beta/models/{model}:generateContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"functionCall\": {\n \"name\": \"<string>\",\n \"args\": {}\n },\n \"functionResponse\": {\n \"name\": \"<string>\",\n \"response\": {}\n },\n \"executableCode\": {},\n \"codeExecutionResult\": {},\n \"thought\": true,\n \"thoughtSignature\": \"<string>\"\n }\n ]\n }\n ],\n \"tools\": [\n {}\n ],\n \"toolConfig\": {},\n \"safetySettings\": [\n {}\n ],\n \"generationConfig\": {\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {},\n \"responseJsonSchema\": {},\n \"responseModalities\": [],\n \"candidateCount\": 1,\n \"maxOutputTokens\": 2,\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 2,\n \"seed\": 123,\n \"presencePenalty\": 123,\n \"frequencyPenalty\": 123,\n \"responseLogprobs\": true,\n \"logprobs\": 10,\n \"enableEnhancedCivicAnswers\": true,\n \"thinkingConfig\": {\n \"includeThoughts\": true,\n \"thinkingBudget\": 123\n },\n \"imageConfig\": {\n \"aspectRatio\": \"<string>\"\n },\n \"responseFormat\": {}\n },\n \"cachedContent\": \"cachedContents/abc123\",\n \"store\": true\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{
"content": {
"parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "image/jpeg",
"data": "<string>"
},
"fileData": {
"fileUri": "<string>",
"mimeType": "<string>"
},
"functionCall": {
"name": "<string>",
"args": {}
},
"functionResponse": {
"name": "<string>",
"response": {}
},
"executableCode": {},
"codeExecutionResult": {},
"thought": true,
"thoughtSignature": "<string>"
}
]
},
"finishMessage": "<string>",
"safetyRatings": [
{}
],
"citationMetadata": {},
"groundingMetadata": {},
"avgLogprobs": 123,
"index": 123
}
],
"promptFeedback": {
"blockReason": "<string>",
"safetyRatings": [
{}
]
},
"usageMetadata": {
"promptTokenCount": 123,
"cachedContentTokenCount": 123,
"candidatesTokenCount": 123,
"toolUsePromptTokenCount": 123,
"thoughtsTokenCount": 123,
"totalTokenCount": 123,
"serviceTier": "<string>"
},
"modelVersion": "<string>",
"responseId": "<string>",
"modelStatus": {}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}Google
Gemini Generate Content
使用 Gemini 原生 generateContent REST 请求和响应格式生成模型内容。
POST
/
v1beta
/
models
/
{model}
:generateContent
生成 Gemini 内容
curl --request POST \
--url https://api.ttapi.io/v1beta/models/{model}:generateContent \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"contents": [
{
"parts": [
{
"text": "<string>",
"functionCall": {
"name": "<string>",
"args": {}
},
"functionResponse": {
"name": "<string>",
"response": {}
},
"executableCode": {},
"codeExecutionResult": {},
"thought": true,
"thoughtSignature": "<string>"
}
]
}
],
"tools": [
{}
],
"toolConfig": {},
"safetySettings": [
{}
],
"generationConfig": {
"stopSequences": [
"<string>"
],
"responseSchema": {},
"responseJsonSchema": {},
"responseModalities": [],
"candidateCount": 1,
"maxOutputTokens": 2,
"temperature": 1,
"topP": 0.5,
"topK": 2,
"seed": 123,
"presencePenalty": 123,
"frequencyPenalty": 123,
"responseLogprobs": true,
"logprobs": 10,
"enableEnhancedCivicAnswers": true,
"thinkingConfig": {
"includeThoughts": true,
"thinkingBudget": 123
},
"imageConfig": {
"aspectRatio": "<string>"
},
"responseFormat": {}
},
"cachedContent": "cachedContents/abc123",
"store": true
}
'import requests
url = "https://api.ttapi.io/v1beta/models/{model}:generateContent"
payload = {
"contents": [{ "parts": [
{
"text": "<string>",
"functionCall": {
"name": "<string>",
"args": {}
},
"functionResponse": {
"name": "<string>",
"response": {}
},
"executableCode": {},
"codeExecutionResult": {},
"thought": True,
"thoughtSignature": "<string>"
}
] }],
"tools": [{}],
"toolConfig": {},
"safetySettings": [{}],
"generationConfig": {
"stopSequences": ["<string>"],
"responseSchema": {},
"responseJsonSchema": {},
"responseModalities": [],
"candidateCount": 1,
"maxOutputTokens": 2,
"temperature": 1,
"topP": 0.5,
"topK": 2,
"seed": 123,
"presencePenalty": 123,
"frequencyPenalty": 123,
"responseLogprobs": True,
"logprobs": 10,
"enableEnhancedCivicAnswers": True,
"thinkingConfig": {
"includeThoughts": True,
"thinkingBudget": 123
},
"imageConfig": { "aspectRatio": "<string>" },
"responseFormat": {}
},
"cachedContent": "cachedContents/abc123",
"store": True
}
headers = {
"TT-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'TT-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
contents: [
{
parts: [
{
text: '<string>',
functionCall: {name: '<string>', args: {}},
functionResponse: {name: '<string>', response: {}},
executableCode: {},
codeExecutionResult: {},
thought: true,
thoughtSignature: '<string>'
}
]
}
],
tools: [{}],
toolConfig: {},
safetySettings: [{}],
generationConfig: {
stopSequences: ['<string>'],
responseSchema: {},
responseJsonSchema: {},
responseModalities: [],
candidateCount: 1,
maxOutputTokens: 2,
temperature: 1,
topP: 0.5,
topK: 2,
seed: 123,
presencePenalty: 123,
frequencyPenalty: 123,
responseLogprobs: true,
logprobs: 10,
enableEnhancedCivicAnswers: true,
thinkingConfig: {includeThoughts: true, thinkingBudget: 123},
imageConfig: {aspectRatio: '<string>'},
responseFormat: {}
},
cachedContent: 'cachedContents/abc123',
store: true
})
};
fetch('https://api.ttapi.io/v1beta/models/{model}:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ttapi.io/v1beta/models/{model}:generateContent",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contents' => [
[
'parts' => [
[
'text' => '<string>',
'functionCall' => [
'name' => '<string>',
'args' => [
]
],
'functionResponse' => [
'name' => '<string>',
'response' => [
]
],
'executableCode' => [
],
'codeExecutionResult' => [
],
'thought' => true,
'thoughtSignature' => '<string>'
]
]
]
],
'tools' => [
[
]
],
'toolConfig' => [
],
'safetySettings' => [
[
]
],
'generationConfig' => [
'stopSequences' => [
'<string>'
],
'responseSchema' => [
],
'responseJsonSchema' => [
],
'responseModalities' => [
],
'candidateCount' => 1,
'maxOutputTokens' => 2,
'temperature' => 1,
'topP' => 0.5,
'topK' => 2,
'seed' => 123,
'presencePenalty' => 123,
'frequencyPenalty' => 123,
'responseLogprobs' => true,
'logprobs' => 10,
'enableEnhancedCivicAnswers' => true,
'thinkingConfig' => [
'includeThoughts' => true,
'thinkingBudget' => 123
],
'imageConfig' => [
'aspectRatio' => '<string>'
],
'responseFormat' => [
]
],
'cachedContent' => 'cachedContents/abc123',
'store' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"TT-API-KEY: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ttapi.io/v1beta/models/{model}:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"functionCall\": {\n \"name\": \"<string>\",\n \"args\": {}\n },\n \"functionResponse\": {\n \"name\": \"<string>\",\n \"response\": {}\n },\n \"executableCode\": {},\n \"codeExecutionResult\": {},\n \"thought\": true,\n \"thoughtSignature\": \"<string>\"\n }\n ]\n }\n ],\n \"tools\": [\n {}\n ],\n \"toolConfig\": {},\n \"safetySettings\": [\n {}\n ],\n \"generationConfig\": {\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {},\n \"responseJsonSchema\": {},\n \"responseModalities\": [],\n \"candidateCount\": 1,\n \"maxOutputTokens\": 2,\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 2,\n \"seed\": 123,\n \"presencePenalty\": 123,\n \"frequencyPenalty\": 123,\n \"responseLogprobs\": true,\n \"logprobs\": 10,\n \"enableEnhancedCivicAnswers\": true,\n \"thinkingConfig\": {\n \"includeThoughts\": true,\n \"thinkingBudget\": 123\n },\n \"imageConfig\": {\n \"aspectRatio\": \"<string>\"\n },\n \"responseFormat\": {}\n },\n \"cachedContent\": \"cachedContents/abc123\",\n \"store\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("TT-API-KEY", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ttapi.io/v1beta/models/{model}:generateContent")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"functionCall\": {\n \"name\": \"<string>\",\n \"args\": {}\n },\n \"functionResponse\": {\n \"name\": \"<string>\",\n \"response\": {}\n },\n \"executableCode\": {},\n \"codeExecutionResult\": {},\n \"thought\": true,\n \"thoughtSignature\": \"<string>\"\n }\n ]\n }\n ],\n \"tools\": [\n {}\n ],\n \"toolConfig\": {},\n \"safetySettings\": [\n {}\n ],\n \"generationConfig\": {\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {},\n \"responseJsonSchema\": {},\n \"responseModalities\": [],\n \"candidateCount\": 1,\n \"maxOutputTokens\": 2,\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 2,\n \"seed\": 123,\n \"presencePenalty\": 123,\n \"frequencyPenalty\": 123,\n \"responseLogprobs\": true,\n \"logprobs\": 10,\n \"enableEnhancedCivicAnswers\": true,\n \"thinkingConfig\": {\n \"includeThoughts\": true,\n \"thinkingBudget\": 123\n },\n \"imageConfig\": {\n \"aspectRatio\": \"<string>\"\n },\n \"responseFormat\": {}\n },\n \"cachedContent\": \"cachedContents/abc123\",\n \"store\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/v1beta/models/{model}:generateContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["TT-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"functionCall\": {\n \"name\": \"<string>\",\n \"args\": {}\n },\n \"functionResponse\": {\n \"name\": \"<string>\",\n \"response\": {}\n },\n \"executableCode\": {},\n \"codeExecutionResult\": {},\n \"thought\": true,\n \"thoughtSignature\": \"<string>\"\n }\n ]\n }\n ],\n \"tools\": [\n {}\n ],\n \"toolConfig\": {},\n \"safetySettings\": [\n {}\n ],\n \"generationConfig\": {\n \"stopSequences\": [\n \"<string>\"\n ],\n \"responseSchema\": {},\n \"responseJsonSchema\": {},\n \"responseModalities\": [],\n \"candidateCount\": 1,\n \"maxOutputTokens\": 2,\n \"temperature\": 1,\n \"topP\": 0.5,\n \"topK\": 2,\n \"seed\": 123,\n \"presencePenalty\": 123,\n \"frequencyPenalty\": 123,\n \"responseLogprobs\": true,\n \"logprobs\": 10,\n \"enableEnhancedCivicAnswers\": true,\n \"thinkingConfig\": {\n \"includeThoughts\": true,\n \"thinkingBudget\": 123\n },\n \"imageConfig\": {\n \"aspectRatio\": \"<string>\"\n },\n \"responseFormat\": {}\n },\n \"cachedContent\": \"cachedContents/abc123\",\n \"store\": true\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{
"content": {
"parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "image/jpeg",
"data": "<string>"
},
"fileData": {
"fileUri": "<string>",
"mimeType": "<string>"
},
"functionCall": {
"name": "<string>",
"args": {}
},
"functionResponse": {
"name": "<string>",
"response": {}
},
"executableCode": {},
"codeExecutionResult": {},
"thought": true,
"thoughtSignature": "<string>"
}
]
},
"finishMessage": "<string>",
"safetyRatings": [
{}
],
"citationMetadata": {},
"groundingMetadata": {},
"avgLogprobs": 123,
"index": 123
}
],
"promptFeedback": {
"blockReason": "<string>",
"safetyRatings": [
{}
]
},
"usageMetadata": {
"promptTokenCount": 123,
"cachedContentTokenCount": 123,
"candidatesTokenCount": 123,
"toolUsePromptTokenCount": 123,
"thoughtsTokenCount": 123,
"totalTokenCount": 123,
"serviceTier": "<string>"
},
"modelVersion": "<string>",
"responseId": "<string>",
"modelStatus": {}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}请求参数和响应字段与 Gemini 官方格式保持一致。完整规范请参考
Google 官方文档。
contents 传入文本或多模态对话内容。接口同时支持系统指令、工具调用、安全设置、
缓存内容、结构化输出、思考配置以及模型支持的其他生成参数。路径参数
Gemini 模型 ID。
示例:
"gemini-3.5-flash"
请求体
application/json
Gemini generateContent 原生 REST 格式请求体。
当前对话内容;多轮请求需要包含完整对话历史。
Minimum array length:
1Show child attributes
Show child attributes
模型可以使用的函数、代码执行或受支持的内置工具。
本次请求中工具共用的配置。
按安全类别设置内容拦截阈值。
Show child attributes
Show child attributes
Show child attributes
Show child attributes
生成与输出配置;具体可用字段取决于模型。
Show child attributes
Show child attributes
用作上下文的缓存内容资源,格式为 cachedContents/{cachedContent}。
示例:
"cachedContents/abc123"
本次请求使用的服务层级。
可用选项:
unspecified, standard, flex, priority 覆盖项目级请求日志配置。
最后修改于 2026年7月15日
⌘I