cURL
curl --request POST \
--url https://api.ttapi.io/gemini/chat/completions \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"model": "<string>",
"stream": "false"
}
'import requests
url = "https://api.ttapi.io/gemini/chat/completions"
payload = {
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"model": "<string>",
"stream": "false"
}
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({
messages: [{role: 'user', content: 'Hello!'}],
model: '<string>',
stream: 'false'
})
};
fetch('https://api.ttapi.io/gemini/chat/completions', 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/gemini/chat/completions",
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([
'messages' => [
[
'role' => 'user',
'content' => 'Hello!'
]
],
'model' => '<string>',
'stream' => 'false'
]),
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/gemini/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"model\": \"<string>\",\n \"stream\": \"false\"\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/gemini/chat/completions")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"model\": \"<string>\",\n \"stream\": \"false\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/gemini/chat/completions")
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 \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"model\": \"<string>\",\n \"stream\": \"false\"\n}"
response = http.request(request)
puts response.read_body{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! Nice to chat with you.\n\nHow can I help you? Or what would you like to talk about? ๐",
"role": "assistant"
}
}
],
"created": 1757472417,
"id": "oebAaMTvMfCUjMcP_prYwAs",
"model": "gemini-2.5-pro",
"object": "chat.completion",
"usage": {
"completion_tokens": 21,
"prompt_tokens": 3,
"total_tokens": 1466
}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}Google
Gemini Completions
POST
/
gemini
/
chat
/
completions
cURL
curl --request POST \
--url https://api.ttapi.io/gemini/chat/completions \
--header 'Content-Type: application/json' \
--header 'TT-API-KEY: <api-key>' \
--data '
{
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"model": "<string>",
"stream": "false"
}
'import requests
url = "https://api.ttapi.io/gemini/chat/completions"
payload = {
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"model": "<string>",
"stream": "false"
}
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({
messages: [{role: 'user', content: 'Hello!'}],
model: '<string>',
stream: 'false'
})
};
fetch('https://api.ttapi.io/gemini/chat/completions', 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/gemini/chat/completions",
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([
'messages' => [
[
'role' => 'user',
'content' => 'Hello!'
]
],
'model' => '<string>',
'stream' => 'false'
]),
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/gemini/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"model\": \"<string>\",\n \"stream\": \"false\"\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/gemini/chat/completions")
.header("TT-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"model\": \"<string>\",\n \"stream\": \"false\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ttapi.io/gemini/chat/completions")
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 \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello!\"\n }\n ],\n \"model\": \"<string>\",\n \"stream\": \"false\"\n}"
response = http.request(request)
puts response.read_body{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! Nice to chat with you.\n\nHow can I help you? Or what would you like to talk about? ๐",
"role": "assistant"
}
}
],
"created": 1757472417,
"id": "oebAaMTvMfCUjMcP_prYwAs",
"model": "gemini-2.5-pro",
"object": "chat.completion",
"usage": {
"completion_tokens": 21,
"prompt_tokens": 3,
"total_tokens": 1466
}
}{
"status": "FAILED",
"message": "\"prompt\" cannot be empty.",
"data": {}
}{
"status": "FAILED",
"message": "Wrong TT-API-KEY or email is not activated."
}The request and response fields follow the official Responses API format.
For details, refer to the Google official documentation.
Authorizations
You can obtain your API key from the TTAPI Dashboard.
Body
application/json
Show child attributes
Show child attributes
Example:
[{ "role": "user", "content": "Hello!" }]
Models supported by TTAPI, see Gemini Supported Models
Whether to use server-sent events for progressive response transmission
Response
Successful response (stream=false returns JSON, stream=true returns Gemini stream)
List of response results
Show child attributes
Show child attributes
Response creation timestamp (seconds)
Example:
1757472417
Unique request identifier
Example:
"oebAaMTvMfCUjMcP_prYwAs"
Gemini model version used
Example:
"gemini-2.5-pro"
Response object type
Example:
"chat.completion"
Token usage statistics
Show child attributes
Show child attributes
Last modified on July 15, 2026
โI