Call the API
Set CYBER_API_BASE to the supplied API base address (including /v1), CYBER_MODEL to your assigned model ID and CYBER_API_KEY to your project key. Run the example on your server.
Python 3
import json
import os
from urllib.request import Request, urlopen
base = os.environ["CYBER_API_BASE"].rstrip("/")
payload = {
"model": os.environ["CYBER_MODEL"],
"messages": [{"role": "user", "content": "Gateway flagged request R1. Application logs are pending. List the known fact and the missing evidence."}],
}
request = Request(
base + "/chat/completions",
data=json.dumps(payload).encode(),
headers={
"Authorization": "Bearer " + os.environ["CYBER_API_KEY"],
"Content-Type": "application/json",
},
)
with urlopen(request, timeout=60) as response:
print(json.load(response)["choices"][0]["message"]["content"])
JavaScript · Node.js 18+
const { CYBER_API_BASE, CYBER_API_KEY, CYBER_MODEL } = process.env;
const base = CYBER_API_BASE.endsWith("/")
? CYBER_API_BASE.slice(0, -1) : CYBER_API_BASE;
const response = await fetch(base + "/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer " + CYBER_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: CYBER_MODEL,
messages: [{ role: "user", content: "Gateway flagged request R1. Application logs are pending. List the known fact and the missing evidence." }],
}),
});
if (!response.ok) throw new Error("HTTP " + response.status);
console.log((await response.json()).choices[0].message.content);
Enquire about model access