curl --request POST \
--url http://127.0.0.1:8400/v1/sessions/{id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": "<string>",
"metadata": {}
}
'import requests
url = "http://127.0.0.1:8400/v1/sessions/{id}/messages"
payload = {
"content": "<string>",
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({content: '<string>', metadata: {}})
};
fetch('http://127.0.0.1:8400/v1/sessions/{id}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8400",
CURLOPT_URL => "http://127.0.0.1:8400/v1/sessions/{id}/messages",
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([
'content' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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 := "http://127.0.0.1:8400/v1/sessions/{id}/messages"
payload := strings.NewReader("{\n \"content\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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("http://127.0.0.1:8400/v1/sessions/{id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://127.0.0.1:8400/v1/sessions/{id}/messages")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "event",
"session_id": "<string>",
"seq": 123,
"type": "message",
"data": {
"role": "user",
"content": "<string>"
},
"created_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "model_not_mapped",
"tool": "<string>",
"clashes_with": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "model_not_mapped",
"tool": "<string>",
"clashes_with": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "model_not_mapped",
"tool": "<string>",
"clashes_with": "<string>"
}
}Send a user message
Adds a user turn and starts the agent loop. Returns at once with the
event that was stored. Follow progress on the events stream. A model-only
turn needs no worker. A turn that calls a tool waits until a worker
for the environment is attached; the session shows waiting_for_worker.
Returns 409 session_busy if a turn is already running, and 409
session_archived for an archived session. The agent’s model is checked
against the server’s model map again here (it may have changed since the
session was made): an unmapped model is 422 model_not_mapped, with no
outbound request. While the agent loop is starting or cannot run, or while
this replica is stopping, the answer is 503 agent_loop_unavailable (send
the message again; another replica takes it); a server built without an agent
loop answers 501 not_implemented. In those cases nothing is stored.
If a custom tool of the agent has the same name as a built-in tool or an
MCP tool, the answer is 409 custom_tool_conflict: nothing is stored and
the session status is unchanged.
A turn that fails later ends with an error event and status error. If the replica running the turn stops, the event code is server_restarted: send the message again.
curl --request POST \
--url http://127.0.0.1:8400/v1/sessions/{id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"content": "<string>",
"metadata": {}
}
'import requests
url = "http://127.0.0.1:8400/v1/sessions/{id}/messages"
payload = {
"content": "<string>",
"metadata": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({content: '<string>', metadata: {}})
};
fetch('http://127.0.0.1:8400/v1/sessions/{id}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8400",
CURLOPT_URL => "http://127.0.0.1:8400/v1/sessions/{id}/messages",
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([
'content' => '<string>',
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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 := "http://127.0.0.1:8400/v1/sessions/{id}/messages"
payload := strings.NewReader("{\n \"content\": \"<string>\",\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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("http://127.0.0.1:8400/v1/sessions/{id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"content\": \"<string>\",\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://127.0.0.1:8400/v1/sessions/{id}/messages")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"content\": \"<string>\",\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "event",
"session_id": "<string>",
"seq": 123,
"type": "message",
"data": {
"role": "user",
"content": "<string>"
},
"created_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "model_not_mapped",
"tool": "<string>",
"clashes_with": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "model_not_mapped",
"tool": "<string>",
"clashes_with": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "model_not_mapped",
"tool": "<string>",
"clashes_with": "<string>"
}
}Headers
Up to 255 characters. The key is scoped to the calling principal, the HTTP
method, the path and the key. Only 2xx responses are stored, for 24 hours.
The same key with the same body replays the stored response, with the
response header Idempotency-Replayed: true. The same key with a different
body is 422 idempotency_key_reuse. If the first request is still running,
the answer is 409 idempotency_in_progress; a record in progress for more
than 60 seconds is taken over by the new request. A key that is longer than
255 characters or not printable ASCII is 400 invalid_idempotency_key.
255Response
Accepted. The stored user message event.