Chat
curl --request POST \
--url https://composer.personal.ai/lab/api/v1/op/agent.chat \
--header 'Content-Type: <content-type>' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"agent_slug": "<string>",
"conversation_id": "<string>",
"message": "<string>",
"timezone": "<string>",
"channel": "<string>",
"attachments": [
{}
],
"as_subject": true
}
'import requests
url = "https://composer.personal.ai/lab/api/v1/op/agent.chat"
payload = {
"agent_slug": "<string>",
"conversation_id": "<string>",
"message": "<string>",
"timezone": "<string>",
"channel": "<string>",
"attachments": [{}],
"as_subject": True
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': '<content-type>'},
body: JSON.stringify({
agent_slug: '<string>',
conversation_id: '<string>',
message: '<string>',
timezone: '<string>',
channel: '<string>',
attachments: [{}],
as_subject: true
})
};
fetch('https://composer.personal.ai/lab/api/v1/op/agent.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://composer.personal.ai/lab/api/v1/op/agent.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_slug' => '<string>',
'conversation_id' => '<string>',
'message' => '<string>',
'timezone' => '<string>',
'channel' => '<string>',
'attachments' => [
[
]
],
'as_subject' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: <content-type>",
"x-api-key: <x-api-key>"
],
]);
$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://composer.personal.ai/lab/api/v1/op/agent.chat"
payload := strings.NewReader("{\n \"agent_slug\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"message\": \"<string>\",\n \"timezone\": \"<string>\",\n \"channel\": \"<string>\",\n \"attachments\": [\n {}\n ],\n \"as_subject\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://composer.personal.ai/lab/api/v1/op/agent.chat")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "<content-type>")
.body("{\n \"agent_slug\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"message\": \"<string>\",\n \"timezone\": \"<string>\",\n \"channel\": \"<string>\",\n \"attachments\": [\n {}\n ],\n \"as_subject\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://composer.personal.ai/lab/api/v1/op/agent.chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"agent_slug\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"message\": \"<string>\",\n \"timezone\": \"<string>\",\n \"channel\": \"<string>\",\n \"attachments\": [\n {}\n ],\n \"as_subject\": true\n}"
response = http.request(request)
puts response.read_body{
"response": "<string>",
"conversation_id": "<string>",
"run_id": "<string>",
"graphics": [
{}
],
"places": [
{}
],
"goal": {}
}Agents & Chat
Chat
Send a message to an assistant and get its reply
POST
/
lab
/
api
/
v1
/
op
/
agent.chat
Chat
curl --request POST \
--url https://composer.personal.ai/lab/api/v1/op/agent.chat \
--header 'Content-Type: <content-type>' \
--header 'x-api-key: <x-api-key>' \
--data '
{
"agent_slug": "<string>",
"conversation_id": "<string>",
"message": "<string>",
"timezone": "<string>",
"channel": "<string>",
"attachments": [
{}
],
"as_subject": true
}
'import requests
url = "https://composer.personal.ai/lab/api/v1/op/agent.chat"
payload = {
"agent_slug": "<string>",
"conversation_id": "<string>",
"message": "<string>",
"timezone": "<string>",
"channel": "<string>",
"attachments": [{}],
"as_subject": True
}
headers = {
"x-api-key": "<x-api-key>",
"Content-Type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<x-api-key>', 'Content-Type': '<content-type>'},
body: JSON.stringify({
agent_slug: '<string>',
conversation_id: '<string>',
message: '<string>',
timezone: '<string>',
channel: '<string>',
attachments: [{}],
as_subject: true
})
};
fetch('https://composer.personal.ai/lab/api/v1/op/agent.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://composer.personal.ai/lab/api/v1/op/agent.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_slug' => '<string>',
'conversation_id' => '<string>',
'message' => '<string>',
'timezone' => '<string>',
'channel' => '<string>',
'attachments' => [
[
]
],
'as_subject' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: <content-type>",
"x-api-key: <x-api-key>"
],
]);
$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://composer.personal.ai/lab/api/v1/op/agent.chat"
payload := strings.NewReader("{\n \"agent_slug\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"message\": \"<string>\",\n \"timezone\": \"<string>\",\n \"channel\": \"<string>\",\n \"attachments\": [\n {}\n ],\n \"as_subject\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<x-api-key>")
req.Header.Add("Content-Type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://composer.personal.ai/lab/api/v1/op/agent.chat")
.header("x-api-key", "<x-api-key>")
.header("Content-Type", "<content-type>")
.body("{\n \"agent_slug\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"message\": \"<string>\",\n \"timezone\": \"<string>\",\n \"channel\": \"<string>\",\n \"attachments\": [\n {}\n ],\n \"as_subject\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://composer.personal.ai/lab/api/v1/op/agent.chat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<x-api-key>'
request["Content-Type"] = '<content-type>'
request.body = "{\n \"agent_slug\": \"<string>\",\n \"conversation_id\": \"<string>\",\n \"message\": \"<string>\",\n \"timezone\": \"<string>\",\n \"channel\": \"<string>\",\n \"attachments\": [\n {}\n ],\n \"as_subject\": true\n}"
response = http.request(request)
puts response.read_body{
"response": "<string>",
"conversation_id": "<string>",
"run_id": "<string>",
"graphics": [
{}
],
"places": [
{}
],
"goal": {}
}Overview
Sends one message to an assistant in a conversation and returns the reply once it is complete. To receive the reply as it is written, use Chat (Streaming). The reply’sconversation_id can differ from the one you sent, for example when your message continues something the assistant is already arranging with you. Send follow-up messages to the returned conversation_id.
Operation name: agent.chat. Member keys can call it.
Authorization
Headers
Body
The conversation, from Create Conversation.
Example
"conversation_id": "9a2b7c1e-4d3f-4e8a-b6c5-1f0e2d3c4b5a"
Your IANA time zone, for example
America/New_York. Send it on every message so “today” and “tomorrow” mean your day.Example
"timezone": "America/New_York"
The surface the message comes from, such as
sms. It shapes the reply (plain and short for a text, markdown on the web). Omit for a web chat.Files attached to this message:
[{ filename, excerpt }], where excerpt is the file’s text (for example from Ingest File with excerpt_chars).Admin only. Set to true to speak as the person a conversation belongs to, when that person isn’t you. Default false.
Example Request
{
"agent_slug": "my-assistant",
"conversation_id": "9a2b7c1e-4d3f-4e8a-b6c5-1f0e2d3c4b5a",
"message": "What's on tomorrow?",
"timezone": "America/New_York"
}
Response
Example Success Response
{
"response": "Tomorrow you have the dentist at 9:30 and Emma's swimming at 4pm.",
"conversation_id": "9a2b7c1e-4d3f-4e8a-b6c5-1f0e2d3c4b5a",
"run_id": "3f8e2a1b-7c6d-4e5f-9a8b-0c1d2e3f4a5b",
"graphics": [],
"places": []
}
Example cURL
cURL
curl --request POST 'https://composer.personal.ai/lab/api/v1/op/agent.chat' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <your-api-key>' \
--data '{"agent_slug": "my-assistant", "conversation_id": "9a2b7c1e-4d3f-4e8a-b6c5-1f0e2d3c4b5a", "message": "What'\''s on tomorrow?", "timezone": "America/New_York"}'
Error Codes
| Code | Description |
|---|---|
| 400 | The body doesn’t match the fields above, or the operation failed. The response body says why. |
| 401 | Missing or invalid API key |
| 403 | This key isn’t allowed to call this operation |