curl --request POST \
--url https://api.example.com/chat/ \
--header 'Content-Type: application/json' \
--header 'x-user-id: <x-user-id>' \
--data '
{
"agent_id": "<string>",
"session_id": "<string>",
"input": {
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>"
}
],
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"finished_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123
}
}
}
'import requests
url = "https://api.example.com/chat/"
payload = {
"agent_id": "<string>",
"session_id": "<string>",
"input": {
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>"
}
],
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"finished_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123
}
}
}
headers = {
"x-user-id": "<x-user-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-user-id': '<x-user-id>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agent_id: '<string>',
session_id: '<string>',
input: {
name: '<string>',
content: [{text: '<string>', type: 'text', id: '<string>'}],
id: '<string>',
metadata: {},
created_at: '<string>',
finished_at: '<string>',
usage: {input_tokens: 123, output_tokens: 123}
}
})
};
fetch('https://api.example.com/chat/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/chat/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'agent_id' => '<string>',
'session_id' => '<string>',
'input' => [
'name' => '<string>',
'content' => [
[
'text' => '<string>',
'type' => 'text',
'id' => '<string>'
]
],
'id' => '<string>',
'metadata' => [
],
'created_at' => '<string>',
'finished_at' => '<string>',
'usage' => [
'input_tokens' => 123,
'output_tokens' => 123
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-user-id: <x-user-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/chat/"
payload := strings.NewReader("{\n \"agent_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"input\": {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-user-id", "<x-user-id>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/chat/")
.header("x-user-id", "<x-user-id>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"input\": {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/chat/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-user-id"] = '<x-user-id>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agent_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"input\": {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"session_id": "<string>",
"status": "started"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Trigger a chat run (fire-and-forget)
Trigger a chat run for the specified session.
The run executes as a background task. Events produced during the
run are published to the message bus and delivered to any active
GET /sessions/{session_id}/stream SSE subscriber. The caller
does not receive events from this endpoint’s response body.
Accepts the same input payloads as before:
Msg/list[Msg]: new user message(s).UserConfirmResultEvent/ExternalExecutionResultEvent: resume a paused tool call (human-in-the-loop).None: continue from current state.
Args:
request (ChatRequest):
JSON body with agent_id, session_id, and input.
user_id (str):
Injected user id.
chat_service (ChatService):
Injected application-wide chat service.
Returns:
ChatTriggerResponse:
Confirms the run was scheduled.
curl --request POST \
--url https://api.example.com/chat/ \
--header 'Content-Type: application/json' \
--header 'x-user-id: <x-user-id>' \
--data '
{
"agent_id": "<string>",
"session_id": "<string>",
"input": {
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>"
}
],
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"finished_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123
}
}
}
'import requests
url = "https://api.example.com/chat/"
payload = {
"agent_id": "<string>",
"session_id": "<string>",
"input": {
"name": "<string>",
"content": [
{
"text": "<string>",
"type": "text",
"id": "<string>"
}
],
"id": "<string>",
"metadata": {},
"created_at": "<string>",
"finished_at": "<string>",
"usage": {
"input_tokens": 123,
"output_tokens": 123
}
}
}
headers = {
"x-user-id": "<x-user-id>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-user-id': '<x-user-id>', 'Content-Type': 'application/json'},
body: JSON.stringify({
agent_id: '<string>',
session_id: '<string>',
input: {
name: '<string>',
content: [{text: '<string>', type: 'text', id: '<string>'}],
id: '<string>',
metadata: {},
created_at: '<string>',
finished_at: '<string>',
usage: {input_tokens: 123, output_tokens: 123}
}
})
};
fetch('https://api.example.com/chat/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/chat/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'agent_id' => '<string>',
'session_id' => '<string>',
'input' => [
'name' => '<string>',
'content' => [
[
'text' => '<string>',
'type' => 'text',
'id' => '<string>'
]
],
'id' => '<string>',
'metadata' => [
],
'created_at' => '<string>',
'finished_at' => '<string>',
'usage' => [
'input_tokens' => 123,
'output_tokens' => 123
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-user-id: <x-user-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/chat/"
payload := strings.NewReader("{\n \"agent_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"input\": {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-user-id", "<x-user-id>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/chat/")
.header("x-user-id", "<x-user-id>")
.header("Content-Type", "application/json")
.body("{\n \"agent_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"input\": {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/chat/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-user-id"] = '<x-user-id>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agent_id\": \"<string>\",\n \"session_id\": \"<string>\",\n \"input\": {\n \"name\": \"<string>\",\n \"content\": [\n {\n \"text\": \"<string>\",\n \"type\": \"text\",\n \"id\": \"<string>\"\n }\n ],\n \"id\": \"<string>\",\n \"metadata\": {},\n \"created_at\": \"<string>\",\n \"finished_at\": \"<string>\",\n \"usage\": {\n \"input_tokens\": 123,\n \"output_tokens\": 123\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"session_id": "<string>",
"status": "started"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Headers
Body
Request body for the chat endpoint.
Response
Successful Response
Response body for the fire-and-forget chat trigger.
Confirms that the chat run was scheduled. Events produced by the run arrive separately via the session's SSE stream endpoint.