From 20264a7d9d7a32a7fbdcf34823541be72cccd65c Mon Sep 17 00:00:00 2001 From: Ethan Palm <56270045+ethanpalm@users.noreply.github.com> Date: Tue, 11 Nov 2025 16:09:29 -0800 Subject: [PATCH 1/4] fix capitalization --- docs.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs.json b/docs.json index 8f0c64cd4..6af410718 100644 --- a/docs.json +++ b/docs.json @@ -275,7 +275,7 @@ ] }, { - "tab": "API Reference", + "tab": "API reference", "groups": [ { "group": "API reference", From 0aa1c978930093fcb1081d325cf6f2e52dec8ba8 Mon Sep 17 00:00:00 2001 From: Ethan Palm <56270045+ethanpalm@users.noreply.github.com> Date: Tue, 11 Nov 2025 16:22:48 -0800 Subject: [PATCH 2/4] add useChat example --- api/assistant/create-assistant-message.mdx | 60 +++++++++++++++++++--- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/api/assistant/create-assistant-message.mdx b/api/assistant/create-assistant-message.mdx index b2dd38479..fa11cc317 100644 --- a/api/assistant/create-assistant-message.mdx +++ b/api/assistant/create-assistant-message.mdx @@ -2,16 +2,62 @@ openapi: POST /assistant/{domain}/message --- +## Integration with `useChat` + +The recommended way to integrate the assistant API into your application is with the `useChat` hook from [Vercel's AI SDK](https://sdk.vercel.ai/docs). + + + + +```bash +npm i ai +``` + + + + +```tsx +import { useChat } from 'ai/react'; + +function MyComponent({ domain }) { + const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat({ + api: `https://api-dsc.mintlify.com/v1/assistant/${domain}/message`, + headers: { + 'Authorization': `Bearer ${process.env.MINTLIFY_TOKEN}`, + }, + body: { + fp: 'anonymous' + }, + streamProtocol: 'data', + sendExtraMessageFields: true, + }); + + return ( +
+ {messages.map((message) => ( +
+ {message.role === 'user' ? 'User: ' : 'Assistant: '} + {message.content} +
+ ))} +
+ + +
+
+ ); +} +``` + +
+
+ +See [useChat](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat) in the AI SDK documentation for more details. + ## Rate limits The assistant API has the following limits: - 10,000 uses per key per month - 10,000 requests per Mintlify organization per hour -- 10,000 requests per IP per day - -## Suggested usage - -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. - -You can set `fp`, `threadId`, and `filter` in the `body` field of the options parameter passed to the hook. \ No newline at end of file +- 10,000 requests per IP per day \ No newline at end of file From e880bfbba424ce7a0339393099de4d3c5b8ad98d Mon Sep 17 00:00:00 2001 From: Ethan Palm <56270045+ethanpalm@users.noreply.github.com> Date: Tue, 11 Nov 2025 17:16:39 -0800 Subject: [PATCH 3/4] add messages placeholder --- api/assistant/create-assistant-message.mdx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/assistant/create-assistant-message.mdx b/api/assistant/create-assistant-message.mdx index fa11cc317..960b2a9f5 100644 --- a/api/assistant/create-assistant-message.mdx +++ b/api/assistant/create-assistant-message.mdx @@ -26,7 +26,11 @@ function MyComponent({ domain }) { 'Authorization': `Bearer ${process.env.MINTLIFY_TOKEN}`, }, body: { - fp: 'anonymous' + fp: 'anonymous', + messages: [ + { role: 'user', content: 'What is this documentation + about?' } + ] }, streamProtocol: 'data', sendExtraMessageFields: true, From 656dad4cd6a2866476fa6e2f559aedcc2a518b3c Mon Sep 17 00:00:00 2001 From: Ethan Palm <56270045+ethanpalm@users.noreply.github.com> Date: Tue, 11 Nov 2025 17:19:16 -0800 Subject: [PATCH 4/4] fix split string --- api/assistant/create-assistant-message.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/assistant/create-assistant-message.mdx b/api/assistant/create-assistant-message.mdx index 960b2a9f5..35b80afe9 100644 --- a/api/assistant/create-assistant-message.mdx +++ b/api/assistant/create-assistant-message.mdx @@ -28,8 +28,7 @@ function MyComponent({ domain }) { body: { fp: 'anonymous', messages: [ - { role: 'user', content: 'What is this documentation - about?' } + { role: 'user', content: 'What is this documentation about?' } ] }, streamProtocol: 'data',