Skip to content

Quickstart (5 minutes)

View as Markdown

In five minutes you will create an agent, call it once, open a chat session under your own ID and stream a reply. Every step shows curl, JavaScript (fetch, Node 18+) and Python (requests); pick a tab once and the whole site follows.

The agent in this guide answers for Nada Perfumes, an online perfume and oud store: Royal oud oil (12 ml) 450 SAR, white musk perfume (100 ml) 220 SAR, free delivery on orders over 200 SAR (otherwise 25 SAR) in 1 to 3 working days to Riyadh, Jeddah and Dammam, and returns within 7 days if the product is unopened.

1. Create your account and connect a model

Section titled “1. Create your account and connect a model”
  1. Sign up at app.k-agent.kerneltics.com. You get an organization on the Free plan and a project called Production.
  2. In onboarding, Connect your AI model: paste an API key from OpenAI, Anthropic, DeepSeek or any OpenAI-compatible provider. The key is checked live, encrypted and never shown again. If your K-Agent server already provides a platform model, you can skip this.

Open API keys → Create secret key and copy the key. It starts with kt_sk_live_ and is shown only once. Keep it on your server, then export it in your shell:

نافذة الطرفية
export KAGENT_API_KEY="kt_sk_live_…"

The quickest way is the dashboard: Agents → New agent, pick a template, give it a name. To do the same over the API:

نافذة الطرفية
curl https://api.k-agent.kerneltics.com/v1/agents \
-H "Authorization: Bearer $KAGENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Nada assistant",
"slug": "store-assistant",
"config": {
"locale": { "language": "en", "timezone": "Asia/Riyadh" },
"instructions": {
"enabled": true,
"text": "You answer customers of Nada Perfumes, an online perfume and oud store. Prices: Royal oud oil 12 ml 450 SAR, white musk perfume 100 ml 220 SAR, bakhoor box 95 SAR. Delivery is free on orders over 200 SAR, otherwise 25 SAR, and takes 1 to 3 working days to Riyadh, Jeddah and Dammam, 3 to 5 days to other cities. Returns within 7 days if the product is unopened and in its original packaging."
}
}
}'

Settings you leave out keep their defaults, and the response always shows the complete configuration. Creating an agent publishes version 1 straight away, so it can answer immediately:

{
"id": "agt_01k6rz1m3w8q4t7v9x2b5c0dnf",
"object": "agent",
"name": "Nada assistant",
"slug": "store-assistant",
"published_version": 1,
"has_unpublished_changes": false,
"readiness": { "ready": true, "blockers": [] },
"created_at": 1791271800
}

A one-shot ask needs no session: send a question, get the answer. Address the agent by its slug or its agt_… ID.

نافذة الطرفية
curl https://api.k-agent.kerneltics.com/v1/agents/store-assistant/ask \
-H "Authorization: Bearer $KAGENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input": "How much is delivery?"}'

The response is a run. output_text holds the answer; outcome tells you whether the agent answered or handed_off:

{
"id": "run_01k6rz5a9d3f6g2h8j4k7m1n5p",
"object": "run",
"agent": { "id": "agt_01k6rz1m3w8q4t7v9x2b5c0dnf", "version": 1 },
"session_id": null,
"mode": "one_shot",
"status": "completed",
"outcome": "answered",
"output_text": "Delivery is free on orders over SAR 200; below that, it's SAR 25.",
"handoff": null,
"error": null,
"usage": { "input_tokens": 1214, "cached_input_tokens": 0, "output_tokens": 17, "model_calls": 1, "units": 0.25, "weight": 1 },
"config_hash": "sha256:4be1c0d6…",
"created_at": 1791271860,
"completed_at": 1791271861
}

Sessions keep the conversation history. You can use our sess_… ID, or attach your own external_id — here, the customer’s order number order-8812. POST /v1/sessions is get-or-create: the first call creates the session (201), later calls with the same external_id resume it (200). Send input in the same call to add a message and get the reply.

نافذة الطرفية
curl https://api.k-agent.kerneltics.com/v1/sessions \
-H "Authorization: Bearer $KAGENT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"agent": "store-assistant", "external_id": "order-8812", "input": "Where is my order?"}'
{
"session": {
"id": "sess_01k6rz4p7h2c9m5x8w3t6v1qbg",
"object": "session",
"external_id": "order-8812",
"status": "active",
"mode": "agent",
"created_at": 1791271920
},
"created": true,
"message": { "id": "msg_01k6rz5b2c4d6e8f0g1h3j5k7m", "object": "message", "role": "user" },
"run": { "id": "run_01k6rz6c8e0g2j4m6p8r0t2v4x", "object": "run", "status": "completed", "outcome": "answered", "output_text": "Orders reach Riyadh, Jeddah and Dammam within 1 to 3 working days, and other cities within 3 to 5. Which city is your order going to?" },
"warnings": []
}

From now on, order-8812 and sess_01k6rz4p7h2c9m5x8w3t6v1qbg both address this session in every URL. The rules are spelled out in Sessions and session IDs.

Add "stream": true to receive the reply as Server-Sent Events while the model writes it. This message addresses the session by your external_id:

نافذة الطرفية
curl -N https://api.k-agent.kerneltics.com/v1/sessions/order-8812/messages \
-H "Authorization: Bearer $KAGENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input": "Can I return a perfume?", "stream": true}'

The stream looks like this. message.delta events are best-effort previews; message.completed and run.completed are authoritative:

id: 4182
event: run.created
data: {"run":{"id":"run_01k6rz7d9f1h3k5n7q9s1v3x5z","object":"run","status":"queued"}}
event: message.delta
data: {"message_id":"msg_01k6rz8e0h2k4n6q8s0v2x4z6b","delta":"Yes, within 7 days,"}
event: message.delta
data: {"message_id":"msg_01k6rz8e0h2k4n6q8s0v2x4z6b","delta":" as long as it's unopened and in its original packaging."}
id: 4185
event: message.completed
data: {"message":{"id":"msg_01k6rz8e0h2k4n6q8s0v2x4z6b","role":"assistant","content":[{"type":"text","text":"Yes, within 7 days, as long as it's unopened and in its original packaging."}]}}
id: 4186
event: run.completed
data: {"run":{"id":"run_01k6rz7d9f1h3k5n7q9s1v3x5z","object":"run","status":"completed","outcome":"answered"}}

Other events, such as tool calls, can appear in between. Ignore event types you don’t use; new ones may be added. If the connection drops, resume with the last id you saw — see Runs and streaming.