API Documentation

Complete reference for the Preksha AI API

Authentication
Ingest Events
Query Events
Alert Rules

Base URL

https://api.preksha.ai/v1

Authentication

All API requests require authentication using an API key

Include your API key in the X-API-Key header:

X-API-Key: pk_live_your_api_key

API keys can be created and managed in your project settings.

Quick Start

Start sending events in minutes

import { PrekshaClient } from '@preksha/sdk';

const preksha = new PrekshaClient({
  apiKey: process.env.PREKSHA_API_KEY,
  projectId: 'your-project-id'
});

// After your AI call completes
await preksha.ingest({
  model: 'claude-3-sonnet',
  inputTokens: 456,
  outputTokens: 1234,
  clientId: 'user-123',
  inputHash: hash(prompt),  // Hash, not raw content
  outputHash: hash(response),
  metadata: {
    endpoint: '/api/chat',
    cached: false
  }
});

API Endpoints

Available REST API endpoints

POST/api/v1/ingest
GET/api/v1/events
GET/api/v1/events/:id
GET/api/v1/stats
POST/api/v1/alert-rules
GET/api/v1/clients
POST/api/v1/blocklist

Official SDKs

Python

v1.2.0

stable

JavaScript/TypeScript

v1.1.5

stable

Go

v0.9.0

beta

Ruby

v0.8.0

beta

Rate Limits

Requests/minute1,000
Burst50/sec
Max payload1 MB

Enterprise plans have higher limits. Contact sales for details.

Need Help?