signToken creates a compact, short-lived token that your frontend can use with the "GatelitSigned" auth scheme. Call it from your backend — never from client-side code.
base64url(header).base64url(payload).base64url(signature) — structurally identical to a standard HS256 JWT.
Parameters
options
string
required
User identifier embedded in the token. Used for request attribution in dashboard logs.
string
Organisation ID to embed in the token. The gateway uses this to resolve org-scoped provider keys when BYOK is configured.
string
Restrict this token to a single model in
"provider/model-name" format (for example "openai/gpt-4o"). Requests using a different model are rejected by the gateway. Omit to allow any model permitted by your policy.number
Cap the maximum output tokens for requests made with this token.
number
default:"60"
Token lifetime in seconds. Defaults to
60. Tokens expire at iat + ttl.secret
string
required
Your
GATELIT_SIGNING_SECRET. Store this in an environment variable and never expose it outside your server.Examples
Nuxt server route
Next.js API route
Using the token on the frontend
Once your backend endpoint issues a token, pass it toGatelitClient via getToken:
Security notes
- Never import
@gatelit/sdk/signin browser code. The separate import path exists specifically to prevent the signing code from being bundled into client builds. - Store the secret in an environment variable. Use
process.env.GATELIT_SIGNING_SECRET(or your runtime’s equivalent) and ensure it is excluded from version control. - Authenticate the user before issuing a token.
signTokendoes not perform any authentication — you must verify the caller’s identity in your own middleware before calling it. - Keep TTLs short. The default of 60 seconds is appropriate for most use cases. A shorter TTL limits the window of exposure if a token is intercepted.