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));Modelos & Generación AI
OpenAI-Compatible Endpoint
Drop-in OpenAI Chat Completions surface — point any OpenAI SDK at 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-Compatible Endpoint
SecureAI exposes an OpenAI-compatible surface so you can integrate with any OpenAI SDK by changing only the base URL and API key — no code changes. The full SecureAI security stack (API-key auth, model/index allowlists, SMLTP policy enforcement + entitlements, Prompt Shield, PII/DLP, points billing, and the model redundancy engine) runs underneath.Endpoint
POST /api/external/v1/chat/completions
GET /api/external/v1/models
base_url at:
https://{customer.name}.hiperai.ai/api/external/v1
Zero-Knowledge onlyThis surface does not support RAG / knowledge bases. Requests are pinned to
Zero-Knowledge. If you need knowledge-base retrieval, use the classic Chat Completion endpoint.Authentication
Authorization: Bearer sk-your-api-key-here
Using an 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);
Request Body
Standard OpenAI fields are supported.messages is required (there is no prompt on this surface). max_completion_tokens is accepted as an alias for max_tokens.
The following OpenAI parameters are passed through to the provider as-is:
tools, tool_choice, parallel_tool_calls, response_format, stop, top_p, frequency_penalty, presence_penalty, seed, logprobs, top_logprobs, user.
SecureAI extension fields
Send these as extra body fields (viaextra_body in the OpenAI SDKs):
| Field | Description |
|---|---|
smltp_policy | SMLTP security policy for this call. |
prompt_shield | { enabled?, policy? } — per-call Prompt Shield override. |
models / fallback_models | Model redundancy chain. |
redundancy | { timeout_ms, first_token_timeout_ms, on[] }. |
user_id | Bill to a different user (admin-gated). |
Response
Standard OpenAIchat.completion shape, plus a secureai extension object.
{
"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 (when present) can be exchanged for a signed compliance receipt.
Streaming
Setstream: true. Frames are native OpenAI chat.completion.chunk objects terminated by data: [DONE]. The secureai extension is attached to the first chunk. choices (including tool_calls deltas and finish_reason) pass through untouched.
Errors
Errors from this handler use the OpenAI envelope:{ "error": { "message": "you must provide a model parameter", "type": "invalid_request_error", "code": null } }
code: "all_models_failed" and status 429 (all rate limits) or 502 (otherwise). Security-middleware rejections keep the SecureAI { "success": false, ... } shape; both always carry a message.
Related
- Chat Completion — the classic surface (adds RAG).
- Redundancy & Failover
- Prompt Shield API
Authorizations
API key authentication using Bearer token format.
Example: Authorization: Bearer sk-your-api-key-here
Body
application/json
Example:
"openai/gpt-5-nano"
Show child attributes
Show child attributes
{ timeout_ms, first_token_timeout_ms, on[] }
{ enabled?, policy? } per-call Prompt Shield override
Response
OpenAI chat.completion object plus a secureai extension

