For the complete documentation index, see llms.txt. Prefer markdown by appending.mdto documentation URLs or sendingAccept: text/markdown.
Billing
Middleware-based credit system that deducts a configured amount per AI request, with usage-based billing and payment provider integration planned.
AI Kit includes a straightforward middleware setup to manage user credits for AI features. This lets you control access based on available credits without complex payment integrations.
Credit-based access
A focused middleware verifies if users have enough credits before allowing them to access specific AI-powered routes or actions.
export const aiRouter = new Hono().post(
"/chat",
rateLimiter,
validate("json", chatMessageSchema),
deductCredits({
amount: 10,
}),
streamChat,
);This example shows how the deductCredits middleware subtracts a specific amount (10 credits) for each request to the /chat endpoint.
Extending billing
To charge for subscriptions or credit purchases, follow Integrate Core Kit, then use the provider guides below. Keep one server-side policy for payments and AI usage.
How is this guide?
Last updated on
Authentication
Anonymous sessions are created automatically on first visit so users can interact with AI features before signing up, with easy upgrade paths to full auth.
Database
PostgreSQL with Drizzle ORM stores chat history, vector embeddings for RAG, AI-generated images, and per-user credits in feature-isolated pg schemas.