Skip to content

TypeScript API / @laikacms/server/ai / ChatRequest

Interface: ChatRequest ​

Chat request body - matches the actual POST /chat wire format (Vercel AI SDK).

messages is the full conversation history as Vercel AI SDK UIMessage objects (v3 format: { id, role, parts[] }). The server reads the last user message from this array; do NOT use the legacy message: string field.

Example ​

typescript
const body: ChatRequest = {
  messages: [{ id: '1', role: 'user', parts: [{ type: 'text', text: 'Hello' }] }],
  document: { slug: 'posts/my-post' },
};

Properties ​

document ​

ts
document: object;

Document context - only the slug is required on the wire

slug ​

ts
slug: string;

messages ​

ts
messages: unknown[];

Full conversation history as Vercel AI SDK UIMessage objects


sessionId? ​

ts
optional sessionId?: string;

Session ID (optional - creates new session if not provided)

Released under the MIT License.