showcase/shell-docs/src/content/reference/v1/components/CopilotKit.mdx
{ /*
You can find more information about self-hosting CopilotKit here.
import { CopilotKit } from "@copilotkit/react-core";
<CopilotKit runtimeUrl="<your-runtime-url>">
// ... your app ...
</CopilotKit>
Don't have it yet? Go to https://cloud.copilotkit.ai and get one for free. </PropertyReference>
<PropertyReference name="publicLicenseKey" type="string" > Your public license key for accessing premium CopilotKit features.Don't have it yet? Go to https://cloud.copilotkit.ai and get one for free. </PropertyReference>
<PropertyReference name="guardrails_c" type="{ validTopics?: string[]; invalidTopics?: string[]; }" > Restrict input to specific topics using guardrails. @remarksThis feature is only available when using CopilotKit's hosted cloud service. To use this feature, sign up at https://cloud.copilotkit.ai to get your publicApiKey. The feature allows restricting chat conversations to specific topics. </PropertyReference>
<PropertyReference name="runtimeUrl" type="string" > The endpoint for the Copilot Runtime instance. [Click here for more information](/concepts/copilot-runtime). </PropertyReference> <PropertyReference name="transcribeAudioUrl" type="string" > The endpoint for the Copilot transcribe audio service. </PropertyReference> <PropertyReference name="textToSpeechUrl" type="string" > The endpoint for the Copilot text to speech service. </PropertyReference> <PropertyReference name="headers" type="Record<string, string> | (() => Record<string, string>)" > Additional headers to be sent with the request. Can be a static object or a function that returns headers dynamically (useful for refreshing auth tokens).For example:
// Static headers
headers={{ "Authorization": "Bearer X" }}
// Dynamic headers (re-evaluated on each render)
headers={() => ({ "Authorization": `Bearer ${getToken()}` })}
Note: The authorization property is automatically forwarded to LangGraph agents. See the LangGraph Agent Authentication Guide for details.
</PropertyReference>
To enable HTTP-only cookie authentication, set credentials="include" and configure
CORS on your runtime endpoint:
// Frontend (https://myapp.com)
<CopilotKit runtimeUrl="https://api.myapp.com/copilotkit" credentials="include">
{children}
</CopilotKit>
// Backend (https://api.myapp.com)
copilotRuntimeNextJSAppRouterEndpoint({
runtime,
endpoint: "/copilotkit",
cors: {
origin: "https://myapp.com",
credentials: true,
},
});
This feature is only available when using CopilotKit's hosted cloud service. To use this feature, sign up at https://cloud.copilotkit.ai to get your publicApiKey. The feature allows restricting chat conversations to specific topics. </PropertyReference>
<PropertyReference name="threadId" type="string" > The thread id to use for the CopilotKit. </PropertyReference> <PropertyReference name="onError" type="CopilotErrorHandler" > Optional error handler for comprehensive debugging and observability.Requires publicApiKey: Error handling only works when publicApiKey is provided. This is a premium Copilot Cloud feature.
@param errorEvent - Structured error event with rich debugging context
@example
<CopilotKit
publicApiKey="ck_pub_your_key"
onError={(errorEvent) => {
debugDashboard.capture(errorEvent);
}}
>
Pass true for full output, or an object for granular control:
<CopilotKit debug={true} runtimeUrl="...">
{children}
</CopilotKit>