Get started

#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:

FieldExampleEffect
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.

Your server AI Studio Agent and tools POST /stream {message, session_id} run one turn data: {"type":"session"} tool_start {tool, input} tool call tool_end {tool} sources {knowledge_base_id, sources} text {content} text {content} (repeats) No "done" event: the server closes the response when the turn is over. On failure the last event is "error"
Events arrive as server-sent events. Only session, text and error are needed for a working chat.

Every event type and full Node.js and Python readers are in Stream a reply.

#5. Handle errors

StatusWhat happenedWhat to do
401Missing, wrong or revoked keyCheck the Authorization: Bearer header and the key.
403The key belongs to another agentUse the key created for this agent.
404Agent or session not foundCheck the ids; a session only works with the key that created it.
402A spending limit is reachedTry again after the limit resets; the owner can raise it.
500The run failedRetry; if it persists, report the time, agent id and session id.

All codes: Errors and limits.

#Next steps

AI Studio developer documentation. Times are UTC and IDs are opaque strings.