API per sviluppatori.
Una sola chiave, un solo endpoint, tutti i modelli. L'API è OpenAI-compatible: se usi già una libreria OpenAI, ti basta cambiare il base_url.
https://api.enesi.ai/v1 — usa qualsiasi SDK OpenAI impostando questo base_url e la tua chiave llmr_....Autenticazione
Ogni richiesta va autenticata con la tua chiave API nell'header Authorization, in formato Bearer. Le chiavi iniziano con llmr_ e si generano dalla dashboard.
Authorization: Bearer llmr_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
Tratta la chiave come una password: non includerla nel codice client né nei repository pubblici.
Chat completions
Genera una risposta da un modello conversazionale. Imposta model sull'identificativo del modello (l'elenco è nell'area cliente, sezione Modelli) e passa la lista dei messages.
curl https://api.enesi.ai/v1/chat/completions \
-H "Authorization: Bearer llmr_..." \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4.6",
"messages": [
{ "role": "system", "content": "Sei un assistente conciso." },
{ "role": "user", "content": "Riassumi la conformità GDPR in una frase." }
]
}'<?php
$ch = curl_init("https://api.enesi.ai/v1/chat/completions");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer llmr_...",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"model" => "claude-sonnet-4.6",
"messages" => [
["role" => "system", "content" => "Sei un assistente conciso."],
["role" => "user", "content" => "Riassumi la conformità GDPR in una frase."],
],
]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;const res = await fetch("https://api.enesi.ai/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer llmr_...",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "claude-sonnet-4.6",
messages: [
{ role: "system", content: "Sei un assistente conciso." },
{ role: "user", content: "Riassumi la conformità GDPR in una frase." }
]
})
});
const data = await res.json();
console.log(data.choices[0].message.content);Embeddings
Trasforma un testo in un vettore numerico, utile per ricerca semantica e classificazione. Passa model e input (stringa o array di stringhe).
curl https://api.enesi.ai/v1/embeddings \
-H "Authorization: Bearer llmr_..." \
-H "Content-Type: application/json" \
-d '{
"model": "embedding-small",
"input": "Gateway API con credito prepagato."
}'<?php
$ch = curl_init("https://api.enesi.ai/v1/embeddings");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer llmr_...",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"model" => "embedding-small",
"input" => "Gateway API con credito prepagato.",
]),
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;const res = await fetch("https://api.enesi.ai/v1/embeddings", {
method: "POST",
headers: {
"Authorization": "Bearer llmr_...",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "embedding-small",
input: "Gateway API con credito prepagato."
})
});
const data = await res.json();
console.log(data.data[0].embedding.length);Lista modelli
Restituisce i modelli abilitati per la tua chiave, con identificativo e disponibilità.
curl https://api.enesi.ai/v1/models \
-H "Authorization: Bearer llmr_..."<?php
$ch = curl_init("https://api.enesi.ai/v1/models");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer llmr_..."],
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;const res = await fetch("https://api.enesi.ai/v1/models", {
headers: { "Authorization": "Bearer llmr_..." }
});
const data = await res.json();
data.data.forEach(m => console.log(m.id));Codici di errore
Gli errori seguono lo standard HTTP e includono un campo error.code testuale.
| Stato | Codice | Significato |
|---|---|---|
| 401 | invalid_api_key | Chiave API mancante, errata o revocata. |
| 402 | insufficient_credit | Credito esaurito. Ricarica il saldo per riprendere. |
| 403 | model_not_allowed | Il modello richiesto non è abilitato per questa chiave. |
| 404 | model_not_found | L'identificativo del modello non esiste. |
| 429 | rate_limit_exceeded | Troppe richieste. Rallenta e riprova dopo qualche istante. |
| 502 | upstream_error | Errore dal provider del modello a monte. |
| 503 | provider_unavailable | Il provider del modello è temporaneamente non disponibile. |