Endpoint
Authentication
Requires a valid Clerk session token. See Authentication for details.Request Body
The unique identifier of the conversation. Must be a valid Convex ID.
The user’s message content to send to the AI assistant.
Response
Indicates whether the message was successfully queued for processing.
The Inngest event ID for tracking the background processing job.
The Convex ID of the created assistant message placeholder.
Request Example
Response Example
Behavior
Automatic Cancellation
When a new message is sent, the endpoint automatically:- Finds all processing messages in the same project
- Cancels those messages by sending
message/cancelevents - Updates their status to
cancelled
Message Creation
The endpoint creates two messages:- User Message: Contains the user’s input with role
user - Assistant Message: Empty placeholder with role
assistantand statusprocessing
Asynchronous Processing
The actual AI response generation happens asynchronously:- An Inngest
message/sentevent is triggered - Background processing handles the AI generation
- The assistant message is updated with the response
- Status changes from
processingtocompletedorfailed
Error Responses
Description of the error that occurred.
Common Errors
| Status Code | Error | Description |
|---|---|---|
| 401 | Unauthorized | Missing or invalid authentication token |
| 404 | Conversation not found | The specified conversationId doesn’t exist |
| 500 | Internal key not configured | Server configuration error |
Notes
- The response is returned immediately after queueing the message, not after AI generation completes
- Use the returned
messageIdto subscribe to updates and receive the AI response - Messages are stored in Convex database
- Background processing is handled by Inngest
- Only one message per project can be processing at a time