You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api-reference/assistant/create-assistant-message.mdx
+77-3Lines changed: 77 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,69 @@
2
2
openapi: POST /assistant/{domain}/message
3
3
---
4
4
5
+
The AI Discovery Assistant API provides intelligent, context-aware responses based on your documentation. The API returns responses as a **streaming text response**, allowing you to display answers progressively as they're generated.
6
+
7
+
## Streaming response
8
+
9
+
This endpoint returns a **streaming response** using Server-Sent Events (SSE). The response body contains a readable stream that you must process chunk by chunk to receive the complete answer.
10
+
11
+
### Complete example
12
+
13
+
Here's a complete example showing how to send a message and handle the streaming response:
14
+
15
+
```javascript
16
+
constdomain=process.env.MINTLIFY_DOMAIN!;
17
+
constapiKey=process.env.MINTLIFY_API_KEY!;
18
+
constuserMessage=process.argv.slice(2).join('') ||'How do I get started?';
-**`fp`** - A unique fingerprint to identify the user session
54
+
-**`threadId`** - Identifier for the conversation thread to maintain context
55
+
-**`messages`** - Array of message objects with `id`, `role`, `content`, and `parts`
56
+
-**`retrievalPageSize`** - Number of documentation chunks to retrieve for context (default: 5)
57
+
-**`filter`** - Optional filter to limit search to specific versions or languages
58
+
59
+
### Handling the stream
60
+
61
+
The response is a readable stream that must be processed using the Streams API:
62
+
63
+
1. Get a reader from `response.body.getReader()`
64
+
2. Create a `TextDecoder` to convert bytes to text
65
+
3. Read chunks in a loop until `done` is true
66
+
4. Decode each chunk and process the text
67
+
5
68
## Rate limits
6
69
7
70
The assistant API has the following limits:
@@ -10,8 +73,19 @@ The assistant API has the following limits:
10
73
- 10,000 requests per Mintlify organization per hour
11
74
- 10,000 requests per IP per day
12
75
13
-
## Suggested usage
76
+
## Frontend integration
77
+
78
+
For React applications, use the [useChat hook from ai-sdk](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat#usechat) to send requests and handle streaming responses automatically.
14
79
15
-
For best results, use the [useChat hook from ai-sdk](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat#usechat) to send requests and handle responses.
80
+
You can set `fp`, `threadId`, and `filter` in the `body` field of the options parameter passed to the hook:
16
81
17
-
You can set `fp`, `threadId`, and `filter` in the `body` field of the options parameter passed to the hook.
0 commit comments