ryOS ryOS / Docs
GitHub Launch

API Reference

ryOS backend APIs use Node.js route handlers in api/, deployable on Vercel or the standalone Bun API server.

Most actively refactored JSON routes use the shared apiHandler utility (api/_utils/api-handler.ts) for CORS, method checks, auth resolution, and consistent error handling. Some specialized routes (for example multipart upload handlers) still use explicit/manual handling.

API Request Flow

graph LR
    Client[Client App] --> Auth{Auth Check}
    Auth -->|Valid| Router[API Router]
    Auth -->|Invalid| Error[401 Error]
    Router --> API[Node.js Runtime]
    API --> Services[External Services]
    Services --> AI[AI Providers]
    Services --> DB[(Redis/KV)]
    Services --> Media[Media APIs]
    API --> Response[JSON Response]
    Response --> Client

Endpoint Documentation

Endpoint GroupDescription
Chat APIMain AI chat with streaming and tool calling
Song APIMusic library CRUD, lyrics, furigana, translations
Media APIText-to-speech, transcription, YouTube search
Auth APIUser registration, login, token management
Rooms APIChat room creation and management
Messages APISend and retrieve chat messages
Presence APIPresence tracking, user search, AI replies
AI Generation APIsApplet generation, IE time-travel, parse-title
Utility APIsLink preview, iframe check, share applet, stocks, sync, admin
API Design GuidePatterns and conventions for API development

Cross-Cutting Handler Pattern

  • apiHandler: shared wrapper for CORS preflight, origin checks, method allowlists, optional JSON parsing, unified logger wiring, and default JSON error handling.
  • request-auth: shared auth resolver for token endpoints, expecting:
    • Authorization: Bearer {token}
    • X-Username: {username}
  • Partial auth headers return 400.
  • Invalid token/username pairs return 401.
  • Optional-auth endpoints can be anonymous while still validating provided auth headers.

Infrastructure Adapters

  • Redis (api/_utils/redis.ts): Centralized Redis client factory supporting Upstash REST (REDIS_KV_REST_API_URL) and standard Redis (REDIS_URL) backends with a unified API.
  • Storage (api/_utils/storage.ts): Switchable object storage adapter supporting Vercel Blob and S3-compatible backends for cloud backups and sync.

Quick Reference

AI Endpoints

EndpointPurpose
/api/chatMain AI chat with tool calling
/api/applet-aiApplet text + image generation
/api/ie-generateTime-travel page generation
/api/parse-titleMusic metadata extraction

Media Endpoints

EndpointPurpose
/api/songs/Song library CRUD
/api/songs/[id]Individual song operations
/api/speechText-to-speech
/api/audio-transcribeSpeech-to-text
/api/youtube-searchYouTube music search

Communication Endpoints

EndpointPurpose
/api/roomsRoom list + create
/api/rooms/[id]Room detail + delete
/api/rooms/[id]/joinJoin a room
/api/rooms/[id]/leaveLeave a room
/api/rooms/[id]/usersGet active users in room
/api/rooms/[id]/messagesList/send messages
/api/rooms/[id]/messages/[msgId]Delete message (admin)
/api/messages/bulkBulk message fetch
/api/presence/switchPresence switching
/api/presence/heartbeatGlobal online presence heartbeat
/api/rooms/[id]/typingBroadcast typing indicator
/api/usersUser search
/api/ai/ryo-replyAI reply in rooms
/api/listen/sessionsList/create listen-together sessions
/api/listen/sessions/[id]Get session state
/api/listen/sessions/[id]/joinJoin listen session
/api/listen/sessions/[id]/leaveLeave listen session
/api/listen/sessions/[id]/syncSync playback state (DJ only)
/api/listen/sessions/[id]/reactionSend emoji reaction
/api/telegram/link/createCreate Telegram account link
/api/telegram/link/statusCheck Telegram link status
/api/telegram/link/disconnectDisconnect Telegram account

Utility Endpoints

EndpointPurpose
/api/link-previewURL metadata extraction
/api/iframe-checkEmbeddability checking
/api/share-appletApplet sharing
/api/stocksReal-time stock quotes
/api/sync/backup-tokenGenerate cloud backup upload descriptor
/api/sync/backupSave/list/delete cloud backup metadata
/api/sync/statusCloud backup status summary
/api/sync/domainsRead logical and physical cloud sync metadata
/api/sync/domains/[domain]Download or update one logical sync domain
/api/sync/domains/[domain]/attachments/prepareGenerate blob upload instructions for logical sync parts
/api/adminAdmin operations
/api/airdrop/heartbeatAirDrop presence heartbeat
/api/airdrop/discoverDiscover nearby AirDrop users
/api/airdrop/sendSend file via AirDrop
/api/airdrop/respondAccept/decline AirDrop transfer

Endpoint Categories Overview

graph TD
    API["/api/*"]
    API --> AI[AI Services]
    API --> Media[Media Services]
    API --> Comm[Communication]
    API --> Util[Utilities]
    
    AI --> chat["/chat"]
    AI --> applet["/applet-ai"]
    AI --> ie["/ie-generate"]
    AI --> parse["/parse-title"]
    
    Media --> song["/song/*"]
    Media --> speech["/speech"]
    Media --> transcribe["/audio-transcribe"]
    Media --> yt["/youtube-search"]
    
    Comm --> rooms["/rooms"]
    Comm --> messages["/messages/bulk"]
    Comm --> presence["/presence/switch"]
    Comm --> users["/users"]
    Comm --> ryo["/ai/ryo-reply"]
    Comm --> listen["/listen/sessions"]
    Comm --> telegram["/telegram/link"]
    
    Util --> preview["/link-preview"]
    Util --> iframe["/iframe-check"]
    Util --> share["/share-applet"]
    Util --> stocks["/stocks"]
    Util --> sync["/sync/*"]
    Util --> admin["/admin"]

Authentication

Authorization: Bearer {token}
X-Username: {username}

Token-based sessions use a 90-day TTL. Auth-required endpoints use the shared request-auth validation boundary for consistent 400/401 semantics.

AI Providers

ProviderModels
OpenAIgpt-5.4, gpt-4.1-mini, tts-1, whisper-1
Anthropicsonnet-4.6
Googlegemini-3-flash, gemini-3-flash-preview, gemini-3.1-pro-preview, gemini-3.1-flash-image-preview