For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

ChatKit

Build and customize an embeddable chat with ChatKit.

ChatKit provides an embeddable chat UI for your agent. It supports file attachments, interactive widgets, and tool calls.

Overview

Run ChatKit on your own infrastructure with the custom server integration. Use the ChatKit Python SDK to connect it to a server-side agent, including one built with the Agents SDK.

Agent Builder shut down on November 30, 2026. ChatKit remains available. If your ChatKit app uses an Agent Builder workflow ID, see Migrate from Agent Builder and move the app to a custom server integration.

Get started with ChatKit

Embed ChatKit in your frontend

Use the custom server integration to connect the ChatKit UI to your backend. Authenticate each user on your server and restrict access to their threads and files.

  1. In your project directory, install the ChatKit React bindings:

    Install the ChatKit React bindings
    npm install @openai/chatkit-react
  2. Add the ChatKit JS script to your page. Drop this snippet into your page’s <head> or wherever you load scripts, and the browser will fetch and run ChatKit for you.

    index.html
    <script
    src="https://cdn.platform.openai.com/deployments/chatkit/chatkit.js"
    async
    ></script>
  3. Import ChatKit and useChatKit from @openai/chatkit-react. In your React component, call useChatKit with api.url set to the endpoint your server exposes (for example, /chatkit). Set api.domainKey to a nonempty development value on localhost. For production, register your frontend domain and use the public domain key issued for it. Keep your OpenAI API key on the server.

  4. Pass the hook’s control to the ChatKit component, give the component a visible height, and send a message. Check that your endpoint receives the request and the reply appears in the chat. See the React component in the customer support example.

To try a complete integration, follow the customer support quickstart. Install uv and set OPENAI_API_KEY in the terminal that runs the backend. From examples/customer-support, install the example’s dependencies with npm install, then run npm start. The React app proxies requests to the Python server at /support/chatkit. Ask the agent about your seat assignment to verify the connection.

Customize ChatKit

See the custom theming, widgets, and actions docs to learn more about how ChatKit works. Or explore the following resources to test your chat, iterate on prompts, and add widgets and tools.

Build your implementation

ChatKit docs on GitHub

Learn to handle authentication, add theming and customization, and more.

ChatKit Python SDK

Add server-side storage, access control, tools, and other backend functionality.

ChatKit JS SDK

Check out the ChatKit JS repo.

Explore ChatKit UI

chatkit.world

Play with an interactive demo of ChatKit.

Widget builder

Browse available widgets.

ChatKit playground

Play with an interactive demo to learn by doing.

See working examples

Samples on GitHub

See working examples of ChatKit and get inspired.

Next steps

Use workflow evaluations to test your agent before deploying changes.

Migrate an existing hosted integration

If you previously used Agent Builder, look for a workflow ID in your server’s session request and a client secret exchange in your frontend. Replace that integration with a connection to your own ChatKit endpoint. Configure authentication and thread storage on the new server, then test a new conversation and reopen it as the same user.

Historical examples of an Agent Builder integration

Use these examples only to locate the hosted session dependency in existing code. The Java example used the Maven dependency com.openai:openai-java:4.117.0. The Go example used the module installed with go get github.com/openai/openai-go/v3@v3.111.0.

Legacy server request with an Agent Builder workflow ID
export default async function getChatKitSessionToken(deviceId: string) {
  const apiKey = process.env.OPENAI_API_KEY;
  if (!apiKey) {
    throw new Error("OPENAI_API_KEY is required");
  }

  const response = await fetch("https://api.openai.com/v1/chatkit/sessions", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "OpenAI-Beta": "chatkit_beta=v1",
      Authorization: `Bearer ${apiKey}`,
    },
    body: JSON.stringify({
      workflow: { id: "wf_68df4b13b3588190a09d19288d4610ec0df388c3983f58d1" },
      user: deviceId,
    }),
  });

  if (!response.ok) {
    throw new Error(
      `Failed to create a ChatKit session: ${response.status} ${await response.text()}`
    );
  }

  const { client_secret } = await response.json();

  if (!client_secret) {
    throw new Error("ChatKit session response did not include client_secret");
  }

  return client_secret;
}
Legacy frontend client secret exchange
import { ChatKit, useChatKit } from '@openai/chatkit-react';

   export function MyChat({ getAppAuthToken }) {
     const { control } = useChatKit({
       api: {
         async getClientSecret(existing) {
           if (existing) {
             // implement session refresh
            }

           const appAuthToken = await getAppAuthToken();
           const res = await fetch('/api/chatkit/session', {
             method: 'POST',
             headers: {
               'Authorization': 'Bearer ' + appAuthToken,
               'Content-Type': 'application/json',
             },
           });
           const { client_secret } = await res.json();
           return client_secret;
         },
       },
     });

     return <ChatKit control={control} className="h-[600px] w-[320px]" />;
   }