curl --request POST \
--url https://api.tikway.ai/v1beta/models/{model}:streamGenerateContent \
--header 'Content-Type: application/json' \
--header 'x-goog-api-key: <api-key>' \
--data '
{
"systemInstruction": {
"parts": [
{
"text": "You are a helpful assistant."
}
]
},
"contents": [
{
"role": "user",
"parts": [
{
"text": "Write a short bedtime story about a unicorn."
}
]
}
],
"generationConfig": {
"maxOutputTokens": 1024
}
}
'import requests
url = "https://api.tikway.ai/v1beta/models/{model}:streamGenerateContent"
payload = {
"systemInstruction": { "parts": [{ "text": "You are a helpful assistant." }] },
"contents": [
{
"role": "user",
"parts": [{ "text": "Write a short bedtime story about a unicorn." }]
}
],
"generationConfig": { "maxOutputTokens": 1024 }
}
headers = {
"x-goog-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-goog-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
systemInstruction: {parts: [{text: 'You are a helpful assistant.'}]},
contents: [
{role: 'user', parts: [{text: 'Write a short bedtime story about a unicorn.'}]}
],
generationConfig: {maxOutputTokens: 1024}
})
};
fetch('https://api.tikway.ai/v1beta/models/{model}:streamGenerateContent', 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.tikway.ai/v1beta/models/{model}:streamGenerateContent",
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([
'systemInstruction' => [
'parts' => [
[
'text' => 'You are a helpful assistant.'
]
]
],
'contents' => [
[
'role' => 'user',
'parts' => [
[
'text' => 'Write a short bedtime story about a unicorn.'
]
]
]
],
'generationConfig' => [
'maxOutputTokens' => 1024
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-goog-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.tikway.ai/v1beta/models/{model}:streamGenerateContent"
payload := strings.NewReader("{\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"You are a helpful assistant.\"\n }\n ]\n },\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Write a short bedtime story about a unicorn.\"\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"maxOutputTokens\": 1024\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-goog-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.tikway.ai/v1beta/models/{model}:streamGenerateContent")
.header("x-goog-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"You are a helpful assistant.\"\n }\n ]\n },\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Write a short bedtime story about a unicorn.\"\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"maxOutputTokens\": 1024\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/v1beta/models/{model}:streamGenerateContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-goog-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"You are a helpful assistant.\"\n }\n ]\n },\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Write a short bedtime story about a unicorn.\"\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"maxOutputTokens\": 1024\n }\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{
"index": 0,
"content": {
"role": "model",
"parts": [
{
"text": "Once upon a time, a magic backpack..."
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 10,
"candidatesTokenCount": 12,
"totalTokenCount": 22
},
"modelVersion": "gemini-2.0-flash"
}Stream Generate Content
curl --request POST \
--url https://api.tikway.ai/v1beta/models/{model}:streamGenerateContent \
--header 'Content-Type: application/json' \
--header 'x-goog-api-key: <api-key>' \
--data '
{
"systemInstruction": {
"parts": [
{
"text": "You are a helpful assistant."
}
]
},
"contents": [
{
"role": "user",
"parts": [
{
"text": "Write a short bedtime story about a unicorn."
}
]
}
],
"generationConfig": {
"maxOutputTokens": 1024
}
}
'import requests
url = "https://api.tikway.ai/v1beta/models/{model}:streamGenerateContent"
payload = {
"systemInstruction": { "parts": [{ "text": "You are a helpful assistant." }] },
"contents": [
{
"role": "user",
"parts": [{ "text": "Write a short bedtime story about a unicorn." }]
}
],
"generationConfig": { "maxOutputTokens": 1024 }
}
headers = {
"x-goog-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-goog-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
systemInstruction: {parts: [{text: 'You are a helpful assistant.'}]},
contents: [
{role: 'user', parts: [{text: 'Write a short bedtime story about a unicorn.'}]}
],
generationConfig: {maxOutputTokens: 1024}
})
};
fetch('https://api.tikway.ai/v1beta/models/{model}:streamGenerateContent', 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.tikway.ai/v1beta/models/{model}:streamGenerateContent",
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([
'systemInstruction' => [
'parts' => [
[
'text' => 'You are a helpful assistant.'
]
]
],
'contents' => [
[
'role' => 'user',
'parts' => [
[
'text' => 'Write a short bedtime story about a unicorn.'
]
]
]
],
'generationConfig' => [
'maxOutputTokens' => 1024
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-goog-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.tikway.ai/v1beta/models/{model}:streamGenerateContent"
payload := strings.NewReader("{\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"You are a helpful assistant.\"\n }\n ]\n },\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Write a short bedtime story about a unicorn.\"\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"maxOutputTokens\": 1024\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-goog-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.tikway.ai/v1beta/models/{model}:streamGenerateContent")
.header("x-goog-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"You are a helpful assistant.\"\n }\n ]\n },\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Write a short bedtime story about a unicorn.\"\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"maxOutputTokens\": 1024\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tikway.ai/v1beta/models/{model}:streamGenerateContent")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-goog-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"systemInstruction\": {\n \"parts\": [\n {\n \"text\": \"You are a helpful assistant.\"\n }\n ]\n },\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Write a short bedtime story about a unicorn.\"\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"maxOutputTokens\": 1024\n }\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{
"index": 0,
"content": {
"role": "model",
"parts": [
{
"text": "Once upon a time, a magic backpack..."
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 10,
"candidatesTokenCount": 12,
"totalTokenCount": 22
},
"modelVersion": "gemini-2.0-flash"
}Authorizations
Tikway API Key. Passed through the x-goog-api-key request header according to the Gemini native protocol.
Path Parameters
Model name, in the format models/{model}.
Body
Current conversation content. A single-round request usually has only one Content; multi-round conversations include historical and latest requests in order.
1Hide child attributes
Hide child attributes
List of content sections.
1Hide child attributes
Hide child attributes
Text input.
Does this part belong to model thinking content?
Think content signatures; keep them as is on postback.
Custom metadata associated with the content block.
How video content is processed.
Audio transcription information.
Speech synthesis related metadata.
Server-side tool calls that need to be returned by the client.
The execution result of the server tool call.
Video content metadata.
Content roles. When omitted, it is usually treated as user.
user, model A list of tools that the model can use, such as function calls or code execution.
Hide child attributes
Hide child attributes
List of function declarations.
Hide child attributes
Hide child attributes
function name.
Description of function usage.
Function parameters JSON Schema.
Function responds to JSON Schema.
UNSPECIFIED, BLOCKING, NON_BLOCKING JSON Schema of function parameters; mutually exclusive with parameters .
JSON Schema of the function response; mutually exclusive with response .
Enable code execution tools.
Enable Google search tools.
Enable the URL context tool.
Google Search retrieves the configuration.
Computer operating tool configuration.
File search tool configuration.
Connectable MCP server.
Geolocation search tool configuration.
Tool call configuration.
Hide child attributes
Hide child attributes
Security filtering rules; the same category can be configured at most once, overriding the default threshold for that category.
Hide child attributes
Hide child attributes
Security Category.
HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_CIVIC_INTEGRITY, HARM_CATEGORY_JAILBREAK Blocking threshold.
HARM_BLOCK_THRESHOLD_UNSPECIFIED, BLOCK_LOW_AND_ABOVE, BLOCK_MEDIUM_AND_ABOVE, BLOCK_ONLY_HIGH, BLOCK_NONE, OFF Generate and output configurations.
Hide child attributes
Hide child attributes
Sampling temperature.
0 <= x <= 2Kernel sampling threshold.
The number of highest probability candidates retained at each step.
Returns the number of candidate replies.
x >= 1The maximum number of output tokens.
Stop the sequence.
5Output MIME type.
text/plain, application/json, text/x.enum The JSON Schema that application/json output should follow.
The raw JSON Schema of the JSON output.
The requested output modal.
MODALITY_UNSPECIFIED, TEXT, IMAGE, AUDIO Hide child attributes
Hide child attributes
Think about token budgeting.
Whether to include a reflection summary in the response.
Model thinking depth.
THINKING_LEVEL_UNSPECIFIED, MINIMAL, LOW, MEDIUM, HIGH Media input resolution settings.
MEDIA_RESOLUTION_UNSPECIFIED, MEDIA_RESOLUTION_LOW, MEDIA_RESOLUTION_MEDIUM, MEDIA_RESOLUTION_HIGH Decode the random seed.
Existence penalty for existing tokens.
Frequency penalty for existing tokens.
Whether to return the token log probability in the response.
The number of high-probability candidate tokens returned; only valid when responseLogprobs is true.
0 <= x <= 20Enable enhanced citizen question answering.
Speech generation configuration.
Adjust responses based on detected emotions.
Configure text, audio and image output formats separately.
Hide child attributes
Hide child attributes
Hide child attributes
Hide child attributes
Audio transcription configuration.
Hide child attributes
Hide child attributes
Language tips.
Voice adaptation prompt phrase.
Custom terms.
VERBATIM, SMART Deprecated; use languageCodes.
The cached content name to use as context, in the format cachedContents/{cachedContent}.
Request service level.
unspecified, standard, flex, priority Whether to log this request; if set, it will override the project-level log configuration.
Response
Gemini API: models.generateContent normal response. Fully inline and suitable for importing into Apifox.
A list of candidate responses generated by the model.
Hide child attributes
Hide child attributes
Candidate reply index.
Candidate reply content.
Hide child attributes
Hide child attributes
Role, fixed as model.
model Reply content part.
Hide child attributes
Hide child attributes
Generated text.
Whether it is the content of thinking.
Think about signing.
Custom metadata associated with the content block.
How video content is processed.
Audio transcription information.
Speech synthesis related metadata.
Server-side tool calls that need to be returned by the client.
The execution result of the server tool call.
Video content metadata.
The ending reason for the candidate reply.
A description of the reason for ending.
Reference metadata.
Number of candidate reply tokens.
Average log probability of candidate responses.
Term log probability results.
URL context metadata.
Word usage statistics.
Hide child attributes
Hide child attributes
Prompt word number.
Number of candidate reply tokens.
The total number of tokens.
The number of cached content tokens.
Think about word count.
Tool usage hint word token number.
The actual model version used.
Response unique ID.

