Using the Question Answer API with the Vercel AI SDK
Copy page
Overview
This guide demonstrates how to use the Vercel AI SDK to integrate the Question Answer API into your application.
We'll cover two main approaches:
- Using the
useChathook and a Next.js API route - Using server actions (AI SDK Actions) with React Server Components
Log your AI API conversations to the Analytics API to get analytics and reporting, track user feedback, and power features like shared or saved chats — all viewable in the Inkeep Portal.
Using useChat and a route
useChat is cross-platform hook that helps you create a conversational experience with the Vercel AI SDK with React, Svelte, Vue, and Solid frontends.
To use useChat, first create an API route using Next.js. Here's where we'll call Inkeep.
API Route
Client
Using Server Actions (AI SDK Actions)
streamUI is another way to use the Vercel AI SDK, but with React Server Components. This lets you stream entire UI components, not just the text that is then parsed and rendered on the client.
This example illustrates how to render assistant messages and a "sources" list provided by the provideLinks tool.