API Reference Summary
| Method / constructor | Description |
|---|---|
new Limits(config) | Create client. config.apiKey required (must start with sk_). Optional: config.debug (boolean) for request/response logging. |
limits.check(policyKeyOrTag, input) | Evaluate conditions policy. input = object. Returns PolicyEvaluationResult. |
limits.evaluate(policyKeyOrTag, prompt, response) | Evaluate instructions policy (prompt + LLM response). response can be a string or object. Returns PolicyEvaluationResult. |
limits.guard(policyKeyOrTag, input) | Evaluate guardrails policy. input = string. Returns PolicyEvaluationResult. |
limits.listEscalations() | List all escalations. Returns Escalation[]. |
limits.listEscalationsByPolicyId(policyId) | List escalations by policy. Returns Escalation[]. |
limits.approveEscalation(escalationId) | Approve escalation by ID. Returns Escalation. |
limits.declineEscalation(escalationId) | Decline escalation by ID. Returns Escalation. |
Policy key or tag
Forcheck, evaluate, and guard the first argument can be:
- Policy key — e.g.
'amount-minimum-usd' - Tag — e.g.
'#payments'. All policies with that tag are evaluated; strictest result wins: BLOCK → ESCALATE → ALLOW.
Result shape (all policy methods)
The API returns a response withmeta and result; the SDK normalizes this to the PolicyEvaluationResult shape below. When the API returns validation or evaluation errors, they appear in errors.
Configuration
| Parameter | Type | Required | Description |
|---|---|---|---|
config.apiKey | string | Yes | API key (must start with sk_). |
config.debug | boolean | No | Set to true to enable request/response logging in the console. Default: false. |
TypeScript types
Import types for type safety:Exported types
| Type | Description |
|---|---|
PolicyEvaluationResult | Return type of check(), evaluate(), guard() — data, isAllowed, isBlocked, isEscalated, errors?. |
Escalation | Escalation object: id, policy_id, organization_id, status, request?, response?, action_by?, action_by_user?, created_at, updated_at. |
EscalationResponse | Policy result at time of escalation: action, message, success, violated. |
EscalationStatus | Enum: PENDING, ALLOWED, DECLINED (for Escalation.status). |
ActionByUser | User who resolved the escalation: id, first_name, last_name, email (present on Escalation.action_by_user when resolved). |
Errors
| Error | When |
|---|---|
InvalidAPIKeyError | Key missing or doesn’t start with sk_. |
InvalidPolicyKeyError | Policy key/tag empty or invalid. |
InvalidInputError | Empty input where required. |
APIRequestError | API returned 4xx/5xx (error.statusCode, error.response). |
NetworkError / TimeoutError | Request failed or timed out. |
instanceof for handling:
Auth
Requests useAuthorization: Bearer <apiKey>. Get an API key from the Limits dashboard (Dashboard → API keys).