Back to Docs
API v1

API Documentation

Integrate Nairi into your applications with our REST API. All endpoints require authentication unless otherwise noted.

Authentication
All API requests must include your session token in the Authorization header
Header
Authorization: Bearer YOUR_SESSION_TOKEN

Session tokens are obtained through Supabase Auth after signing in. Use the Supabase client library to manage authentication.

Endpoints

Authentication
POST/auth/sign-up
POST/auth/sign-in
POST/auth/sign-out

Create a new user account

Sign in with email and password

Sign out current user

Chat
POST/api/chat

Send a message to AI and stream response

Creation
POST/api/create

Generate content (presentations, websites, etc.)

Credits
GET/api/credits
GET/api/credits/earn
POST/api/credits/earn
POST/api/credits/referral

Get user's credit balance and stats

Get available rewards to claim

Claim a reward

Process referral signup

Marketplace
GET/api/marketplace/search
POST/api/marketplace/purchase
GET/api/marketplace/reviews
POST/api/marketplace/reviews

Search for agents

Purchase an agent

Get agent reviews

Submit a review

Profile
GET/api/profile
PATCH/api/profile
DELETE/api/profile

Get current user's profile

Update profile information

Request account deletion

Execution Traces
GET/api/traces
POST/api/traces
PATCH/api/traces

Get execution traces history

Start a new execution trace

Complete an execution trace

Code Examples

Chat API
// Send a chat message
const response = await fetch('/api/chat', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_SESSION_TOKEN'
  },
  body: JSON.stringify({
    messages: [
      { role: 'user', content: 'Hello, how are you?' }
    ],
    conversationId: 'optional-conversation-id',
    mode: 'default' // or 'debate', 'reasoning', 'tutor', 'creator'
  })
})

// Response is a stream
const reader = response.body.getReader()
Credits API
// Get credit balance
const response = await fetch('/api/credits', {
  headers: {
    'Authorization': 'Bearer YOUR_SESSION_TOKEN'
  }
})

const { balance, dailyLimit, resetIn, streak } = await response.json()

// Claim a reward
const claimResponse = await fetch('/api/credits/earn', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_SESSION_TOKEN'
  },
  body: JSON.stringify({
    rewardType: 'watch' // or 'activity', 'streak'
  })
})
Rate Limits

Free tier: 100 requests/minute

Pro tier: 1000 requests/minute

Business tier: Custom limits

Response Format
{
  "success": true,
  "data": { ... },
  "error": null
}