Adds a user message to an ongoing chat, runs one agent turn and returns the new items. The agent can call tools and, on a conversation flow, move between nodes during the turn.
With a public key, only chats started with that same key can be continued.
Request#
Body#
| Field | Type | Required | Description |
|---|---|---|---|
chat_id |
string | Yes | An ongoing chat. |
content |
string | Yes | The user's message. Only the first 8000 characters are kept. |
Example request#
curl -X POST "https://api.tried.com.au/create-chat-completion" \
-H "Authorization: Bearer $TRIED_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chat_id": "chat_0a1b2c3d4e5f6a7b8c9d0e1f",
"content": "Can I move my booking to Friday?"
}'const res = await fetch("https://api.tried.com.au/create-chat-completion", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.TRIED_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"chat_id": "chat_0a1b2c3d4e5f6a7b8c9d0e1f",
"content": "Can I move my booking to Friday?"
}),
});
const data = await res.json();import os, requests
res = requests.post(
"https://api.tried.com.au/create-chat-completion",
headers={"Authorization": f"Bearer {os.environ['TRIED_API_KEY']}"},
json={
"chat_id": "chat_0a1b2c3d4e5f6a7b8c9d0e1f",
"content": "Can I move my booking to Friday?",
},
)
data = res.json()Response#
200 OK
{
"messages": [
{ "role": "tool_call_invocation", "tool_call_id": "call_tool_1", "name": "check_availability", "arguments": "{\"day\":\"Friday\"}", "created_timestamp": 1792310460100 },
{ "role": "agent", "content": "Friday at 10 am or 3 pm are free. Which suits you?", "created_timestamp": 1792310461200 }
],
"chat": { "chat_id": "chat_0a1b2c3d4e5f6a7b8c9d0e1f", "chat_status": "ongoing", "chat_cost": { "combined_cost": 0.006 } }
}| Field | Type | Description |
|---|---|---|
messages |
array | Items produced in this turn, in the message item shape. The user message is not repeated. |
chat |
object | The updated chat object (shortened above). |
Errors#
| Status | When |
|---|---|
400 |
Validation failed, the chat has ended, or content is empty. |
401 |
Missing or invalid API key, or a public key sent from an Origin not in its allowed domains. |
402 |
Credit exhausted, budget reached or invoice overdue. |
403 |
The key's IP allowlist or scopes reject the request. This route needs the calls scope. With a public key: the chat was not started with this key. |
404 |
No chat with this ID in the workspace. |
429 |
Rate limit exceeded. See Rate limits. |
See Errors for the body format.