Skip to main content

Chats

Endpoints for creating and managing AI chat conversations.

GET /api/chats

Get a paginated list of chats ordered by pinned status and last update time.

Authentication: Required (session)

Query Parameters:

ParameterTypeDefaultDescription
limitinteger20Number of results per page
offsetinteger0Pagination offset

Response:

{
"total": 150,
"limit": 20,
"offset": 0,
"results": [
{
"id": "abc123",
"name": "Product Analysis",
"autoRename": true,
"stale": false,
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T14:22:00Z",
"modelId": "model-123",
"tier": "advanced",
"ownerAssistantId": null,
"primaryAssistantId": "asst-456",
"web": false,
"directory": "reports",
"outputSize": "medium",
"pinned": true
}
]
}

POST /api/chats

Create a new chat conversation with optional initial messages and associations.

Authentication: Required (session)

Request Body:

FieldTypeRequiredDescription
namestringNoChat name (null for auto-generated)
modelIdstringYesModel ID to use for chat
tierstringNoModel tier: everyday, advanced, strategic
ownerAssistantIdstringNoAssistant that owns this chat
primaryAssistantIdstringNoPrimary assistant for the chat
assistantIdsarrayNoArray of assistant IDs to associate
datasetIdsarrayNoArray of dataset IDs to associate
libraryIdsarrayNoArray of library IDs to associate
instructionsstringNoCustom instructions for the chat
messagesarrayNoInitial messages (defaults to empty)
webbooleanNoEnable web access (default: false)
helpCenterbooleanNoEnable help center (default: false)
magicReportbooleanNoEnable App (default: false)
pinnedbooleanNoPin chat to top (default: false)
directorystringNoDirectory path for organization
outputSizestringNoOutput size: small, medium, large (default: medium)

Example Request:

{
"name": "Sales Analysis",
"modelId": "claude-opus-4",
"tier": "advanced",
"assistantIds": ["asst-123"],
"datasetIds": ["ds-456"],
"messages": [],
"web": false,
"outputSize": "medium"
}

Response:

Returns the created chat object with associated IDs.


GET /api/chats-list

Get a simple list of all chats ordered by update time (legacy compatibility endpoint).

Authentication: Required (session)

Response:

Array of chat objects without pagination.


GET /api/chats/{id}

Retrieve a specific chat with full details including attachments, assistants, datasets, and memory summaries.

Authentication: Required (session)

Pre-blocks: chat.lookupForUi

Response:

{
"id": "abc123",
"name": "Product Analysis",
"instructions": "Focus on quarterly metrics",
"modelId": "claude-opus-4",
"model": {
"id": "claude-opus-4",
"name": "Claude Opus 4",
"tier": "strategic"
},
"assistantIds": ["asst-123", "asst-456"],
"datasetIds": ["ds-789"],
"libraryIds": ["lib-012"],
"messages": [],
"memories": [
{
"id": "mem-345",
"summary": "Discussed Q4 revenue targets",
"messageCount": 12
}
],
"attachments": [
{
"id": "file-678",
"filename": "report.pdf",
"size": 102400
}
],
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T14:22:00Z",
"_links": {
"inf:messages": { "href": "/api/chats/abc123/messages" },
"inf:chat-schedule": { "href": "/api/chats/abc123/schedule" }
}
}

PUT /api/chats/{id}

Update chat properties and associations.

Authentication: Required (session)

Pre-blocks: chat.lookup

Request Body:

FieldTypeDescription
namestringChat name
instructionsstringCustom instructions
modelIdstringChange model
assistantIdsarrayReplace assistant associations
datasetIdsarrayReplace dataset associations
libraryIdsarrayReplace library associations
primaryAssistantIdstringSet primary assistant
ownerAssistantIdstringSet owner assistant
autoRenamebooleanEnable auto-renaming
autoRenamedAtdateLast auto-rename timestamp
autosuggestbooleanEnable auto-suggestions
stalebooleanMark as stale
webbooleanEnable web access
helpCenterbooleanEnable help center
magicReportbooleanEnable App
pinnedbooleanPin to top
directorystringOrganization directory
outputSizestringsmall, medium, or large

Response:

Returns the updated chat object.

Transaction Support

This endpoint uses database transactions to ensure consistency when updating multiple associations.


