Invoke with Session
Invoke an agent with context from a session.
Request Body
Session ID for context. If omitted, creates ephemeral invocation.
Context selection options
Specific block IDs to include
Include blocks with these tags
Exclude blocks with these tags
Always include pinned blocks
Enrichment mode: none, manual, auto
Enrichment configurationShow enrichmentConfig properties
enrichmentConfig.includePreferences
Include learned user preferences
enrichmentConfig.recencyBias
Prefer recent context (0-1)
enrichmentConfig.maxTokens
Max tokens for enrichment
Enable streaming response
Save conversation to session
curl -X POST https://api.runtools.ai/v1/aip/invoke \
-H "X-API-Key: rt_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"agent": "code-assistant",
"prompt": "Continue the auth implementation we discussed",
"session": "sess_abc123",
"context": {
"includeByTag": ["authentication"],
"maxTokens": 50000
},
"enrichment": "auto",
"stream": true
}'
{
"data": {
"id": "inv_abc123",
"status": "completed",
"output": "I've continued the auth implementation...",
"agent": "code-assistant",
"session": "sess_abc123",
"blocksCreated": ["blk_new001", "blk_new002"],
"usage": {
"contextTokens": 45000,
"inputTokens": 46200,
"outputTokens": 1850
}
}
}
Streaming Response
When stream: true, response is Server-Sent Events:
event: start
data: {"invocationId": "inv_abc123", "agent": "code-assistant"}
event: context_assembled
data: {"tokenCount": 45000, "blocksIncluded": 12}
event: thinking
data: {"content": "Looking at the auth implementation..."}
event: text_delta
data: {"content": "Based on our previous discussion"}
event: text_delta
data: {"content": " about JWT tokens, I'll continue..."}
event: tool_call
data: {"tool": "edit_file", "input": {"path": "/src/auth.ts"}}
event: tool_result
data: {"output": "File updated"}
event: complete
data: {"output": "Done!", "blocksCreated": ["blk_new001"], "usage": {...}}
Event Types
| Event | Description |
|---|
start | Invocation started |
context_assembled | Context selected and assembled |
thinking | Agent thinking/reasoning |
text_delta | Text chunk |
tool_call | Tool being called |
tool_result | Tool execution result |
file_edit | File was edited |
dev_url | Dev server URL available |
complete | Invocation finished |
error | Error occurred |
AIP-Compatible Endpoint
Standard AIP protocol endpoint for cross-platform compatibility.
Request Body
Same as /v1/aip/invoke but follows AIP specification format:
{
"aip_version": "0.1.0",
"prompt": {
"content": "Build a landing page",
"attachments": []
},
"context": {
"session_id": "sess_abc123",
"include_by_tag": ["relevant"]
},
"options": {
"stream": true,
"save_to_session": true
}
}
curl -X POST https://api.runtools.ai/.well-known/aip/invoke \
-H "X-API-Key: rt_live_xxx" \
-H "X-AIP-Agent: code-assistant" \
-H "Content-Type: application/json" \
-d '{
"aip_version": "0.1.0",
"prompt": { "content": "Build a landing page" },
"context": { "session_id": "sess_abc123" }
}'
The /.well-known/aip/invoke endpoint follows the open AIP specification for interoperability with other AIP-compatible platforms.