// Node.js 22+ (ESM). Save as orbit-example.mjs and run with: node orbit-example.mjs
const base = process.env.ORBIT_SIM_BASE_URL;
const apiKey = process.env.ORBIT_SIM_API_KEY; // keep the key server-side; never log it
const response = await fetch(`${base}/api/public-simulation/v1/models`, {
headers: { Authorization: `Bearer ${apiKey}` },
signal: AbortSignal.timeout(20000),
});
// No automatic retry. On a timeout or a 5xx, keep requestId and only GET /request.
console.log(response.status, JSON.stringify(await response.json()));
# Python 3.9+, standard library only
import json, os, urllib.error, urllib.parse, urllib.request
base = os.environ["ORBIT_SIM_BASE_URL"]
api_key = os.environ["ORBIT_SIM_API_KEY"] # keep the key server-side; never log it
req = urllib.request.Request(
base + "/api/public-simulation/v1/models",
headers={"Authorization": "Bearer " + api_key},
)
try:
with urllib.request.urlopen(req, timeout=20) as resp:
print(resp.status, json.dumps(json.load(resp)))
except urllib.error.HTTPError as err:
# No automatic retry. On a timeout or a 5xx, keep request_id and only GET /request.
print(err.code, json.dumps(json.load(err)))
// Node.js 22+ (ESM). Save as orbit-example.mjs and run with: node orbit-example.mjs
const base = process.env.ORBIT_SIM_BASE_URL;
const apiKey = process.env.ORBIT_SIM_API_KEY; // keep the key server-side; never log it
const requestId = process.env.ORBIT_SIM_REQUEST_ID; // a new UUID you saved before sending
const body = {
"mode": "simulation",
"requestId": requestId,
"model": "sim-general",
"message": "local mock metering",
"maxOutputTokens": 64,
"scenario": "success"
};
const response = await fetch(`${base}/api/public-simulation/v1/generate`, {
method: 'POST',
headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
body: JSON.stringify(body),
signal: AbortSignal.timeout(20000),
});
// No automatic retry. On a timeout or a 5xx, keep requestId and only GET /request.
console.log(response.status, JSON.stringify(await response.json()));
# Python 3.9+, standard library only
import json, os, urllib.error, urllib.parse, urllib.request
base = os.environ["ORBIT_SIM_BASE_URL"]
api_key = os.environ["ORBIT_SIM_API_KEY"] # keep the key server-side; never log it
request_id = os.environ["ORBIT_SIM_REQUEST_ID"] # a new UUID you saved before sending
body = {
"mode": "simulation",
"requestId": request_id,
"model": "sim-general",
"message": "local mock metering",
"maxOutputTokens": 64,
"scenario": "success"
}
req = urllib.request.Request(
base + "/api/public-simulation/v1/generate",
data=json.dumps(body).encode("utf-8"),
method="POST",
headers={"Authorization": "Bearer " + api_key, "Content-Type": "application/json"},
)
try:
with urllib.request.urlopen(req, timeout=20) as resp:
print(resp.status, json.dumps(json.load(resp)))
except urllib.error.HTTPError as err:
# No automatic retry. On a timeout or a 5xx, keep request_id and only GET /request.
print(err.code, json.dumps(json.load(err)))
// Node.js 22+ (ESM). Save as orbit-example.mjs and run with: node orbit-example.mjs
const base = process.env.ORBIT_SIM_BASE_URL;
const apiKey = process.env.ORBIT_SIM_API_KEY; // keep the key server-side; never log it
const requestId = process.env.ORBIT_SIM_REQUEST_ID; // the same UUID as the original POST
const url = new URL('/api/public-simulation/v1/request', base);
url.searchParams.set('requestId', requestId);
const response = await fetch(url, {
headers: { Authorization: `Bearer ${apiKey}` },
signal: AbortSignal.timeout(20000),
});
// No automatic retry. On a timeout or a 5xx, keep requestId and only GET /request.
console.log(response.status, JSON.stringify(await response.json()));
# Python 3.9+, standard library only
import json, os, urllib.error, urllib.parse, urllib.request
base = os.environ["ORBIT_SIM_BASE_URL"]
api_key = os.environ["ORBIT_SIM_API_KEY"] # keep the key server-side; never log it
request_id = os.environ["ORBIT_SIM_REQUEST_ID"] # the same UUID as the original POST
query = urllib.parse.urlencode({"requestId": request_id})
req = urllib.request.Request(
base + "/api/public-simulation/v1/request?" + query,
headers={"Authorization": "Bearer " + api_key},
)
try:
with urllib.request.urlopen(req, timeout=20) as resp:
print(resp.status, json.dumps(json.load(resp)))
except urllib.error.HTTPError as err:
# No automatic retry. On a timeout or a 5xx, keep request_id and only GET /request.
print(err.code, json.dumps(json.load(err)))