Генерация текста
curl --request POST \
--url https://api.example.com/api/v2/generate \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"params": {}
}
'import requests
url = "https://api.example.com/api/v2/generate"
payload = {
"model": "<string>",
"prompt": "<string>",
"params": {}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', prompt: '<string>', params: {}})
};
fetch('https://api.example.com/api/v2/generate', 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.example.com/api/v2/generate",
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' => '<string>',
'prompt' => '<string>',
'params' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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://api.example.com/api/v2/generate"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"params\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.example.com/api/v2/generate")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"params\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v2/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"params\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"status": "<string>",
"model_slug": "<string>",
"result_text": {},
"result_url": {},
"error": {},
"tokens_spent": 123,
"processing_ms": {},
"result_metadata": {}
}Генерация (результаты)
Генерация текста
Генерация текста с помощью GPT, Claude, Gemini, DeepSeek и Grok
POST
/
api
/
v2
/
generate
Генерация текста
curl --request POST \
--url https://api.example.com/api/v2/generate \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"params": {}
}
'import requests
url = "https://api.example.com/api/v2/generate"
payload = {
"model": "<string>",
"prompt": "<string>",
"params": {}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({model: '<string>', prompt: '<string>', params: {}})
};
fetch('https://api.example.com/api/v2/generate', 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.example.com/api/v2/generate",
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' => '<string>',
'prompt' => '<string>',
'params' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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://api.example.com/api/v2/generate"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"params\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.example.com/api/v2/generate")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"params\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v2/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"params\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"status": "<string>",
"model_slug": "<string>",
"result_text": {},
"result_url": {},
"error": {},
"tokens_spent": 123,
"processing_ms": {},
"result_metadata": {}
}Запрос
string
обязательно
API-ключ:
Authorization: Bearer nb_ВАШ_API_КЛЮЧstring
обязательно
Слаг текстовой модели. Все доступные слаги перечислены в каталоге моделей.
string
обязательно
Запрос пользователя длиной до 100 000 символов.
object
по умолчанию:"{}"
Параметры выбранной модели. Для текстовых моделей могут включать
system_prompt, temperature и max_tokens.Пример запроса
curl -X POST https://elumenta.ru/api/v2/generate \
-H "Authorization: Bearer nb_ВАШ_API_КЛЮЧ" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5",
"prompt": "Напиши безопасную функцию разбора JSON на Python",
"params": {
"system_prompt": "Ты опытный Python-разработчик.",
"temperature": 0.5
}
}'
import requests
response = requests.post(
"https://elumenta.ru/api/v2/generate",
headers={"Authorization": "Bearer nb_ВАШ_API_КЛЮЧ"},
json={
"model": "claude-sonnet-5",
"prompt": "Напиши безопасную функцию разбора JSON на Python",
"params": {
"system_prompt": "Ты опытный Python-разработчик.",
"temperature": 0.5,
},
},
)
print(response.json()["result_text"])
const response = await fetch("https://elumenta.ru/api/v2/generate", {
method: "POST",
headers: {
"Authorization": "Bearer nb_ВАШ_API_КЛЮЧ",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "claude-sonnet-5",
prompt: "Напиши безопасную функцию разбора JSON на JavaScript",
params: { temperature: 0.5 }
})
});
const data = await response.json();
console.log(data.result_text);
Ответ
integer
ID генерации.
string
completed | pending | failedstring
Слаг использованной модели.
string | null
Сгенерированный текст.
string | null
Для текста обычно
null.string | null
Описание ошибки или
null.integer
Списанные токены Elumenta.
integer | null
Время обработки в миллисекундах.
object | null
Дополнительные метаданные результата или
null.{
"id": 18473,
"status": "completed",
"model_slug": "claude-sonnet-5",
"result_text": "Вот безопасная функция разбора JSON...",
"result_url": null,
"error": null,
"tokens_spent": 3,
"processing_ms": 2104,
"result_metadata": null
}
Этот эндпоинт принимает собственную схему Elumenta:
model, prompt и необязательный объект params. Для запросов в формате OpenAI с массивом messages используйте POST /v1/chat/completions.
