Skip to main content
Nuabase is designed to let your frontend application call LLMs directly, without routing every request through your own backend API. This reduces latency and server load while keeping your API keys secure.

Architecture

Instead of exposing your API_KEY to the browser (which is insecure), you use a Short-lived Access Token.
  1. Login: User logs into your app as usual.
  2. Token Request: Your frontend requests a Nuabase Token from your backend.
  3. Sign: Your backend uses your Signing Key Secret to generate a JWT for that specific user.
  4. Call: Your frontend uses this token to initialize the Nuabase SDK and make requests.

Step 1: Backend - Generate Tokens

You need to expose an endpoint (e.g., POST /api/nuabase-token) that returns a token for the currently authenticated user.
Never expose your NUABASE_SIGNING_KEY_SECRET to the client. It must only be used on your server.

Step 2: Frontend - Initialize SDK

In your frontend application, you initialize the Nua client by providing a fetchToken function. This function is called automatically whenever the SDK needs a fresh token.

Step 3: Make Requests

Once initialized, you can define and call functions just like in the server-side workflow.

Security & abuse prevention

Since requests come directly from the client, Nuabase uses the userId embedded in the token to enforce limits.
  • Budgets: Set a maximum monthly spend per user.
  • Rate Limits: Limit the number of requests per minute per user.
You can configure these limits in the Nuabase Console.