Skip to navigation

Use the Agentic Chat

Run your organization's agents, attach files, answer cards, and download generated files

The agentic chat runs the agents enabled for your organization, with their skills and tools. It lives under /api/v2; everything else in this API is under /api/v1.

Before you begin

  • You have an API key (pai_test_* or pai_live_*)
  • Feature api.agentic_chat is enabled for your organization
  • A turn runs as the user who created the API key, with the agents enabled for the organization

Send a message

curl -X POST https://api-staging.pyramid-ai.com/api/v2/chat \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"messages": [{ "role": "user", "content": "What is a means of escape?" }]
}'
{
"success": true,
"data": {
"chat_id": "471a2149-5932-4a51-af79-12f71ce5668c",
"status": "completed",
"text": "A means of escape is ...",
"card": null,
"files": [],
"protocol": "ui-message-stream-v1",
"events": []
},
"request_id": "..."
}
  • text, card and files are the fields to build on.
  • events is the raw activity of the turn. Add "include_events": false to leave it out.
  • The request waits up to 230 seconds. For long turns send "stream": true and read the event stream; the chat ID is in the X-Chat-Id header.

Continue a chat

Send only the new message with the chat_id. The server keeps the history.

curl -X POST https://api-staging.pyramid-ai.com/api/v2/chat \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"chat_id": "471a2149-5932-4a51-af79-12f71ce5668c",
"messages": [{ "role": "user", "content": "Give me an example." }]
}'

Attach a file

1

Reserve the file

curl -X POST https://api-staging.pyramid-ai.com/api/v2/files \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "file_name": "level-3.pdf", "content_type": "application/pdf", "size_bytes": 482113 }'

The reply has a file_id and an upload.url. size_bytes must be the exact size of the file.

2

Send the bytes

curl -X PUT "UPLOAD_URL" \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE" \
-H "Content-Type: application/pdf" \
--data-binary @level-3.pdf
3

Name the file on a message

curl -X POST https://api-staging.pyramid-ai.com/api/v2/chat \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"messages": [{ "role": "user", "content": "Check this drawing", "files": ["FILE_ID"] }]
}'

PDF, PNG, JPEG, Markdown, XLSX and DOCX are accepted, up to 500 MB. An attached file is a chat attachment. It does not enter your knowledge library; use Documents for that.

Choose an agent

By default the best agent is picked for each turn. To use a specific one, list the agents and pass its id:

curl https://api-staging.pyramid-ai.com/api/v2/agents \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE"
{ "messages": [{ "role": "user", "content": "..." }], "agent_id": "drawing-assistant" }

Answer a card

Some skills stop and ask you to confirm inputs or choose an option. The reply then has "status": "awaiting_input" and a card:

"card": {
"tool_call_id": "call_867a...",
"name": "ask_user",
"input": { "questions": [{ "id": "unit_system", "prompt": "Which unit system?", "options": [{ "id": "metric", "label": "Metric" }] }] }
}

Answer it in your next request:

{
"chat_id": "CHAT_ID",
"card_response": {
"tool_call_id": "call_867a...",
"card": "ask_user",
"action": "answer",
"answers": [{ "questionId": "unit_system", "prompt": "Which unit system?", "selected": [{ "id": "metric", "label": "Metric" }] }]
}
}

For a card that asks you to confirm inputs, use "action": "confirm" and send the card’s rows back in values.

Download a generated file

Files the agent generates (a report, a marked-up drawing) are listed in files:

curl https://api-staging.pyramid-ai.com/api/v2/files/FILE_ID \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE"

The reply has a download_url that is valid for expires_in seconds (300 by default; set ttl between 60 and 3600).

Manage chats

# List, newest first
curl "https://api-staging.pyramid-ai.com/api/v2/chat?limit=20" \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE"
# Read one chat with its messages
curl https://api-staging.pyramid-ai.com/api/v2/chat/CHAT_ID \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE"
# Rename
curl -X PATCH https://api-staging.pyramid-ai.com/api/v2/chat/CHAT_ID \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "title": "Level 3 cooling check" }'
# Delete
curl -X DELETE https://api-staging.pyramid-ai.com/api/v2/chat/CHAT_ID \
-H "Authorization: Bearer pai_test_YOUR_KEY_HERE"