Use this file to discover all available pages before exploring further.
This guide assumes that you have completed the Quickstart.
An example project demonstrating implementation of this guide can be found
here.
Let users share an individual response via a share modal. You provide a generateShareLink(message) function that calls your backend and returns a URL. The SDK handles the modal UI, copying, and confirmation.
1
Frontend: Add a Share button to the response footer
Create a footer component using the pre-built ResponseFooter.ShareButton.
Implement an endpoint that returns the message for a given threadId and messageId.
Implement a message store to store the message history. If you’ve followed the Quickstart, you’ll have a message store already, which you can move
to a common location (such as /lib/messageStore.ts) and modify it to persist message history across API routes and requests as follows:
/lib/messageStore.ts
import OpenAI from "openai";export type DBMessage = OpenAI.Chat.ChatCompletionMessageParam & { id?: string;};const messagesStore: { [threadId: string]: DBMessage[];} = {};export const getMessageStore = (id: string) => { const messageList = await fetchMessagesFromDB(id); // fetch from db here return { addMessage: (message: DBMessage) => { // save to db here }, messageList, };};