Skip to main content

Choose Your Installation Method

RegPilot can be integrated into your application in multiple ways depending on your use case and technical stack.

REST API

The simplest way to get started is using the REST API directly. No installation required!

Prerequisites

  • RegPilot account (sign up here)
  • API key from your project dashboard

Make Your First Request

curl -X POST https://regpilot.dev/api/ai/chat \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

SDK Integration

For a more integrated experience, use our official SDKs with built-in TypeScript support.

Node.js / TypeScript

1

Install the package

npm install @regpilot/sdk
# or
yarn add @regpilot/sdk
# or
pnpm add @regpilot/sdk
2

Initialize the client

import { RegPilot } from '@regpilot/sdk';

const regpilot = new RegPilot({
  apiKey: process.env.REGPILOT_API_KEY,
  environment: 'production', // or 'development'
});
3

Make a request

const response = await regpilot.chat.create({
  messages: [
    { role: 'user', content: 'Hello from SDK!' }
  ],
  governorEnabled: true, // Enable compliance validation
});

console.log(response.content);
console.log('Risk Score:', response.riskScore);

Python

1

Install the package

pip install regpilot
2

Initialize the client

from regpilot import RegPilot

client = RegPilot(
    api_key=os.environ["REGPILOT_API_KEY"],
    environment="production"
)
3

Make a request

response = client.chat.create(
    messages=[
        {"role": "user", "content": "Hello from Python SDK!"}
    ],
    governor_enabled=True
)

print(response.content)
print(f"Risk Score: {response.risk_score}")

Framework Integration

Next.js Integration

1

Install dependencies

npm install @regpilot/nextjs
2

Create API route

Create app/api/chat/route.ts:
import { RegPilotHandler } from '@regpilot/nextjs';

export const POST = RegPilotHandler({
  apiKey: process.env.REGPILOT_API_KEY!,
  governorEnabled: true,
});
3

Use in your components

'use client';

import { useRegPilot } from '@regpilot/nextjs/client';

export default function Chat() {
  const { messages, sendMessage, isLoading } = useRegPilot();

  return (
    <div>
      {messages.map((msg, i) => (
        <div key={i}>{msg.content}</div>
      ))}
      <button onClick={() => sendMessage('Hello!')}>
        Send
      </button>
    </div>
  );
}

React Integration

1

Install dependencies

npm install @regpilot/react
2

Wrap your app with provider

import { RegPilotProvider } from '@regpilot/react';

function App() {
  return (
    <RegPilotProvider apiKey={process.env.REACT_APP_REGPILOT_API_KEY}>
      <YourComponents />
    </RegPilotProvider>
  );
}
3

Use the hook in components

import { useRegPilot } from '@regpilot/react';

function ChatComponent() {
  const { chat, isLoading, error } = useRegPilot();

  const handleSubmit = async (message: string) => {
    const response = await chat.send(message);
    console.log(response);
  };

  return (
    // Your UI
  );
}

Environment Variables

Set up your environment variables for secure API key management:
  • .env.local (Next.js)
  • .env (Node.js)
  • .env (Python)
# Public (client-side safe)
NEXT_PUBLIC_REGPILOT_PROJECT_ID=your_project_id

# Private (server-side only)
REGPILOT_API_KEY=sk_your_api_key_here
REGPILOT_ENVIRONMENT=production
Security Best Practice: Never commit your API keys to version control. Always use environment variables and add .env files to your .gitignore.

Configuration Options

Configure RegPilot to match your requirements:
const regpilot = new RegPilot({
  // Required
  apiKey: process.env.REGPILOT_API_KEY,
  
  // Optional
  environment: 'production', // 'production' | 'development'
  timeout: 30000, // Request timeout in milliseconds
  retries: 3, // Number of retry attempts
  baseURL: 'https://regpilot.dev/api', // Custom base URL
  
  // Governor settings
  governor: {
    enabled: true,
    strictMode: false,
    autoApproveThreshold: 50,
  },
  
  // Logging
  logging: {
    level: 'info', // 'debug' | 'info' | 'warn' | 'error'
    pretty: true, // Pretty print logs in development
  },
});

Verify Installation

Test your installation with a simple health check:
import { RegPilot } from '@regpilot/sdk';

const client = new RegPilot({
  apiKey: process.env.REGPILOT_API_KEY!,
});

// Test connection
const health = await client.health.check();
console.log('✅ RegPilot is connected:', health.status);

Next Steps

Troubleshooting

If you encounter issues installing the SDK:
  1. Clear npm cache: npm cache clean --force
  2. Delete node_modules and package-lock.json
  3. Run npm install again
  4. Try with a different package manager (yarn or pnpm)
Ensure you’re importing from the correct package:
// ✅ Correct
import { RegPilot } from '@regpilot/sdk';

// ❌ Incorrect
import { RegPilot } from 'regpilot-sdk';
Make sure you have the latest type definitions:
npm install --save-dev @types/node
And ensure your tsconfig.json includes:
{
  "compilerOptions": {
    "esModuleInterop": true,
    "moduleResolution": "node"
  }
}
Need help? Join our community forum or email [email protected].