API=https://api.k-agent.kerneltics.com/v1
KEY=kt_sk_live_…
# One question, one answer
curl $API/agents/agt_01J…/ask \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{"input":"How much is delivery?"}'
# → {"object":"run","status":"completed","outcome":"answered",
# "output_text":"Delivery is SAR 25, or free over SAR 200.",
# "usage":{"units":0.25,…}}
# A session under your own ID: created once, then resumed
curl $API/sessions -H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: 6f1c…" \
-d '{"agent":"agt_01J…","external_id":"order-8812",
"input":"Where is my order?"}'
# → 201 {"session":{"id":"sess_01J…","external_id":"order-8812"},
# "created":true,"run":{…}}
# Later turns use your ID in the URL, streamed over SSE
curl $API/sessions/order-8812/messages \
-H "Authorization: Bearer $KEY" \
-d '{"input":"Can I change the delivery address?","stream":true}'
# run.created … message.delta … run.completed
const API = "https://api.k-agent.kerneltics.com/v1";
const headers = {
Authorization: `Bearer ${process.env.KAGENT_SECRET_KEY}`,
"Content-Type": "application/json",
};
// One question, one answer
const run = await fetch(`${API}/agents/agt_01J…/ask`, {
method: "POST",
headers,
body: JSON.stringify({ input: "How much is delivery?" }),
}).then((res) => res.json());
console.log(run.output_text); // Delivery is SAR 25, or free over SAR 200.
// A session under your own ID: created once, then resumed
const { session, created } = await fetch(`${API}/sessions`, {
method: "POST",
headers: { ...headers, "Idempotency-Key": crypto.randomUUID() },
body: JSON.stringify({
agent: "agt_01J…",
external_id: "order-8812",
input: "Where is my order?",
}),
}).then((res) => res.json());
// Later turns use your ID in the URL
await fetch(`${API}/sessions/order-8812/messages`, {
method: "POST",
headers,
body: JSON.stringify({ input: "Can I change the delivery address?" }),
});
import os, uuid, requests
API = "https://api.k-agent.kerneltics.com/v1"
headers = {"Authorization": f"Bearer {os.environ['KAGENT_SECRET_KEY']}"}
# One question, one answer
run = requests.post(
f"{API}/agents/agt_01J…/ask",
headers=headers,
json={"input": "How much is delivery?"},
).json()
print(run["output_text"]) # Delivery is SAR 25, or free over SAR 200.
# A session under your own ID: created once, then resumed
res = requests.post(
f"{API}/sessions",
headers={**headers, "Idempotency-Key": str(uuid.uuid4())},
json={
"agent": "agt_01J…",
"external_id": "order-8812",
"input": "Where is my order?",
},
).json()
print(res["created"], res["session"]["id"]) # True sess_01J…
# Later turns use your ID in the URL
requests.post(
f"{API}/sessions/order-8812/messages",
headers=headers,
json={"input": "Can I change the delivery address?"},
)