← Back to Home

API Documentation

REST API v1 for mobile apps and integrations

Quick Start for Mobile Apps

1. Authentication

The API uses Sanctum token-based authentication. To get started:

POST /api/v1/auth/login
Content-Type: application/json

{
  "email": "[email protected]",
  "password": "your-password",
  "device_name": "My iPhone"
}

Response:

{
  "data": {
    "token": "1|abc123...",
    "token_type": "Bearer",
    "user": {
      "id": 1,
      "name": "John Doe",
      "email": "[email protected]"
    }
  }
}

Use the token in subsequent requests:

Authorization: Bearer 1|abc123...

2. Check Credentials

Before using chat, verify the user has API credentials configured:

GET /api/v1/auth/me

// Check response.data.flags.has_credentials

3. Send Messages

// Create conversation
POST /api/v1/conversations
{ "title": "My Chat" }

// Send message
POST /api/v1/conversations/{id}/messages
{
  "content": "Hello, how are you?",
  "model": "openai/gpt-4o-mini"
}

API Endpoints

Authentication

Method Endpoint Description
POST/api/v1/auth/loginLogin and get token
POST/api/v1/auth/logoutRevoke current token
POST/api/v1/auth/tokenIssue named token
GET/api/v1/auth/meGet current user profile

Preferences

Method Endpoint Description
GET/api/v1/preferencesGet user preferences
PUT/api/v1/preferencesUpdate preferences

Conversations

Method Endpoint Description
GET/api/v1/conversationsList conversations
POST/api/v1/conversationsCreate conversation
GET/api/v1/conversations/{id}Get conversation with messages
PUT/api/v1/conversations/{id}Update conversation
DELETE/api/v1/conversations/{id}Delete conversation
POST/api/v1/conversations/{id}/pinPin conversation
POST/api/v1/conversations/{id}/unpinUnpin conversation
POST/api/v1/conversations/{id}/regenerateRegenerate last response

Messages

Method Endpoint Description
GET/api/v1/conversations/{id}/messagesList messages
POST/api/v1/conversations/{id}/messagesSend message
GET/api/v1/conversations/{id}/streamStream response (SSE)
DELETE/api/v1/messages/{id}Delete message

Response Format

All responses follow a consistent envelope format:

Success

{
  "data": { ... },
  "meta": {
    "pagination": { ... }
  }
}

Error

{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human readable message",
    "details": { ... }
  }
}

Error Codes

Code HTTP Description
INVALID_CREDENTIALS401Wrong email/password
UNAUTHENTICATED401No/invalid token
FORBIDDEN403Not authorized
NOT_FOUND404Resource not found
VALIDATION_ERROR422Invalid input
CREDENTIALS_REQUIRED428API keys not configured

Idempotency

For POST/PUT/PATCH requests, include an Idempotency-Key header to prevent duplicate operations:

Idempotency-Key: unique-request-id-123

Rate Limiting

API requests are limited to 60 requests per minute per user. Rate limit headers are included in responses:


Web UI Features

Voice Dictation

The web chat interface includes a voice dictation feature that uses your browser's built-in speech recognition (Web Speech API).

Browser Support

  • Best support: Google Chrome, Microsoft Edge (Chromium-based)
  • Partial support: Safari (macOS/iOS)
  • Not supported: Firefox (as of 2024)
  • Requirement: HTTPS is required for speech recognition to work

How to Use

  1. Click the microphone icon next to the message input
  2. Allow microphone access when prompted by your browser
  3. Speak clearly - your speech will be transcribed in real-time
  4. Click the stop button (square icon) when done
  5. The transcribed text will appear in the message input, ready to send

Language Selection

Use the language dropdown next to the mic button to select your dictation language. Available options include:

Your language preference is saved locally and remembered across sessions.

Troubleshooting

Issue Solution
"Microphone access denied"Click the lock/info icon in your browser's address bar and enable microphone permissions
"No speech detected"Speak louder or check your microphone is working
"Network error"Check your internet connection (speech recognition requires connectivity)
"Not supported" messageTry using Chrome or Edge browser
Button is disabledEnsure you're accessing the site via HTTPS