@limitry/sdk 1.0.0-rc.1 → 1.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +82 -9
  3. package/package.json +3 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ What changed in the Limitry TypeScript SDK (`@limitry/sdk`). Generated from the source on each release; newest first.
4
+
5
+ ## 1.0.0-rc.4 (2026-10-16)
6
+
7
+ ### Added
8
+
9
+ - Each release comes with a `CHANGELOG.md` listing what changed, newest first.
10
+
11
+ ### Changed
12
+
13
+ - The package page (README, on GitHub, npm and PyPI) shows what the product does with a first real example, and links the guide, the API reference, the changelog and support.
14
+
15
+ ## 1.0.0-rc.3 (2026-10-16)
16
+
17
+ No user-facing changes.
package/README.md CHANGED
@@ -1,26 +1,99 @@
1
1
  # @limitry/sdk
2
2
 
3
- The official TypeScript client for the Limitry API.
3
+ The Limitry TypeScript SDK puts a limit around costly work in one call: `guard` checks before your code runs, and `hold` reserves an estimate, then charges what the work actually cost. Every API operation is a typed method too.
4
+
5
+ Limitry is the limits, credits and budgets layer for your software: give each of your users, teams, tenants, API keys or agents an allowance, and before any costly action one call tells your code whether it may happen.
6
+
7
+ ## Install
4
8
 
5
9
  ```bash
6
10
  npm install @limitry/sdk
7
11
  ```
8
12
 
13
+ Set `LIMITRY_API_KEY` to a key from **API keys** in the app. Use a test
14
+ key (`lim_test_…`) while you build.
15
+
16
+ ## Guard costly work
17
+
18
+ `guard` checks the limit, then runs your code only if it's allowed. Here
19
+ it counts one AI call against a limit such as 100 a day:
20
+
21
+ ```ts
22
+ import { createClient, LimitExceeded } from "@limitry/sdk";
23
+
24
+ const limitry = createClient(); // reads LIMITRY_API_KEY
25
+
26
+ try {
27
+ const reply = await limitry.guard(
28
+ { subject: { kind: "user", id: "usr_123" }, action: "ai-call" },
29
+ () => callModel(prompt),
30
+ );
31
+ } catch (error) {
32
+ if (error instanceof LimitExceeded) {
33
+ console.log(`Try again in ${error.retryAfterSeconds} seconds`);
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Charge what it actually cost
39
+
40
+ When you only know the cost afterwards, such as an AI reply priced by
41
+ the token, `hold` reserves an estimate (5 cents here), runs your code
42
+ and charges what it used. If your code throws, the hold is released:
43
+
9
44
  ```ts
10
45
  import { createClient } from "@limitry/sdk";
11
46
 
12
- // The key from LIMITRY_API_KEY, or pass { token }.
13
47
  const limitry = createClient();
48
+
49
+ const answer = await limitry.hold(
50
+ { subject: { kind: "user", id: "usr_123" }, action: "ai-call", estimate: 5 },
51
+ async (held) => {
52
+ const response = await callModel(prompt);
53
+ held.cost(priceCents(response.usage)); // your prices, in cents
54
+ return response;
55
+ },
56
+ );
14
57
  ```
15
58
 
16
- - Guide: https://limitry.com/docs/sdk/
17
- - API reference: https://api.limitry.com/v1/docs
59
+ If Limitry can't be reached, each limit's fail mode decides: `open` lets
60
+ the work run, `closed` refuses it.
18
61
 
19
- ## Building from this repository
62
+ ## Everything else
20
63
 
21
- ```bash
22
- npm ci && npm test && npm run build
64
+ Every API operation is a typed method, named like its CLI command:
65
+ `limitry limits create` is `limitry.limits.create()`.
66
+
67
+ ```ts
68
+ import { createClient } from "@limitry/sdk";
69
+
70
+ const limitry = createClient();
71
+
72
+ await limitry.limits.create({
73
+ name: "AI replies per day",
74
+ subjectKind: "user",
75
+ action: "ai-call",
76
+ amount: 100,
77
+ window: "day",
78
+ });
23
79
  ```
24
80
 
25
- This repository is generated from Limitry's own repository on
26
- each release; see CONTRIBUTING.md. Licensed under the Apache License 2.0.
81
+ A failure throws an `ApiError` with the error's `code`, `message`,
82
+ `status` and `requestId`. Writes are retried safely: each sends an
83
+ idempotency key, so a retried request happens once.
84
+
85
+ ## Links
86
+
87
+ - [Website](https://limitry.com)
88
+ - [TypeScript SDK guide](https://limitry.com/docs/sdk/)
89
+ - [API reference](https://limitry.com/docs/reference/)
90
+ - [Changelog](https://github.com/limitry/limitry-typescript/blob/main/CHANGELOG.md)
91
+ - [Discord](https://limitry.com/discord)
92
+ - [Report a security issue](https://limitry.com/security/)
93
+
94
+ ## About this package
95
+
96
+ This repository is generated from Limitry's source on each
97
+ release, so pull requests are ported there and credited (see
98
+ [CONTRIBUTING.md](https://github.com/limitry/limitry-typescript/blob/main/CONTRIBUTING.md)).
99
+ Licensed under the Apache License 2.0.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limitry/sdk",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.4",
4
4
  "description": "Limitry API client",
5
5
  "type": "module",
6
6
  "exports": {
@@ -11,7 +11,8 @@
11
11
  },
12
12
  "files": [
13
13
  "dist",
14
- "NOTICE"
14
+ "NOTICE",
15
+ "CHANGELOG.md"
15
16
  ],
16
17
  "scripts": {
17
18
  "build": "tsc -p tsconfig.build.json",