Developers

Build on Onpilot.

Embed an agent, drive conversations via API, or orchestrate tools — whatever your product needs.

Early access. The @onpilot/react and @onpilot/node packages are published but still stabilizing. Talk to us to get set up with an API key and identity-token minting.

Quickstart

Embed SDK

Drop a single script tag on any page. The bubble lazy-loads on idle, authenticates with a short-lived identity token you mint from your backend, and inherits your tenant settings from the dashboard.

html
<!-- Drop-in embed -->
<script
  src="https://chat.onpilot.ai/embed.js"
  data-identity-token="YOUR_TENANT_JWT"
  async
></script>

React

React SDK

Render the agent as a React component. Pass an async identityTokenProvider so tokens are fetched (and refreshed) from your backend — never hardcoded.

tsx
import { OnPilotBubble } from "@onpilot/react";

export default function App() {
  return (
    <OnPilotBubble
      identityTokenProvider={async () => fetchJwtFromYourBackend()}
      position="bottom-right"
    />
  );
}

Server

Server SDK (Node quickstart)

Mint short-lived identity tokens for your signed-in users. The token carries the user identity and tenant binding, so the browser client never holds long-lived secrets.

ts
// Mint an identity token for your signed-in user
import { mintIdentityToken } from "@onpilot/node";

const token = await mintIdentityToken({
  tenantId: "your_tenant_id",
  user: { id: currentUser.id, email: currentUser.email },
  expiresInSeconds: 3600,
});

REST API

One curl to kick the tires

Prefer to drive conversations from your backend? Create a thread, send a message, and stream a reply — all with a single API key.

bash
curl -X POST https://api.onpilot.ai/v1/chat/threads \
  -H "Authorization: Bearer $ONPILOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"copilot_id": "cp_123", "message": "What is the status of order #42?"}'