This guide walks you through setting up a new project from scratch. If you’d just like to get started quickly, check out the Quickstart
guide which gets you up and running with a basic template.
1
Create a project
2
Install the latest dependencies
3
Create an API key
Navigate to C1 Console and create a new API key.
4
Set up a backend endpoint
First, create a message history store. This is a simple in-memory store for the messages in the chat.Then, setup the backend endpoint using the message history store. In a typical Next.js application using the
App Router, a simple endpoint for an agent may look like this:
5
Set up the frontend
To integrate the frontend, use the
C1Chat
component. This component includes a ready-to-use chat interface that manages its own state. All you need to do is pass the apiUrl
prop pointing to your backend endpoint.Example implementation:app/page.tsx
If you would like to customize the UI instead of using the pre-built
C1Chat
component, see Customizing Crayon
UI.