This API endpoint allows users to run and query an agent with streaming response. Also supports resuming interrupted executions by providing execution_state_id.
Input:
sessionId(str): The session ID for the agent interaction.traceparent(str, optional): W3C Trace Context header for distributed tracing.chat_request: (AgentChatRequest) Input payload to start and query an agent or resume execution.- For new execution: provide agent_id and message
- For resuming: provide execution_state_id (and optionally approval_response)
Output: The response contains a streaming response of the user query or resumed execution.
sessionId
String
required
The session ID for the agent interaction.
The session ID for the agent interaction.
7926a636-2fb6-4a0d-96a6-31da00359b02
traceparent
String
W3C Trace Context header for distributed tracing.
W3C Trace Context header for distributed tracing.
00-47b4b549217cde861fb60fe0c276a29b-f39e92d2c8619ae9-01
curl -X 'POST'
-H "Authorization: Bearer [[accessToken]]" \
-H
'Accept: text/event-stream,application/json'
-H
'Content-Type: application/json'
-H
'sessionId: 7926a636-2fb6-4a0d-96a6-31da00359b02'
-H
'traceparent: 00-47b4b549217cde861fb60fe0c276a29b-f39e92d2c8619ae9-01'
'http://localhost/public/api/v1/run_agent_stream'
-d
'{
"time_machine_timestamp" : "time_machine_timestamp",
"debug_mode" : true,
"agent_id" : "agent_id",
"message" : "message",
"execution_state_id" : "execution_state_id",
"approval_response" : {
"key" : ""
}
}'
import http.client
conn = http.client.HTTPConnection("undefinedundefined")
payload = "{\"agent_id\":\"string\",\"message\":\"string\",\"execution_state_id\":\"string\",\"approval_response\":{},\"time_machine_timestamp\":\"string\",\"debug_mode\":true}"
headers = {
'sessionId': "7926a636-2fb6-4a0d-96a6-31da00359b02",
'traceparent': "00-47b4b549217cde861fb60fe0c276a29b-f39e92d2c8619ae9-01",
'Authorization': "Bearer REPLACE_BEARER_TOKEN",
'content-type': "application/json"
}
conn.request("POST", "/public/api/v1/run_agent_stream", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))require 'uri'
require 'net/http'
url = URI("http://undefinedundefined/public/api/v1/run_agent_stream")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["sessionId"] = '7926a636-2fb6-4a0d-96a6-31da00359b02'
request["traceparent"] = '00-47b4b549217cde861fb60fe0c276a29b-f39e92d2c8619ae9-01'
request["Authorization"] = 'Bearer REPLACE_BEARER_TOKEN'
request["content-type"] = 'application/json'
request.body = "{\"agent_id\":\"string\",\"message\":\"string\",\"execution_state_id\":\"string\",\"approval_response\":{},\"time_machine_timestamp\":\"string\",\"debug_mode\":true}"
response = http.request(request)
puts response.read_bodyconst data = JSON.stringify({
"agent_id": "string",
"message": "string",
"execution_state_id": "string",
"approval_response": {},
"time_machine_timestamp": "string",
"debug_mode": true
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "http://undefinedundefined/public/api/v1/run_agent_stream");
xhr.setRequestHeader("sessionId", "7926a636-2fb6-4a0d-96a6-31da00359b02");
xhr.setRequestHeader("traceparent", "00-47b4b549217cde861fb60fe0c276a29b-f39e92d2c8619ae9-01");
xhr.setRequestHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);HttpResponse<String> response = Unirest.post("http://undefinedundefined/public/api/v1/run_agent_stream")
.header("sessionId", "7926a636-2fb6-4a0d-96a6-31da00359b02")
.header("traceparent", "00-47b4b549217cde861fb60fe0c276a29b-f39e92d2c8619ae9-01")
.header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
.header("content-type", "application/json")
.body("{\"agent_id\":\"string\",\"message\":\"string\",\"execution_state_id\":\"string\",\"approval_response\":{},\"time_machine_timestamp\":\"string\",\"debug_mode\":true}")
.asString();import Foundation
let headers = [
"sessionId": "7926a636-2fb6-4a0d-96a6-31da00359b02",
"traceparent": "00-47b4b549217cde861fb60fe0c276a29b-f39e92d2c8619ae9-01",
"Authorization": "Bearer REPLACE_BEARER_TOKEN",
"content-type": "application/json"
]
let parameters = [
"agent_id": "string",
"message": "string",
"execution_state_id": "string",
"approval_response": [],
"time_machine_timestamp": "string",
"debug_mode": true
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "http://undefinedundefined/public/api/v1/run_agent_stream")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "http://undefinedundefined/public/api/v1/run_agent_stream",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\"agent_id\":\"string\",\"message\":\"string\",\"execution_state_id\":\"string\",\"approval_response\":{},\"time_machine_timestamp\":\"string\",\"debug_mode\":true}",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer REPLACE_BEARER_TOKEN",
"content-type: application/json",
"sessionId: 7926a636-2fb6-4a0d-96a6-31da00359b02",
"traceparent: 00-47b4b549217cde861fb60fe0c276a29b-f39e92d2c8619ae9-01"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "http://undefinedundefined/public/api/v1/run_agent_stream");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "sessionId: 7926a636-2fb6-4a0d-96a6-31da00359b02");
headers = curl_slist_append(headers, "traceparent: 00-47b4b549217cde861fb60fe0c276a29b-f39e92d2c8619ae9-01");
headers = curl_slist_append(headers, "Authorization: Bearer REPLACE_BEARER_TOKEN");
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"agent_id\":\"string\",\"message\":\"string\",\"execution_state_id\":\"string\",\"approval_response\":{},\"time_machine_timestamp\":\"string\",\"debug_mode\":true}");
CURLcode ret = curl_easy_perform(hnd);var client = new RestClient("http://undefinedundefined/public/api/v1/run_agent_stream");
var request = new RestRequest(Method.POST);
request.AddHeader("sessionId", "7926a636-2fb6-4a0d-96a6-31da00359b02");
request.AddHeader("traceparent", "00-47b4b549217cde861fb60fe0c276a29b-f39e92d2c8619ae9-01");
request.AddHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"agent_id\":\"string\",\"message\":\"string\",\"execution_state_id\":\"string\",\"approval_response\":{},\"time_machine_timestamp\":\"string\",\"debug_mode\":true}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);Request payload for starting or resuming an agent chat interaction.
agent_idstringrequiredID of the agent
ID of the agent
messagestringrequiredMessage to send to the agent
Message to send to the agent
execution_state_idobjectID of the execution state to resume (optional for resume functionality)
ID of the execution state to resume (optional for resume functionality)
stringID of the execution state to resume (optional for resume functionality)
ID of the execution state to resume (optional for resume functionality)
approval_responseobjectResponse for pending approvals when resuming execution (optional)
Response for pending approvals when resuming execution (optional)
time_machine_timestampobjectTimestamp to run the time machine agent at a specific point in time (optional)
Timestamp to run the time machine agent at a specific point in time (optional)
stringTimestamp to run the time machine agent at a specific point in time (optional)
Timestamp to run the time machine agent at a specific point in time (optional)
debug_modeobjectFlag to enable debug mode for detailed LLM logging (optional)
Flag to enable debug mode for detailed LLM logging (optional)
booleanFlag to enable debug mode for detailed LLM logging (optional)
Flag to enable debug mode for detailed LLM logging (optional)
{
"agent_id": "example",
"message": "example",
"execution_state_id": null,
"approval_response": null,
"time_machine_timestamp": null,
"debug_mode": null
}