curl --request POST \
--url https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, please introduce yourself"
}
]
}
]
}'
import requests
url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent"
payload = {
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, please introduce yourself"
}
]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent";
const payload = {
contents: [
{
role: "user",
parts: [
{
text: "Hello, please introduce yourself"
}
]
}
]
};
const headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent"
payload := map[string]interface{}{
"contents": []map[string]interface{}{
{
"role": "user",
"parts": []map[string]interface{}{
{
"text": "Hello, please introduce yourself",
},
},
},
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent";
String payload = """
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, please introduce yourself"
}
]
}
]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent";
$payload = [
"contents" => [
[
"role" => "user",
"parts" => [
[
"text" => "Hello, please introduce yourself"
]
]
]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent")
payload = {
contents: [
{
role: "user",
parts: [
{
text: "Hello, please introduce yourself"
}
]
}
]
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
{
"code": 200,
"data": {
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "Hello! I'm pleased to introduce myself.\n\nI am a large language model, trained and developed by Google..."
}
]
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
}
]
}
],
"promptFeedback": {
"safetyRatings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
}
]
]
},
"usageMetadata": {
"promptTokenCount": 4,
"candidatesTokenCount": 611,
"totalTokenCount": 2422,
"thoughtsTokenCount": 1807,
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 4
}
]
}
}
{
"error": {
"code": 400,
"message": "Invalid request parameters",
"status": "INVALID_ARGUMENT"
}
}
{
"error": {
"code": 401,
"message": "Authentication failed, please check your API Key",
"status": "UNAUTHENTICATED"
}
}
{
"error": {
"code": 402,
"message": "Insufficient balance, please recharge",
"status": "PAYMENT_REQUIRED"
}
}
{
"error": {
"code": 403,
"message": "Access denied",
"status": "PERMISSION_DENIED"
}
}
{
"error": {
"code": 404,
"message": "Model not found",
"status": "NOT_FOUND"
}
}
{
"error": {
"code": 429,
"message": "Rate limit exceeded, please try again later",
"status": "RESOURCE_EXHAUSTED"
}
}
{
"error": {
"code": 500,
"message": "Internal server error",
"status": "INTERNAL"
}
}
{
"error": {
"code": 502,
"message": "Bad gateway, service temporarily unavailable",
"status": "BAD_GATEWAY"
}
}
{
"error": {
"code": 503,
"message": "Service temporarily unavailable",
"status": "UNAVAILABLE"
}
}
Текстовая серия
Нативный формат Gemini
- Вызов моделей Gemini в нативном формате Google API
- Синхронный режим обработки с ответом в реальном времени
- Минимум параметров для быстрого старта
POST
/
v1beta
/
models
/
{model}
:
{method}
curl --request POST \
--url https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, please introduce yourself"
}
]
}
]
}'
import requests
url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent"
payload = {
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, please introduce yourself"
}
]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent";
const payload = {
contents: [
{
role: "user",
parts: [
{
text: "Hello, please introduce yourself"
}
]
}
]
};
const headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent"
payload := map[string]interface{}{
"contents": []map[string]interface{}{
{
"role": "user",
"parts": []map[string]interface{}{
{
"text": "Hello, please introduce yourself",
},
},
},
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent";
String payload = """
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, please introduce yourself"
}
]
}
]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent";
$payload = [
"contents" => [
[
"role" => "user",
"parts" => [
[
"text" => "Hello, please introduce yourself"
]
]
]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent")
payload = {
contents: [
{
role: "user",
parts: [
{
text: "Hello, please introduce yourself"
}
]
}
]
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
{
"code": 200,
"data": {
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "Hello! I'm pleased to introduce myself.\n\nI am a large language model, trained and developed by Google..."
}
]
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
}
]
}
],
"promptFeedback": {
"safetyRatings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
}
]
]
},
"usageMetadata": {
"promptTokenCount": 4,
"candidatesTokenCount": 611,
"totalTokenCount": 2422,
"thoughtsTokenCount": 1807,
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 4
}
]
}
}
{
"error": {
"code": 400,
"message": "Invalid request parameters",
"status": "INVALID_ARGUMENT"
}
}
{
"error": {
"code": 401,
"message": "Authentication failed, please check your API Key",
"status": "UNAUTHENTICATED"
}
}
{
"error": {
"code": 402,
"message": "Insufficient balance, please recharge",
"status": "PAYMENT_REQUIRED"
}
}
{
"error": {
"code": 403,
"message": "Access denied",
"status": "PERMISSION_DENIED"
}
}
{
"error": {
"code": 404,
"message": "Model not found",
"status": "NOT_FOUND"
}
}
{
"error": {
"code": 429,
"message": "Rate limit exceeded, please try again later",
"status": "RESOURCE_EXHAUSTED"
}
}
{
"error": {
"code": 500,
"message": "Internal server error",
"status": "INTERNAL"
}
}
{
"error": {
"code": 502,
"message": "Bad gateway, service temporarily unavailable",
"status": "BAD_GATEWAY"
}
}
{
"error": {
"code": 503,
"message": "Service temporarily unavailable",
"status": "UNAVAILABLE"
}
}
curl --request POST \
--url https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, please introduce yourself"
}
]
}
]
}'
import requests
url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent"
payload = {
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, please introduce yourself"
}
]
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent";
const payload = {
contents: [
{
role: "user",
parts: [
{
text: "Hello, please introduce yourself"
}
]
}
]
};
const headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent"
payload := map[string]interface{}{
"contents": []map[string]interface{}{
{
"role": "user",
"parts": []map[string]interface{}{
{
"text": "Hello, please introduce yourself",
},
},
},
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent";
String payload = """
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello, please introduce yourself"
}
]
}
]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent";
$payload = [
"contents" => [
[
"role" => "user",
"parts" => [
[
"text" => "Hello, please introduce yourself"
]
]
]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <token>",
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1beta/models/gemini-2.5-pro:generateContent")
payload = {
contents: [
{
role: "user",
parts: [
{
text: "Hello, please introduce yourself"
}
]
}
]
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
{
"code": 200,
"data": {
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"text": "Hello! I'm pleased to introduce myself.\n\nI am a large language model, trained and developed by Google..."
}
]
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
}
]
}
],
"promptFeedback": {
"safetyRatings": [
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
}
]
]
},
"usageMetadata": {
"promptTokenCount": 4,
"candidatesTokenCount": 611,
"totalTokenCount": 2422,
"thoughtsTokenCount": 1807,
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 4
}
]
}
}
{
"error": {
"code": 400,
"message": "Invalid request parameters",
"status": "INVALID_ARGUMENT"
}
}
{
"error": {
"code": 401,
"message": "Authentication failed, please check your API Key",
"status": "UNAUTHENTICATED"
}
}
{
"error": {
"code": 402,
"message": "Insufficient balance, please recharge",
"status": "PAYMENT_REQUIRED"
}
}
{
"error": {
"code": 403,
"message": "Access denied",
"status": "PERMISSION_DENIED"
}
}
{
"error": {
"code": 404,
"message": "Model not found",
"status": "NOT_FOUND"
}
}
{
"error": {
"code": 429,
"message": "Rate limit exceeded, please try again later",
"status": "RESOURCE_EXHAUSTED"
}
}
{
"error": {
"code": 500,
"message": "Internal server error",
"status": "INTERNAL"
}
}
{
"error": {
"code": 502,
"message": "Bad gateway, service temporarily unavailable",
"status": "BAD_GATEWAY"
}
}
{
"error": {
"code": 503,
"message": "Service temporarily unavailable",
"status": "UNAVAILABLE"
}
}
Авторизация
string
обязательно
Все конечные точки API требуют аутентификации Bearer TokenПолучите свой API-ключ:Откройте страницу управления API-ключами, чтобы получить ваш API-ключДобавьте его в заголовок запроса:
Authorization: Bearer YOUR_API_KEY
Параметры пути
string
обязательно
Название моделиВ примерах используется
gemini-2.5-pro, который можно заменить на другие поддерживаемые модели Gemini:gemini-3.5-flash— Gemini 3.5 Flashgemini-3.1-pro-preview— Gemini 3.1 Pro Previewgemini-3-pro-preview— Gemini 3 Pro Previewgemini-2.5-pro— Gemini 2.5 Pro
enum<string>
обязательно
Метод генерации (рекомендуется
generateContent для быстрого старта):generateContent: дождаться полного ответа и вернуть его за один разstreamGenerateContent: потоковый ответ, возврат контента порциями
generateContent, streamGenerateContentBody
array
обязательно
Список контента диалогаТребуется минимум 1 сообщение
Пример:
Показать Структура объекта contents
Показать Структура объекта contents
string
обязательно
Тип роли:
user: сообщение пользователяmodel: ответ модели (используется в истории диалога)
[
{
"role": "user",
"parts": [{ "text": "Hello, please introduce yourself" }]
}
]
object
Конфигурация генерации (необязательно)
Показать Свойства generationConfig
Показать Свойства generationConfig
number
Управляет случайностью вывода, диапазон 0.0–2.0
- Меньшие значения делают вывод более детерминированным
- Большие значения делают вывод более случайным
integer
Максимальное количество генерируемых токеновУ разных моделей разные максимальные лимиты
number
Параметр ядровой выборки (nucleus sampling), диапазон 0.0–1.0Управляет вероятностной массой, учитываемой при выборке
integer
Параметр выборки Top-KВыборка только из K самых вероятных токенов на каждом шаге
array
Список стоп-последовательностейОстановить генерацию при встрече с этими последовательностями
array
Настройки безопасности (необязательно)
Показать Структура объекта safetySettings
Показать Структура объекта safetySettings
string
Категория безопасности:
HARM_CATEGORY_HATE_SPEECH: язык враждыHARM_CATEGORY_DANGEROUS_CONTENT: опасный контентHARM_CATEGORY_HARASSMENT: домогательствоHARM_CATEGORY_SEXUALLY_EXPLICIT: контент откровенно сексуального характера
string
Пороговый уровень:
BLOCK_NONE: не блокироватьBLOCK_ONLY_HIGH: блокировать только высокий рискBLOCK_MEDIUM_AND_ABOVE: блокировать средний риск и вышеBLOCK_LOW_AND_ABOVE: блокировать низкий риск и выше
Response
array
Список вариантов ответа
Показать Структура объекта candidates
Показать Структура объекта candidates
object
string
Причина завершения:
STOP: нормальное завершениеMAX_TOKENS: достигнут лимит токеновSAFETY: остановлено по соображениям безопасностиRECITATION: остановлено из-за повторенияOTHER: другие причины
integer
Индекс варианта ответа
object
object
Статистика использования
Показать Свойства usageMetadata
Показать Свойства usageMetadata
integer
Количество токенов в промпте
integer
Количество токенов в вариантах ответа
integer
Общее количество использованных токенов
integer
Количество токенов, использованных на размышление (если применимо)
⌘I