OpenAI-compatible chat completion
curl --request POST \
--url https://secureai.hiperai.ai/api/external/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "openai/gpt-5-nano",
"messages": [
{
"content": "<string>"
}
],
"temperature": 123,
"max_tokens": 123,
"stream": true,
"models": [
"<string>"
],
"fallback_models": [
"<string>"
],
"redundancy": {},
"smltp_policy": "<string>",
"prompt_shield": {}
}
'import requests
url = "https://secureai.hiperai.ai/api/external/v1/chat/completions"
payload = {
"model": "openai/gpt-5-nano",
"messages": [{ "content": "<string>" }],
"temperature": 123,
"max_tokens": 123,
"stream": True,
"models": ["<string>"],
"fallback_models": ["<string>"],
"redundancy": {},
"smltp_policy": "<string>",
"prompt_shield": {}
}
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: 'openai/gpt-5-nano',
messages: [{content: '<string>'}],
temperature: 123,
max_tokens: 123,
stream: true,
models: ['<string>'],
fallback_models: ['<string>'],
redundancy: {},
smltp_policy: '<string>',
prompt_shield: {}
})
};
fetch('https://secureai.hiperai.ai/api/external/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));Modelle & KI-Generierung
OpenAI-kompatibler Endpunkt
Drop-in-OpenAI-Chat-Completions-Oberfläche – richten Sie jedes OpenAI-SDK auf SecureAI
POST
/
v1
/
chat
/
completions
OpenAI-compatible chat completion
curl --request POST \
--url https://secureai.hiperai.ai/api/external/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "openai/gpt-5-nano",
"messages": [
{
"content": "<string>"
}
],
"temperature": 123,
"max_tokens": 123,
"stream": true,
"models": [
"<string>"
],
"fallback_models": [
"<string>"
],
"redundancy": {},
"smltp_policy": "<string>",
"prompt_shield": {}
}
'import requests
url = "https://secureai.hiperai.ai/api/external/v1/chat/completions"
payload = {
"model": "openai/gpt-5-nano",
"messages": [{ "content": "<string>" }],
"temperature": 123,
"max_tokens": 123,
"stream": True,
"models": ["<string>"],
"fallback_models": ["<string>"],
"redundancy": {},
"smltp_policy": "<string>",
"prompt_shield": {}
}
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: 'openai/gpt-5-nano',
messages: [{content: '<string>'}],
temperature: 123,
max_tokens: 123,
stream: true,
models: ['<string>'],
fallback_models: ['<string>'],
redundancy: {},
smltp_policy: '<string>',
prompt_shield: {}
})
};
fetch('https://secureai.hiperai.ai/api/external/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));OpenAI-kompatibler Endpunkt
SecureAI stellt eine OpenAI-kompatible Oberfläche bereit, sodass Sie jedes OpenAI SDK integrieren können, indem Sie nur die Basis-URL und den API-Schlüssel ändern – keine Codeänderungen. Darunter läuft der vollständige SecureAI-Sicherheitsstack (API-Schlüsselauthentifizierung, Modell-/Index-Zulassungslisten, SMLTP-Richtliniendurchsetzung + Berechtigungen, Prompt Shield, PII/DLP, Punkteabrechnung und die Modellredundanz-Engine).Endpunkt
POST /api/external/v1/chat/completions
GET /api/external/v1/models
base_url Ihres OpenAI-Clients auf:
https://{customer.name}.hiperai.ai/api/external/v1
Nur Zero-KnowledgeDiese Oberfläche unterstützt RAG/Wissensdatenbanken nicht. Anfragen werden an
Zero-Knowledge angeheftet. Wenn Sie den Abruf einer Wissensdatenbank benötigen, verwenden Sie den klassischen Endpunkt Chat Completion.Authentifizierung
Authorization: Bearer sk-your-api-key-here
Verwendung eines OpenAI SDK
Python (openai)
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key-here",
base_url="https://{customer.name}.hiperai.ai/api/external/v1",
)
resp = client.chat.completions.create(
model="openai/gpt-5-nano",
messages=[{"role": "user", "content": "Hello!"}],
# SecureAI extensions travel via extra_body
extra_body={
"smltp_policy": "internal",
"fallback_models": ["anthropic/claude-sonnet-4"],
},
)
print(resp.choices[0].message.content)
print(resp.model_extra["secureai"]["served_model"])
JavaScript (openai)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: 'sk-your-api-key-here',
baseURL: 'https://{customer.name}.hiperai.ai/api/external/v1',
});
const resp = await client.chat.completions.create({
model: 'openai/gpt-5-nano',
messages: [{ role: 'user', content: 'Hello!' }],
// @ts-expect-error — SecureAI extension fields
smltp_policy: 'internal',
fallback_models: ['anthropic/claude-sonnet-4'],
});
console.log(resp.choices[0].message.content);
Anforderungstext
Standard-OpenAI-Felder werden unterstützt.messages ist erforderlich (auf dieser Oberfläche gibt es kein prompt). max_completion_tokens wird als Alias für max_tokens akzeptiert.
Die folgenden OpenAI-Parameter werden unverändert an den Anbieter weitergegeben:
tools, tool_choice, parallel_tool_calls, response_format, stop, top_p, frequency_penalty, presence_penalty, seed, logprobs, top_logprobs, user.
SecureAI-Erweiterungsfelder
Senden Sie diese als zusätzliche Textfelder (überextra_body in den OpenAI SDKs):
| Feld | Beschreibung |
|---|---|
smltp_policy | SMLTP-Sicherheitsrichtlinie für diesen Anruf. |
prompt_shield | { enabled?, policy? } – Prompt Shield-Überschreibung pro Anruf. |
models / fallback_models | Modellieren Sie die Redundanz-Kette. |
redundancy | { timeout_ms, first_token_timeout_ms, on[] }. |
user_id | Abrechnung an einen anderen Benutzer (administriert). |
Antwort
Standard-OpenAI-Formchat.completion plus ein secureai-Erweiterungsobjekt.
{
"id": "chatcmpl-1a2b3c...",
"object": "chat.completion",
"created": 1705312200,
"model": "anthropic/claude-sonnet-4",
"choices": [
{ "index": 0, "message": { "role": "assistant", "content": "Hello!" }, "finish_reason": "stop" }
],
"usage": { "prompt_tokens": 9, "completion_tokens": 3, "total_tokens": 12 },
"secureai": {
"served_model": "anthropic/claude-sonnet-4",
"requested_model": "openai/gpt-5-nano",
"failover": { "occurred": true, "attempts": [ ... ] },
"smltp_policy_used": "internal",
"smltp_policy_source": "request",
"smltp_policy_hash": "a1b2c3...",
"prompt_shield_policy": null,
"smltp_bundle_id": "bnd_..."
}
}
secureai.smltp_bundle_id (falls vorhanden) kann gegen eine unterschriebene Compliance-Receipt eingetauscht werden.
Streaming
Stellen Siestream: true ein. Frames sind native OpenAI-Objekte chat.completion.chunk, die durch data: [DONE] beendet werden. Die Erweiterung secureai ist an den ersten Block angehängt. choices (einschließlich tool_calls Deltas und finish_reason) passieren unberührt.
Fehler
Fehler von diesem Handler verwenden den OpenAI-Umschlag:{ "error": { "message": "you must provide a model parameter", "type": "invalid_request_error", "code": null } }
code: "all_models_failed" und den Status 429 (alle Ratenbegrenzungen) oder 502 (andernfalls). Die Ablehnung von Sicherheits-Middleware behält die Form von SecureAI { "success": false, ... }; beide tragen immer ein message.
Verwandte
- Chat Completion – die klassische Oberfläche (fügt RAG hinzu).
- Redundanz & Failover
- Prompt Shield API
Autorisierungen
API key authentication using Bearer token format.
Example: Authorization: Bearer sk-your-api-key-here
Body
application/json
Beispiel:
"openai/gpt-5-nano"
Show child attributes
Show child attributes
{ timeout_ms, first_token_timeout_ms, on[] }
{ enabled?, policy? } per-call Prompt Shield override
Antwort
OpenAI chat.completion object plus a secureai extension

