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.
TurboStarter AI 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
For more advanced billing scenarios or immediate needs, you can tap into the core TurboStarter billing features. The main documentation provides detailed guidance on setting up and managing billing with third-party providers.
Web billing documentation
Learn more about the comprehensive billing features in TurboStarter web application.
Mobile billing documentation
Learn more about the comprehensive billing features in TurboStarter mobile application.
Stay tuned for updates as we enhance the AI-specific billing functionalities!
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.