Sajedar

Docs

Frontend integration notes

Operational notes for wiring Khalti and API token access inside this single Vercel project.

Payment flow

Create a signed order through this Vercel app, open Khalti checkout, return to processing, poll serverless payment status, then reveal the API token after lookup success.

Key handling

Plaintext API tokens appear only on the success screen. Store the token immediately; model token usage is recorded against its 30,000-token allowance.

Model API proxy

Clients call this app with ?token=API_TOKEN. This app validates the token, forwards the request to the hidden VM model, and returns the model response.

Usage tracking

Each successful response records its model-token usage against the key's 30,000-token allowance. Production stores counters in Azure Table Storage; local development uses an in-memory store.

Model API route

curl -X POST "http://localhost:3000/api/models/himalayan-0.5b-it/generate?token=API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text":"Hello"}'

Successful responses include X-Sajedar-Tokens-Used, X-Sajedar-Tokens-Remaining, and X-Sajedar-Key-Request-Count headers.

Example order states

{
  "orderId": "SJ-ORD-1101",
  "state": "pending | success | failed",
  "modelId": "himalayan-0.5b-it",
  "amount": "Rs 800 / 30K tokens"
}
Browse models