Запрос чату
POST /api/v1/chat/completions — генерация текста, диалог, вызов функций
curl --request POST \
--url https://speshu.ai/api/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4o",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
]
}
],
"stream": false,
"max_completion_tokens": 123,
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"top_k": 123,
"stop": [
"<string>"
],
"presence_penalty": 123,
"frequency_penalty": 123,
"seed": 123,
"n": 123,
"logprobs": true,
"top_logprobs": 123,
"logit_bias": {},
"stream_options": {
"include_usage": true
},
"response_format": {},
"tools": [
{}
],
"tool_choice": "<string>",
"parallel_tool_calls": true,
"reasoning": {
"enabled": true,
"max_tokens": 123,
"summary": "<string>",
"display": "<string>"
},
"web_search_options": {
"search_context_size": "<string>",
"user_location": {}
},
"modalities": [
"<string>"
],
"service_tier": "<string>",
"user": "<string>",
"metadata": {}
}
'import requests
url = "https://speshu.ai/api/v1/chat/completions"
payload = {
"model": "gpt-4o",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
]
}
],
"stream": False,
"max_completion_tokens": 123,
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"top_k": 123,
"stop": ["<string>"],
"presence_penalty": 123,
"frequency_penalty": 123,
"seed": 123,
"n": 123,
"logprobs": True,
"top_logprobs": 123,
"logit_bias": {},
"stream_options": { "include_usage": True },
"response_format": {},
"tools": [{}],
"tool_choice": "<string>",
"parallel_tool_calls": True,
"reasoning": {
"enabled": True,
"max_tokens": 123,
"summary": "<string>",
"display": "<string>"
},
"web_search_options": {
"search_context_size": "<string>",
"user_location": {}
},
"modalities": ["<string>"],
"service_tier": "<string>",
"user": "<string>",
"metadata": {}
}
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({
model: 'gpt-4o',
messages: [
{
content: '<string>',
name: '<string>',
tool_call_id: '<string>',
tool_calls: [
{
id: '<string>',
type: 'function',
function: {name: '<string>', arguments: '<string>'}
}
]
}
],
stream: false,
max_completion_tokens: 123,
max_tokens: 123,
temperature: 123,
top_p: 123,
top_k: 123,
stop: ['<string>'],
presence_penalty: 123,
frequency_penalty: 123,
seed: 123,
n: 123,
logprobs: true,
top_logprobs: 123,
logit_bias: {},
stream_options: {include_usage: true},
response_format: {},
tools: [{}],
tool_choice: '<string>',
parallel_tool_calls: true,
reasoning: {enabled: true, max_tokens: 123, summary: '<string>', display: '<string>'},
web_search_options: {search_context_size: '<string>', user_location: {}},
modalities: ['<string>'],
service_tier: '<string>',
user: '<string>',
metadata: {}
})
};
fetch('https://speshu.ai/api/v1/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://speshu.ai/api/v1/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([
'model' => 'gpt-4o',
'messages' => [
[
'content' => '<string>',
'name' => '<string>',
'tool_call_id' => '<string>',
'tool_calls' => [
[
'id' => '<string>',
'type' => 'function',
'function' => [
'name' => '<string>',
'arguments' => '<string>'
]
]
]
]
],
'stream' => false,
'max_completion_tokens' => 123,
'max_tokens' => 123,
'temperature' => 123,
'top_p' => 123,
'top_k' => 123,
'stop' => [
'<string>'
],
'presence_penalty' => 123,
'frequency_penalty' => 123,
'seed' => 123,
'n' => 123,
'logprobs' => true,
'top_logprobs' => 123,
'logit_bias' => [
],
'stream_options' => [
'include_usage' => true
],
'response_format' => [
],
'tools' => [
[
]
],
'tool_choice' => '<string>',
'parallel_tool_calls' => true,
'reasoning' => [
'enabled' => true,
'max_tokens' => 123,
'summary' => '<string>',
'display' => '<string>'
],
'web_search_options' => [
'search_context_size' => '<string>',
'user_location' => [
]
],
'modalities' => [
'<string>'
],
'service_tier' => '<string>',
'user' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://speshu.ai/api/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"stream\": false,\n \"max_completion_tokens\": 123,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"seed\": 123,\n \"n\": 123,\n \"logprobs\": true,\n \"top_logprobs\": 123,\n \"logit_bias\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"response_format\": {},\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"parallel_tool_calls\": true,\n \"reasoning\": {\n \"enabled\": true,\n \"max_tokens\": 123,\n \"summary\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"web_search_options\": {\n \"search_context_size\": \"<string>\",\n \"user_location\": {}\n },\n \"modalities\": [\n \"<string>\"\n ],\n \"service_tier\": \"<string>\",\n \"user\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://speshu.ai/api/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"stream\": false,\n \"max_completion_tokens\": 123,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"seed\": 123,\n \"n\": 123,\n \"logprobs\": true,\n \"top_logprobs\": 123,\n \"logit_bias\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"response_format\": {},\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"parallel_tool_calls\": true,\n \"reasoning\": {\n \"enabled\": true,\n \"max_tokens\": 123,\n \"summary\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"web_search_options\": {\n \"search_context_size\": \"<string>\",\n \"user_location\": {}\n },\n \"modalities\": [\n \"<string>\"\n ],\n \"service_tier\": \"<string>\",\n \"user\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://speshu.ai/api/v1/chat/completions")
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 = "{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"stream\": false,\n \"max_completion_tokens\": 123,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"seed\": 123,\n \"n\": 123,\n \"logprobs\": true,\n \"top_logprobs\": 123,\n \"logit_bias\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"response_format\": {},\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"parallel_tool_calls\": true,\n \"reasoning\": {\n \"enabled\": true,\n \"max_tokens\": 123,\n \"summary\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"web_search_options\": {\n \"search_context_size\": \"<string>\",\n \"user_location\": {}\n },\n \"modalities\": [\n \"<string>\"\n ],\n \"service_tier\": \"<string>\",\n \"user\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"finish_reason": "stop",
"logprobs": {},
"message": {
"role": "assistant",
"content": "<string>",
"refusal": "<string>",
"reasoning": "<string>",
"reasoning_content": "<string>",
"tool_calls": [
{}
]
}
}
],
"system_fingerprint": "<string>",
"service_tier": "<string>",
"usage": {
"total_tokens": 123,
"prompt_tokens": 123,
"completion_tokens": 123,
"prompt_tokens_details": {
"text_tokens": 123,
"audio_tokens": 123,
"image_tokens": 123,
"cached_read_tokens": 123
},
"completion_tokens_details": {
"text_tokens": 123,
"reasoning_tokens": 123,
"audio_tokens": 123
},
"cost": {
"input_cost": 123,
"output_cost": 123,
"total_cost": 123
}
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}base_url.
Минимальный запрос
curl https://speshu.ai/api/v1/chat/completions \
-H "Authorization: Bearer $SPESHU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Привет!"}]
}'
from openai import OpenAI
client = OpenAI(base_url="https://speshu.ai/api/v1", api_key="sk-...")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Привет!"}],
)
print(response.choices[0].message.content)
print(response.usage.cost.total_cost, "₽")
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://speshu.ai/api/v1",
apiKey: "sk-...",
});
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Привет!" }],
});
console.log(response.choices[0].message?.content);
GET /api/v1/models и подставить как есть, без префикса провайдера. Если модель неизвестна, придёт 404 с кодом model_not_found. Идентификатор в примерах ниже конкретный, чтобы их можно было скопировать; в рабочем коде получайте его из каталога — состав моделей меняется.Поля запроса
Обязательные
| Поле | Тип | Описание |
|---|---|---|
model | string | Идентификатор из GET /api/v1/models |
messages | array | Непустой массив сообщений |
Генерация
| Поле | Тип | Описание |
|---|---|---|
max_completion_tokens | integer | Потолок выходных токенов. Это единственный параметр, учитываемый при проверке контекстного окна |
max_tokens | integer | Устаревшее имя. Значение переносится в max_completion_tokens, только если тот не задан |
temperature | number | |
top_p | number | |
top_k | integer | Поддерживают только провайдеры Anthropic; остальные молча игнорируют. |
stop | string[] | |
presence_penalty, frequency_penalty | number | |
seed | integer | |
n | integer | |
logprobs, top_logprobs | boolean, integer | |
logit_bias | object | Карта «токен → смещение» |
service_tier | string | auto, default, flex, priority |
metadata | object |
Формат ответа и инструменты
| Поле | Тип | Описание |
|---|---|---|
response_format | object | {"type": "text"}, {"type": "json_object"} или {"type": "json_schema", "json_schema": {...}} |
tools | array | Функции для вызова |
tool_choice | string | object | none, auto, required либо объект с именем функции |
parallel_tool_calls | boolean | |
web_search_options | object | Встроенный веб-поиск |
modalities | string[] |
Рассуждения
| Поле | Тип | Описание |
|---|---|---|
reasoning | object | {enabled, effort, max_tokens, summary, display} |
reasoning_effort | string | none, minimal, low, medium, high. Сокращённая запись reasoning.effort |
reasoning_effort и reasoning.effort одновременно — придёт ошибка 400. Укажите что-то одно.effort, кроме none, включает рассуждение. Текст рассуждений приходит в choices[0].message.reasoning (и дублируется в reasoning_content) и в usage.completion_tokens_details.reasoning_tokens.
Прочее
| Поле | Тип | Описание |
|---|---|---|
stream | boolean | Потоковая передача через SSE |
stream_options.include_usage | boolean | |
user | string | Принимается, но не используется для атрибуции — запрос всегда относится к владельцу ключа |
Формат сообщений
Текст
{ "role": "user", "content": "Привет" }
system, developer, user, assistant, tool.
Мультимодальность
content может быть массивом блоков. Поддерживаются четыре типа:
{
"role": "user",
"content": [
{ "type": "text", "text": "Что на картинке?" },
{ "type": "image_url", "image_url": { "url": "https://example.com/photo.jpg", "detail": "auto" } }
]
}
| Тип | Поля |
|---|---|
text | text |
image_url | url, detail (auto, low, high) |
input_audio | data (base64), format (wav, mp3) |
file | filename, file_data (data-URL в base64) или file_url |
image_url.url должна быть публично доступна без авторизации — её скачает провайдер. Файл из хранилища подходит: загрузите его через POST /api/v1/storage/upload и подставьте полученный url.400 invalid_request.
Вызов функций
{
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Погода в городе",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}
}
],
"tool_choice": "auto"
}
choices[0].message.tool_calls, а finish_reason равен tool_calls:
{
"tool_calls": [
{
"id": "call_123",
"type": "function",
"function": { "name": "get_weather", "arguments": "{\"city\": \"Москва\"}" }
}
]
}
tool и тем же tool_call_id.
Ответ
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1756800000,
"model": "gpt-4o",
"system_fingerprint": "fp_...",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "Привет! Чем помочь?"
}
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 7,
"total_tokens": 16,
"prompt_tokens_details": { "cached_read_tokens": 0 },
"completion_tokens_details": { "reasoning_tokens": 0 },
"cost": { "total_cost": 0.0008 }
}
}
Стоимость
usage.cost.total_cost — сумма, списанная с вашего кошелька в рублях. Именно она совпадает с cost_context и cost_completion из GET /api/v1/models.
Потоковая передача
Приstream: true приходит поток SSE. Каждый кадр — безымянное событие data:; отдельного поля event: сервер не пишет, поэтому клиенты, разбирающие поток по event:, работать не будут.
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"Привет"}}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"!"}}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[],"usage":{"prompt_tokens":9,"completion_tokens":7,"total_tokens":16,"cost":{"total_cost":0.0008}}}
data: [DONE]
usage. Этот кадр приходит всегда, даже если вы не задавали stream_options.include_usage — и именно в нём списываются деньги.[DONE] не придёт вовсе:
data: {"error":{"message":"...","type":"server_error"}}
Проверки перед вызовом
Часть ошибок возвращается до обращения к провайдеру:| Ситуация | Ответ |
|---|---|
| Нет ключа | 401 invalid_api_key |
| Модель неизвестна | 404 model_not_found |
| Не хватает денег | 402 insufficient_quota |
| Изображение в запросе к модели без зрения | 400 invalid_request |
Неподдерживаемый reasoning.effort | 400 invalid_request |
| Входные токены плюс резерв выхода не помещаются в окно | 422 content_too_large |
| Исчерпан лимит тарифа | 422 limit_exceeded или 429 |
Что дальше
Responses API
Anthropic Messages
Ошибки
Лимиты
Авторизации
API-ключ в формате sk-.... Альтернативно — заголовок X-Api-Key: sk-... (совместимо с Anthropic SDK).
Параметры запроса
Ключ закреплённого роутинга. Одинаковый session_id направляет запросы на одного и того же провайдера. Тело запроса имеет приоритет над заголовком x-session-id.
256Тело
Идентификатор модели из GET /api/v1/models без изменений.
"gpt-4o"
История диалога.
Show child attributes
Show child attributes
Потолок числа выходных токенов.
Устаревшее имя max_completion_tokens. Если задано max_completion_tokens, игнорируется.
Поддерживается только провайдерами Anthropic; остальные молча игнорируют.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Формат ответа: {"type": "text"}, {"type": "json_object"} или {"type": "json_schema", "json_schema": {...}}.
none, auto, required либо объект с именем функции.
Настройки рассуждений. Значение effort, отличное от none, включает рассуждение.
Show child attributes
Show child attributes
Сокращённая запись reasoning.effort. Задавать вместе с reasoning.effort нельзя — будет ошибка.
none, minimal, low, medium, high Show child attributes
Show child attributes
Принимается, но не используется для атрибуции: запрос всегда относится к владельцу ключа.
Ответ
Успешный ответ. При stream: true — поток SSE.
curl --request POST \
--url https://speshu.ai/api/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4o",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
]
}
],
"stream": false,
"max_completion_tokens": 123,
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"top_k": 123,
"stop": [
"<string>"
],
"presence_penalty": 123,
"frequency_penalty": 123,
"seed": 123,
"n": 123,
"logprobs": true,
"top_logprobs": 123,
"logit_bias": {},
"stream_options": {
"include_usage": true
},
"response_format": {},
"tools": [
{}
],
"tool_choice": "<string>",
"parallel_tool_calls": true,
"reasoning": {
"enabled": true,
"max_tokens": 123,
"summary": "<string>",
"display": "<string>"
},
"web_search_options": {
"search_context_size": "<string>",
"user_location": {}
},
"modalities": [
"<string>"
],
"service_tier": "<string>",
"user": "<string>",
"metadata": {}
}
'import requests
url = "https://speshu.ai/api/v1/chat/completions"
payload = {
"model": "gpt-4o",
"messages": [
{
"content": "<string>",
"name": "<string>",
"tool_call_id": "<string>",
"tool_calls": [
{
"id": "<string>",
"type": "function",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
]
}
],
"stream": False,
"max_completion_tokens": 123,
"max_tokens": 123,
"temperature": 123,
"top_p": 123,
"top_k": 123,
"stop": ["<string>"],
"presence_penalty": 123,
"frequency_penalty": 123,
"seed": 123,
"n": 123,
"logprobs": True,
"top_logprobs": 123,
"logit_bias": {},
"stream_options": { "include_usage": True },
"response_format": {},
"tools": [{}],
"tool_choice": "<string>",
"parallel_tool_calls": True,
"reasoning": {
"enabled": True,
"max_tokens": 123,
"summary": "<string>",
"display": "<string>"
},
"web_search_options": {
"search_context_size": "<string>",
"user_location": {}
},
"modalities": ["<string>"],
"service_tier": "<string>",
"user": "<string>",
"metadata": {}
}
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({
model: 'gpt-4o',
messages: [
{
content: '<string>',
name: '<string>',
tool_call_id: '<string>',
tool_calls: [
{
id: '<string>',
type: 'function',
function: {name: '<string>', arguments: '<string>'}
}
]
}
],
stream: false,
max_completion_tokens: 123,
max_tokens: 123,
temperature: 123,
top_p: 123,
top_k: 123,
stop: ['<string>'],
presence_penalty: 123,
frequency_penalty: 123,
seed: 123,
n: 123,
logprobs: true,
top_logprobs: 123,
logit_bias: {},
stream_options: {include_usage: true},
response_format: {},
tools: [{}],
tool_choice: '<string>',
parallel_tool_calls: true,
reasoning: {enabled: true, max_tokens: 123, summary: '<string>', display: '<string>'},
web_search_options: {search_context_size: '<string>', user_location: {}},
modalities: ['<string>'],
service_tier: '<string>',
user: '<string>',
metadata: {}
})
};
fetch('https://speshu.ai/api/v1/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://speshu.ai/api/v1/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([
'model' => 'gpt-4o',
'messages' => [
[
'content' => '<string>',
'name' => '<string>',
'tool_call_id' => '<string>',
'tool_calls' => [
[
'id' => '<string>',
'type' => 'function',
'function' => [
'name' => '<string>',
'arguments' => '<string>'
]
]
]
]
],
'stream' => false,
'max_completion_tokens' => 123,
'max_tokens' => 123,
'temperature' => 123,
'top_p' => 123,
'top_k' => 123,
'stop' => [
'<string>'
],
'presence_penalty' => 123,
'frequency_penalty' => 123,
'seed' => 123,
'n' => 123,
'logprobs' => true,
'top_logprobs' => 123,
'logit_bias' => [
],
'stream_options' => [
'include_usage' => true
],
'response_format' => [
],
'tools' => [
[
]
],
'tool_choice' => '<string>',
'parallel_tool_calls' => true,
'reasoning' => [
'enabled' => true,
'max_tokens' => 123,
'summary' => '<string>',
'display' => '<string>'
],
'web_search_options' => [
'search_context_size' => '<string>',
'user_location' => [
]
],
'modalities' => [
'<string>'
],
'service_tier' => '<string>',
'user' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://speshu.ai/api/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"stream\": false,\n \"max_completion_tokens\": 123,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"seed\": 123,\n \"n\": 123,\n \"logprobs\": true,\n \"top_logprobs\": 123,\n \"logit_bias\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"response_format\": {},\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"parallel_tool_calls\": true,\n \"reasoning\": {\n \"enabled\": true,\n \"max_tokens\": 123,\n \"summary\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"web_search_options\": {\n \"search_context_size\": \"<string>\",\n \"user_location\": {}\n },\n \"modalities\": [\n \"<string>\"\n ],\n \"service_tier\": \"<string>\",\n \"user\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://speshu.ai/api/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"stream\": false,\n \"max_completion_tokens\": 123,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"seed\": 123,\n \"n\": 123,\n \"logprobs\": true,\n \"top_logprobs\": 123,\n \"logit_bias\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"response_format\": {},\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"parallel_tool_calls\": true,\n \"reasoning\": {\n \"enabled\": true,\n \"max_tokens\": 123,\n \"summary\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"web_search_options\": {\n \"search_context_size\": \"<string>\",\n \"user_location\": {}\n },\n \"modalities\": [\n \"<string>\"\n ],\n \"service_tier\": \"<string>\",\n \"user\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://speshu.ai/api/v1/chat/completions")
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 = "{\n \"model\": \"gpt-4o\",\n \"messages\": [\n {\n \"content\": \"<string>\",\n \"name\": \"<string>\",\n \"tool_call_id\": \"<string>\",\n \"tool_calls\": [\n {\n \"id\": \"<string>\",\n \"type\": \"function\",\n \"function\": {\n \"name\": \"<string>\",\n \"arguments\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"stream\": false,\n \"max_completion_tokens\": 123,\n \"max_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"top_k\": 123,\n \"stop\": [\n \"<string>\"\n ],\n \"presence_penalty\": 123,\n \"frequency_penalty\": 123,\n \"seed\": 123,\n \"n\": 123,\n \"logprobs\": true,\n \"top_logprobs\": 123,\n \"logit_bias\": {},\n \"stream_options\": {\n \"include_usage\": true\n },\n \"response_format\": {},\n \"tools\": [\n {}\n ],\n \"tool_choice\": \"<string>\",\n \"parallel_tool_calls\": true,\n \"reasoning\": {\n \"enabled\": true,\n \"max_tokens\": 123,\n \"summary\": \"<string>\",\n \"display\": \"<string>\"\n },\n \"web_search_options\": {\n \"search_context_size\": \"<string>\",\n \"user_location\": {}\n },\n \"modalities\": [\n \"<string>\"\n ],\n \"service_tier\": \"<string>\",\n \"user\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "chat.completion",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"finish_reason": "stop",
"logprobs": {},
"message": {
"role": "assistant",
"content": "<string>",
"refusal": "<string>",
"reasoning": "<string>",
"reasoning_content": "<string>",
"tool_calls": [
{}
]
}
}
],
"system_fingerprint": "<string>",
"service_tier": "<string>",
"usage": {
"total_tokens": 123,
"prompt_tokens": 123,
"completion_tokens": 123,
"prompt_tokens_details": {
"text_tokens": 123,
"audio_tokens": 123,
"image_tokens": 123,
"cached_read_tokens": 123
},
"completion_tokens_details": {
"text_tokens": 123,
"reasoning_tokens": 123,
"audio_tokens": 123
},
"cost": {
"input_cost": 123,
"output_cost": 123,
"total_cost": 123
}
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "invalid_request"
}
}