DELETE /api/chats/{id}

Delete a chat conversation and all associated messages.

Authentication: Required (session)

Response:

204 No Content


POST /api/chats/{id}

Send a message to a chat and receive a streaming AI response.

Authentication: Required (session with AI seat)

Pre-blocks:

  • chat.lookupForSubmission
  • Model resolution
  • Budget enforcement (tiered or legacy)

Request Body:

FieldTypeRequiredDescription
messageobjectYesMessage object with content
fileIdsarrayNoArray of file IDs to attach
uploadIdsarrayNoArray of upload IDs to process
toolsobjectNoTool configuration
functionsarrayNoFunction names to enable
toolkitIdsarrayNoAdditional toolkit IDs
systemstringNoSystem prompt override

Payload Limit: 200MB (209715200 bytes)

Response:

Server-Sent Events (SSE) stream with Content-Type: text/event-stream

Stream Events:

event: message-start
data: {"id":"msg-123","role":"assistant"}

event: content-delta
data: {"delta":"Here is my response..."}

event: tool-use
data: {"toolName":"search","args":{...}}

event: message-complete
data: {"id":"msg-123","cost":0.0042}

Error Handling:

  • 403 - Insufficient budget
  • 400 - Invalid model or payload
  • Connection closed on abort signal
Budget Enforcement

This endpoint enforces weekly and session budget limits. Requests exceeding budget will return 403 Forbidden.


POST /api/chats/{id}/attachments

Upload a file attachment to a chat with optional embedding generation.

Authentication: Required (session)

Pre-blocks: chat.lookup, upload validation

Request Body:

FieldTypeRequiredDescription
uploadIdstringYesUpload ID from file upload
progressnumberNoUpload progress tracking

Response:

{
"id": "file-789",
"filename": "document.pdf",
"size": 204800,
"uploadId": "upload-123",
"embedded": true,
"createdAt": "2024-01-15T15:30:00Z"
}

POST /api/chats/{id}/messages/{messageId}/_explain

Generate an explanation for a specific message in the chat.

Authentication: Required (session)

Pre-blocks: Message and chat lookup

Response:

Server-Sent Events (SSE) stream explaining the message generation process.


POST /api/chats/{id}/_summarize

Create memory summaries from chat messages in configurable segments.

Authentication: Required (session)

Pre-blocks: chat.lookup

Request Body:

FieldTypeDefaultDescription
segmentSizeinteger20Number of messages per segment

Response:

{
"memoriesCreated": 3,
"messagesCovered": 60,
"segments": [
{
"memoryId": "mem-123",
"messageCount": 20,
"summary": "Initial project setup discussion"
}
]
}

GET /api/chat-models

List models available for chat, filtered for specific use cases.

Authentication: Required (session)

Response:

{
"_links": {
"self": { "href": "/api/chat-models" }
},
"_embedded": {
"inf:model": [
{
"id": "claude-opus-4",
"name": "Claude Opus 4",
"slug": "claude-opus-4",
"tier": "strategic",
"chat": true,
"provider": {
"id": "anthropic",
"name": "Anthropic"
},
"promptPpm": 15.0,
"completionPpm": 75.0,
"contextWindow": 200000
}
]
},
"start": 0,
"count": 1,
"total": 1
}

Filtering:

  • Excludes deprecated models
  • Excludes internal models
  • Resolves GO tier aliases (go_everyday, go_advanced, go_strategic)
  • Includes prompt-caching cost adjustments

GET /api/chats/{id}/files/{fileId}/{filename}

Retrieve file contents from a chat attachment.

Authentication: Required (session)

Pre-blocks: ai.verify, file lookup (attachment role only)

Path Parameters:

ParameterTypeDescription
idstringChat ID
fileIdstringFile ID
filenamestringOriginal filename

Response:

File contents with appropriate Content-Type header.

Authorization:

Validates that the requesting user owns the chat containing the file.


GET /api/chats/{id}/images/{fileId}

Retrieve an image file from a chat.

Authentication: Required (session)

Path Parameters:

ParameterTypeDescription
idstringChat ID
fileIdstringImage file ID

Response:

Image file contents with appropriate Content-Type header.

Authorization:

Validates chat ownership before returning image.