Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Wikedhart18/nextjs-ai-chatbot/llms.txt
Use this file to discover all available pages before exploring further.
All endpoints require an active session cookie obtained via the authentication
flow. Unauthenticated requests receive a
401 Unauthorized response.POST /api/chat
Send a message and stream the AI response back to the client. If the chat ID does not yet exist in the database, a new chat record is created automatically with a generated title. The response is a AI SDK data stream (text/plain transfer-encoding chunked). The stream includes text deltas, reasoning tokens (when the reasoning model is selected), and tool-call results.
Authentication: required (session cookie)
Request body
UUID of the chat conversation. Generate a new UUID on the client when starting
a fresh conversation.
Full conversation history in AI SDK
Message
format. The last
entry must be a user message.The model identifier to use for this turn. One of:
| Value | Description |
|---|---|
chat-model-small | Fast, lower-cost model |
chat-model-large | High-capability model |
chat-model-reasoning | Extended reasoning model (tools disabled) |
Response
A streamingtext/plain data stream in the AI SDK wire format. The stream carries:
- Text deltas — incremental assistant text tokens.
- Reasoning tokens — present when
selectedChatModelischat-model-reasoning. - Tool results — for
getWeather,createDocument,updateDocument, andrequestSuggestions(disabled for the reasoning model).
Error codes
| Status | Meaning |
|---|---|
400 | No user message found in the provided messages array. |
401 | Missing or invalid session. |
500 | Internal error during streaming (the stream body will contain "Oops, an error occured!"). |
Example
curl
TypeScript (AI SDK)
DELETE /api/chat
Permanently delete a chat and all of its messages and votes. Authentication: required (session cookie). You can only delete chats that belong to your user account.Query parameters
UUID of the chat to delete.
Response
Returns200 Chat deleted as plain text on success.
Error codes
| Status | Meaning |
|---|---|
401 | Missing or invalid session, or the chat belongs to a different user. |
404 | No id query parameter was provided. |
500 | Unexpected database error. |
Example
curl
TypeScript
POST /api/files/upload
Upload an image file to Vercel Blob storage. The returned URL can be passed as an image content part inside amessages array to give the model visual context.
Authentication: required (session cookie)
Request body
Multipartform-data with the following field:
The image to upload. Constraints:
- Maximum size: 5 MB
- Accepted types:
image/jpeg,image/png
Response
Returns the Vercel BlobPutBlobResult object as JSON.
Error codes
| Status | Meaning |
|---|---|
400 | No file provided, empty request body, file exceeds 5 MB, or unsupported file type. |
401 | Missing or invalid session. |
500 | Vercel Blob upload failed or request could not be processed. |
Example
curl
TypeScript