Agent API
Two ways to call your EvoStudio agent from outside the browser — install the Agent package for a conversational experience inside your own AI engine, or call the REST API directly from any app or script.
Use via the Agent package
The Chraft Agent Caller is a ready-made agent workspace you can install directly into your EvoStudio instance. Once installed, you can chat with it in plain language — tell it what to ask your agent, it builds the API call, streams the reply back, and manages multi-turn sessions automatically.
skill-chraft-agent-caller
SkillClaude / Cursor Skill Package · v20260426-1 · SKILL.md format
Or paste this prompt into your Claude Code / Cursor chat — it will download, unzip, and place the skill in the right folder for you:
Install the Chraft Agent Caller skill for me. Download the zip from https://cdn.chraft.ai/skills/skill-chraft-agent-caller-20260426-1.zip, unzip it, and move the chraft-agent-caller folder into ~/.claude/skills/ (Claude Code) or .cursor/skills/ in this project (Cursor). Then verify the SKILL.md is in place.Manual install: unzip into ~/.claude/skills/ (Claude Code) or your project's .cursor/skills/ folder (Cursor). The skill auto-loads on relevant prompts — no install command needed.
workspace-chraft-agent-caller
Chraft Agent Package · v20260426-1 · 10 KB
Paste this into your EvoStudio chat to install in one shot — it points to the latest signed CDN URL:
install agent https://cdn.chraft.ai/agents/workspace-chraft-agent-caller-20260426-1.zipOr download the zip and drag-and-drop it into the EvoStudio chat window.
Setup — API key required
This agent requires an External API key to function.
The agent calls Chraft's REST API on your behalf. Without a valid sk-oc-* key it will return a 401 error on every request.
- 1Go to EvoStudio → Instance and scroll to External API Keys.
- 2Click Create Key — copy the
sk-oc-…key immediately (it is shown only once). - 3Install the agent package, then in the first message provide your key and base URL:
My API key is sk-oc-abc123... and my app URL is https://chraft.aiThe agent saves both to session memory and reuses them for every subsequent call.
What the agent can do
| Capability | Description |
|---|---|
| Single-turn call | Send a message, get the full reply in one go |
| Streaming call | Stream the reply token-by-token as it arrives (default) |
| Multi-turn sessions | Persist sessionKey across turns for conversation continuity |
| Error diagnosis | 401 / 402 / 503 explained in plain language with recovery steps |
| Session reset | Say "new session" to start a fresh conversation |
Use via the REST API
Call the API directly from any app, script, or backend. Two endpoints — one for a single JSON response, one for real-time streaming.
Prerequisites
1. A running EvoStudio instance — Deploy one from the Instance page.
2. An API key — Create one in the External API Keys panel. Keys look like sk-oc-… and are shown only once at creation.
Authentication
Include your API key as a Bearer token in every request:
Authorization: Bearer sk-oc-<your-key>POST /api/evostudio/chat — single response
Send a message and receive the complete reply in one JSON response. Best for scripts and server-side calls.
Request body
{
"message": "string (required)",
"sessionKey": "string (optional) — omit to start a fresh session",
"history": [
{ "role": "user" | "assistant" | "system", "content": "string" }
]
}Success response 200
{
"success": true,
"reply": "The agent's text response",
"sessionKey": "your-session-key-or-null",
"usage": {
"prompt_tokens": 120,
"completion_tokens": 45,
"total_tokens": 165
}
}Error responses
| Status | error | Cause |
|---|---|---|
| 400 | message is required | Missing or empty message |
| 401 | Unauthorized | Missing, invalid, or expired API key |
| 402 | Insufficient credits | Credit balance too low |
| 503 | EvoStudio instance not configured | Instance not running |
Example — curl
curl -X POST https://your-app.com/api/evostudio/chat \
-H "Authorization: Bearer sk-oc-abc123..." \
-H "Content-Type: application/json" \
-d '{"message": "Hello, what can you do?", "sessionKey": "sess-001"}'Example — Node.js
const res = await fetch('/api/evostudio/chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-oc-abc123...',
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: 'Hello!', sessionKey: 'sess-001' }),
});
const { reply } = await res.json();Example — Python
import requests
resp = requests.post(
"https://your-app.com/api/evostudio/chat",
headers={"Authorization": "Bearer sk-oc-abc123..."},
json={"message": "Hello!", "sessionKey": "sess-001"},
)
print(resp.json()["reply"])POST /api/evostudio/chat/stream — SSE streaming
Same request body as above. Returns a text/event-stream response that streams tokens as they arrive.
Event types
| Event | Payload | Description |
|---|---|---|
| delta | {"text": "…"} | Partial text chunk |
| done | {"text": "…", "sessionKey": "…", "usage": {…}} | Full reply + session info |
| error | {"error": "…"} | Error — stream closed immediately after |
Example — curl
curl -N -X POST https://your-app.com/api/evostudio/chat/stream \
-H "Authorization: Bearer sk-oc-abc123..." \
-H "Content-Type: application/json" \
-d '{"message": "Write a haiku about AI"}'Example — browser fetch
const res = await fetch('/api/evostudio/chat/stream', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-oc-abc123...',
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: 'Tell me a story' }),
});
const reader = res.body!.getReader();
const decoder = new TextDecoder();
let buffer = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const lines = buffer.split('\n');
buffer = lines.pop() ?? '';
let event = '';
for (const line of lines) {
if (line.startsWith('event:')) event = line.slice(6).trim();
else if (line.startsWith('data:')) {
const payload = JSON.parse(line.slice(5).trim());
if (event === 'delta') process.stdout.write(payload.text);
}
}
}Session management
Pass the same sessionKey across multiple requests to maintain conversation context. Omit it (or use a new value) to start a fresh session. Sessions are scoped to the workspace that owns the API key.
Which endpoint to use?
| Use case | Endpoint |
|---|---|
| Server-side script / automation | /api/evostudio/chat |
| Simple one-shot queries | /api/evostudio/chat |
| Real-time UI showing tokens as they arrive | /api/evostudio/chat/stream |
| Long-running generation tasks | /api/evostudio/chat/stream |