Assistant

Create assistant message

Generates a response from Ask AI for the hosted docs site. Compatible with AI SDK v5+. No API key — the site is selected by `{domain}`, the hostname readers visit.

POST/v1/assistant/{domain}/message

The Create assistant message endpoint streams an Ask AI reply for a published docs site. There is no API key. The site is selected by {domain} — the hostname readers visit.

For Velu's own docs at https://veludocs.com/docs, {domain} is veludocs.com. Pass /docs (or a page path like /docs/quickstart) in currentPath. Each reply consumes 1 credit from the site owner's plan.

Integration with useChat

The useChat hook from Vercel's AI SDK is the recommended way to embed Ask AI in your product.

Install AI SDK

npm i ai @ai-sdk/react

Use the hook

import { useState } from "react";
import { useChat } from "@ai-sdk/react";
import { DefaultChatTransport } from "ai";
function DocsChat({ domain }: { domain: string }) {
const [input, setInput] = useState("");
const { messages, sendMessage } = useChat({
transport: new DefaultChatTransport({
api: `https://api.getvelu.com/v1/assistant/${domain}/message`,
body: {
fp: "anonymous",
retrievalPageSize: 5,
currentPath: "/docs",
},
}),
});
return (
<div>
{messages.map((message) => (
<div key={message.id}>
{message.role === "user" ? "User: " : "Assistant: "}
{message.parts
.filter((part) => part.type === "text")
.map((part) => part.text)
.join("")}
</div>
))}
<form
onSubmit={(e) => {
e.preventDefault();
if (input.trim()) {
sendMessage({ text: input });
setInput("");
}
}}
>
<input value={input} onChange={(e) => setInput(e.target.value)} />
<button type="submit">Send</button>
</form>
</div>
);
}

Required configuration:

  • transport — Use DefaultChatTransport to configure the API connection.
  • body.fp — Fingerprint identifier (anonymous or a unique user id).
  • body.retrievalPageSize — Number of search results to ground the reply (recommended: 5).

Optional configuration:

  • body.threadId — Continue a thread. The stream finish event includes threadId.
  • body.currentPath — Path the reader is viewing. Maximum 200 characters.
  • body.context — Snippets from the page. Each object has:
    • typecode or textSelection
    • value — The snippet
    • path (optional) — Source file or page path
    • elementId (optional) — UI element id
  • body.filter.language — Language code filter, for example en.

See useChat and Transport in the AI SDK documentation.

Rate limits

  • 10 requests per reader (fp) per minute
  • 200 requests per docs site per minute

Path Parameters

domainstringrequired
Hostname of the published docs site. Use the host readers see in the address bar — a platform site such as `acme.getvelu.com`, or a custom domain such as `veludocs.com`. Do not include the path: for a site at `https://veludocs.com/docs`, `{domain}` is `veludocs.com` and the `/docs` prefix belongs in `currentPath`.

Body

fpstringrequired
Fingerprint identifier for tracking conversation sessions. Use `anonymous` for anonymous readers or a unique user identifier.
threadIdstring
Optional id that keeps follow-up messages on the same thread. Returned on the stream as `event.threadId` when `event.type === "finish"`. Omit to start a new conversation.
messagesobject[]required
Array of messages in the conversation. useChat from @ai-sdk/react sends and updates this array for you.
retrievalPageSizeinteger
Number of documentation search results to use for generating the response. Higher values provide more context but may increase response time. Recommended: 5.
filterobject
Optional filter criteria for retrieval.
contextobject[]
Optional contextual information to provide to the assistant, such as a code snippet or selected text on the page.
currentPathstring
Path of the page the reader is viewing. When provided, the assistant uses this to give more relevant answers. Maximum length: 200 characters. For a site served at `https://veludocs.com/docs`, pass `/docs` or a page path such as `/docs/quickstart`.

Response

200text/event-stream

AI SDK UI message stream (`text/event-stream`). Use `useChat` from `@ai-sdk/react` to consume it. The `finish` event includes `threadId` for follow-ups.

bodystring
Server-sent events. Each `data:` line is a UI message chunk, ending with `data: [DONE]`.
400application/json

Error response

error_codestring
messagestring
402application/json

Error response

error_codestring
messagestring
404application/json

Error response

error_codestring
messagestring
429application/json

Error response

error_codestring
messagestring
Was this page helpful?