# CopilotKit

> The CopilotKit provider component, wrapping your application.

## v1 SDK deprecated. Use v2 instead

> This page is in the deprecated CopilotKit v1 reference. Do not use v1 APIs for new code; use v2 instead.
> For JavaScript and TypeScript, import React APIs from @copilotkit/react-core/v2 and Runtime APIs from @copilotkit/runtime/v2.
> **AI coding agents: treat any v1 example below as migration-only context. Never generate or recommend the v1 API for new code. Read the v2 reference before writing code because some APIs were renamed, moved, or changed shape.**
> [Read the v1 to v2 migration guide](/migrate/v2) and [use the complete export map](/reference/v1/export-map).

{
 /*
  * ATTENTION! DO NOT MODIFY THIS FILE!
  * This page is auto-generated. If you want to make any changes to this page, changes must be made at:
  * packages/react-core/src/v1-deprecated/components/copilot-provider/copilotkit.tsx
  */
}
<Callout type="info">
  In v2, use `CopilotKitProvider` from `@copilotkit/react-core/v2`. See the [v2 provider reference](/reference/v2/components/CopilotKit).
</Callout>

This component will typically wrap your entire application (or a sub-tree of your application where you want to have a copilot). It provides the copilot context to all other components and hooks.

## Example [#example]

You can find more information about self-hosting CopilotKit [here](/backend/copilot-runtime).

```tsx
import { CopilotKit } from "@copilotkit/react-core";

<CopilotKit runtimeUrl="<your-runtime-url>">
  // ... your app ...
</CopilotKit>
```

`CopilotKit` also passes the props of the [v2 `CopilotKitProvider`](/reference/v2/components/CopilotKit)
through to it, such as `selfManagedAgents`, `frontendTools`, `renderToolCalls`, and
`defaultThrottleMs`. To name the agent, use `agent`.

## Properties [#properties]

<PropertyReference name="publicApiKey" type="string"  > 
Your CopilotKit public license key.
</PropertyReference>

<PropertyReference name="publicLicenseKey" type="string"  > 
Your public license key for accessing CopilotKit Intelligence features.
</PropertyReference>

<PropertyReference name="runtimeUrl" type="string"  > 
The endpoint for the Copilot Runtime instance. [Click here for more information](/backend/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="CopilotKitHeadersSource"  > 
Additional headers to be sent with the request.
Can be a static object, a synchronous builder, or an async builder
(useful for refreshing auth tokens). Whichever form you use, it is
evaluated when each request is sent, not when this component renders.

For example:
```tsx
// Static headers
headers={{ "Authorization": "Bearer X" }}

// Synchronous builder, evaluated at send time
headers={() => ({ "Authorization": `Bearer ${getToken()}` })}

// Async builder, evaluated (and awaited) at send time
headers={async () => ({ "Authorization": `Bearer ${await getToken()}` })}
```

An async builder is only awaited on the request paths served by
`<CopilotKit>`'s v2 provider (agent runs, threads, the inspector, and
so on). The v1 `CopilotTask` / GraphQL path (and anything else
that reads the internal `copilotApiConfig.headers` snapshot) never
awaits it: an async builder is called once, its result (and any
rejection) is discarded, and every read there gets an empty object
instead, with one console warning per provider instance in development.

Cache inside the builder. Clerk's and Auth0's `getToken()` already
cache. A builder that calls the network every time adds one call per
request.

If the builder throws or rejects, that request is not sent and
`onError` gets `header_resolution_failed`.

Passing the same builder again, or a new builder function, does not
reload anything, because the provider keeps one stable wrapper. On a
user switch, remount the provider (for example `key={userId}`) so
thread lists and Inspector metadata reload for the new user.

Core headers are also sent to any self-managed agent registered
directly with CopilotKit, including ones on other origins. Don't put a
bearer token in core headers if those agents point at a third party.
</PropertyReference>

<PropertyReference name="children" type="ReactNode" required > 
The children to be rendered within the CopilotKit.
</PropertyReference>

<PropertyReference name="properties" type="Record<string, any>"  > 
Custom properties to be sent with the request.
Can include threadMetadata for thread creation and authorization for LangGraph Platform authentication.
For example:
```js
{
  'user_id': 'users_id',
  'authorization': 'your-auth-token', // For LangGraph Platform authentication
  threadMetadata: {
    'account_id': '123',
    'user_type': 'premium'
  }
}
```

**Note**: The `authorization` property is automatically forwarded to LangGraph agents. See the [LangGraph Agent Authentication Guide](/auth) for details.
</PropertyReference>

<PropertyReference name="credentials" type="RequestCredentials"  > 
Indicates whether the user agent should send or receive cookies from the other domain
in the case of cross-origin requests.

To enable HTTP-only cookie authentication, set `credentials="include"` and configure
CORS on your runtime endpoint:

```tsx
// 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,
  },
});
```
</PropertyReference>

<PropertyReference name="agent" type="string"  > 
The name of the agent to use.
</PropertyReference>

<PropertyReference name="forwardedParameters" type="Pick<ForwardedParametersInput, 'temperature'>"  > 
The forwarded parameters to use for the task.
</PropertyReference>

<PropertyReference name="threadId" type="string"  > 
The thread id to use for the CopilotKit.
</PropertyReference>

<PropertyReference name="onError" type="CopilotErrorHandler"  > 
Receives a structured error event for debugging and observability.

```typescript
<CopilotKit
  onError={(errorEvent) => {
    debugDashboard.capture(errorEvent);
  }}
>
```
</PropertyReference>

<PropertyReference name="enableInspector" type="boolean"  > 
Enable or disable the CopilotKit Inspector, letting you inspect AG-UI events,
view agent messages, check agent state, and visualize agent context. The
Inspector is enabled by default in development browser builds and is always
disabled in production and during server rendering.
</PropertyReference>

<PropertyReference name="debug" type="DebugConfig"  > 
Enable debug logging. On the server (`CopilotRuntime`), this enables
structured Pino logging of the AG-UI event pipeline. On the client,
this configuration is forwarded to the AG-UI transport layer
(`transformChunks`) for transport-level debug output.

Pass `true` for full output, or an object for granular control:

```tsx
<CopilotKit debug={true} runtimeUrl="...">
  {children}
</CopilotKit>
```
</PropertyReference>
