#Quickstart
In about five minutes you will create an API key for an agent, send it a message, continue the conversation and stream a reply.
{BASE_URL} = https://studio.scaletechsolutions.ai/api/v1#Before you start
You need an AI Studio account (sign up or sign in) and an agent you own or were given access to. Build one with Kage in the app, or start from a template. You will need its id (a number).
#1. Create an API key
In the AI Studio app, create an API key for the agent. Give it a name that says where it will be used, for example Support site (production).
Copy the key now. It looks like ai_labs_3f9c... and is shown only once: AI Studio keeps only a hash of it. Keep it on your server, in an environment variable or a secret manager:
export AI_STUDIO_AGENT_KEY="ai_labs_..."#2. Send a message
curl -X POST "{BASE_URL}/public/agents/42/chat" \
-H "Authorization: Bearer $AI_STUDIO_AGENT_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Hi! What can you help me with?"}'Without a session_id, each message starts a new conversation (a session). Keep the returned session_id to continue it.
#3. Continue the conversation
Send the session_id back, and the agent remembers everything said in that session:
curl -X POST "{BASE_URL}/public/agents/42/chat" \
-H "Authorization: Bearer $AI_STUDIO_AGENT_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "And what are your opening hours?", "session_id": 1187}'A session belongs to the key that created it: another key, even for the same agent, gets a 404. Use one session per end user and conversation. To show a conversation again later, read its history.
Optional fields that make replies better:
| Field | Example | Effect |
|---|---|---|
timezone | "Asia/Kolkata" | The agent knows the user's local date and time. |
location | "Ahmedabad, India" | Free text, used together with timezone. |
context | {"customer_id": "C-91", "plan": "pro"} | Facts from your server for this message only. Not saved in the history; send it with every message that needs it. |
#4. Stream the reply
A turn that uses tools can take a while. Stream it to show text as it is written and progress as the agent works:
curl -N -X POST "{BASE_URL}/public/agents/42/stream" \
-H "Authorization: Bearer $AI_STUDIO_AGENT_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Summarise my last three orders", "session_id": 1187}'The response is a stream of server-sent events, one JSON object per data: line. The first is always session; then text pieces of the reply, tool_start and tool_end as the agent uses tools, and others such as file, image and sources. There is no final "done" event: the stream closes when the turn is over. If something goes wrong you get an error event with a code.
Every event type and full Node.js and Python readers are in Stream a reply.
#5. Handle errors
| Status | What happened | What to do |
|---|---|---|
| 401 | Missing, wrong or revoked key | Check the Authorization: Bearer header and the key. |
| 403 | The key belongs to another agent | Use the key created for this agent. |
| 404 | Agent or session not found | Check the ids; a session only works with the key that created it. |
| 402 | A spending limit is reached | Try again after the limit resets; the owner can raise it. |
| 500 | The run failed | Retry; if it persists, report the time, agent id and session id. |
All codes: Errors and limits.
#Next steps
- Agents API: every endpoint, field and stream event.
- Knowledge base API: keep the agent's knowledge base up to date from your systems.
- Webhooks and triggers: start an agent or workflow when something happens on your side.