Skip to content

x0root API

An OpenAI-compatible Cloudflare Worker API for chat completions with intelligent model routing, streaming responses, persistent chat memory, and automatic conversation compaction.

This documentation site explains every aspect of the project — from the routing engine and memory system to deployment and security.

Key Facts

Item Value
Deployed Worker entry point src/index.js
Wrangler configuration wrangler.toml
Default public base URL (demo client) https://puter-api.x0root.workers.dev

What This Is

The project exposes an API that looks like OpenAI's /v1/chat/completions, but internally it performs its own intelligent routing across multiple upstream AI providers.

What the API can do

  • Validate callers with API keys (Supabase-backed)
  • Accept OpenAI-style messages or a plain prompt
  • Auto-classify requests into one of 6 router tiers
  • Route through an NVIDIA-first waterfall with a Puter fallback
  • Stream with OpenAI-compatible SSE
  • Store per-chat memory in a Cloudflare Durable Object (SQLite)
  • Search past conversations with MiniSearch (BM25)
  • Auto-compact long conversations into rolling summaries
Topic Page
How the Worker processes a request Overview
First request in under a minute Quick Start
All endpoints Endpoints
Authentication Authentication
Every request body parameter Request Parameters
The 6 router tiers Router Tiers
NVIDIA-first routing & Puter fallback Routing Engine
Chat memory, search & compaction Memory
Response and streaming formats Response Format
Copy-paste examples Examples
All error responses Errors
The included browser chat client Browser Client
Local dev, deploy & Cloudflare config Deployment
Secrets, keys & best practices Security
Recent fixes Changelog

The Big Picture

client request
-> API-key validation
-> user model preference check
-> AI classifier (if auto-routing)
-> tier selection
-> upstream provider waterfall
-> OpenAI-compatible response
-> optional Durable Object memory save
-> optional background compaction