Skip to main content
SAMPLE APP

Pinecone Assistant

A chat interface that answers questions about your own documents
The Pinecone Assistant sample app connects a chat interface to your assistant so it can answer complex questions about your own data. Users can upload PDF documents, then ask questions about their content in the chat.

Built with

  • Pinecone Assistant
  • Next.js and Tailwind CSS
  • Node.js 20 or later

Run the sample app

To create the sample app, use the create-pinecone-app CLI:
Terminal
1

Get your Pinecone API key

You need an API key to make calls to your Pinecone project:
Then copy your generated key:
.env
You can also copy an existing key from the API keys page in the Pinecone console.
2

Create an assistant

Create an assistant in the Pinecone console or with the API, and upload the files you want it to answer questions about. For more information, see Create an assistant.
3

Install dependencies

The app requires Node.js 20 or later. From the project root directory, install the dependencies:
Terminal
4

Set environment variables

In .env, set your Pinecone API key and the name of your assistant:
.env
5

Start the app

Start the development server:
Terminal

Project structure

Pinecone Assistant sample app architecture: a Next.js frontend calls Next.js API routes, which proxy requests to the Pinecone Assistant APIThe app uses a standard Next.js structure:
  • Frontend: Next.js, Tailwind CSS, and custom React components that power the chat interface.
  • Backend: Next.js API routes that proxy requests to the Pinecone Assistant API.

Key features

  • Connect to an existing assistant: The app connects to an assistant you’ve already created, so you can host a chat experience privately or publicly.
  • Streaming responses: The assistant’s answers stream to the frontend in real time.
  • Reference highlighting: The app highlights the documents the assistant used to answer each question.

Implementation details

Server action for chat

The server action opens a streaming chat request to the Pinecone Assistant API and passes each event to the client:
TypeScript

Chat functionality

The Home component sends the user’s message to the server action, reads the stream, and updates the UI as content arrives:
TypeScript

Troubleshooting

If you run into problems, see the Pinecone Assistant README. If that doesn’t solve it, open an issue in the sample apps repository or ask in the Pinecone Discord community.