@turnstileai/sdk 0.1.3 → 0.1.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.
package/README.md CHANGED
@@ -1,10 +1,8 @@
1
1
  # @turnstileai/sdk
2
2
 
3
- TypeScript SDK for TurnstileAI, a verification-first AI gateway.
3
+ TypeScript SDK for TurnstileAI.
4
4
 
5
- TurnstileAI sits between your application and model providers, then returns
6
- structured run records with routing, latency, usage, cost, digests, signatures,
7
- and optional ledger checkpoints.
5
+ TurnstileAI is a verification-focused AI gateway SDK for working with routed model requests, run records, provider health, and usage analytics.
8
6
 
9
7
  ## Install
10
8
 
@@ -15,48 +13,48 @@ npm install @turnstileai/sdk
15
13
  ## Quick start
16
14
 
17
15
  ```ts
18
- import OpenAI from "openai";
16
+ import { TurnstileAI } from "@turnstileai/sdk";
19
17
 
20
- const client = new OpenAI({
21
- apiKey: process.env.TURNSTILEAI_API_KEY,
22
- baseURL: "https://api.turnstileai.com/v1"
18
+ const client = new TurnstileAI({
19
+ apiKey: process.env.TURNSTILEAI_API_KEY!
23
20
  });
21
+ ```
24
22
 
25
- const response = await client.chat.completions.create({
26
- model: "openrouter/llama-3.1-70b",
27
- messages: [
28
- { role: "user", content: "Explain Solana finality simply." }
29
- ],
30
- extra_body: {
31
- checkpoint: true,
32
- ledger: "solana",
33
- routeMode: "trust-first"
34
- }
35
- });
23
+ ## Fetch a run record
36
24
 
37
- console.log(response.choices.message.content);
38
- console.log(response.run_record);
25
+ ```ts
26
+ const record = await client.records.get("rr_123");
27
+ console.log(record);
39
28
  ```
40
29
 
41
- ## SDK client
30
+ ## Verify a run record
42
31
 
43
32
  ```ts
44
- import { TurnstileAI } from "@turnstileai/sdk";
33
+ const verification = await client.records.verify("rr_123");
34
+ console.log(verification.status);
35
+ ```
45
36
 
46
- const client = new TurnstileAI({
47
- apiKey: process.env.TURNSTILEAI_API_KEY!
48
- });
37
+ ## List providers
49
38
 
50
- const record = await client.records.get("rr_123");
51
- const verification = await client.records.verify("rr_123");
39
+ ```ts
52
40
  const providers = await client.providers.list();
41
+ console.log(providers);
42
+ ```
43
+
44
+ ## Usage overview
45
+
46
+ ```ts
53
47
  const usage = await client.usage.overview("month");
48
+ console.log(usage);
54
49
  ```
55
50
 
56
51
  ## CLI
57
52
 
53
+ After installing globally or linking locally, you can use:
54
+
58
55
  ```bash
59
56
  turnstileai auth check --key=ts_live_xxx
57
+ turnstileai record get rr_123 --key=ts_live_xxx
60
58
  turnstileai record list --key=ts_live_xxx
61
59
  turnstileai record verify rr_123 --key=ts_live_xxx
62
60
  turnstileai providers list --key=ts_live_xxx
@@ -75,4 +73,27 @@ turnstileai usage overview --key=ts_live_xxx
75
73
  ## Ledger modes
76
74
 
77
75
  - `none`
78
- - `solana`
76
+ - `solana`
77
+
78
+ ## Development
79
+
80
+ Build the package:
81
+
82
+ ```bash
83
+ npm run build
84
+ ```
85
+
86
+ Run tests:
87
+
88
+ ```bash
89
+ npm test
90
+ ```
91
+
92
+ ## Publish updates
93
+
94
+ When you change the SDK or README, publish a new version:
95
+
96
+ ```bash
97
+ npm version patch
98
+ npm publish --access public
99
+ ```
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_test_1 = __importDefault(require("node:test"));
7
+ const strict_1 = __importDefault(require("node:assert/strict"));
8
+ const client_1 = require("../client");
9
+ (0, node_test_1.default)("TurnstileAI throws when apiKey is missing", () => {
10
+ strict_1.default.throws(() => {
11
+ new client_1.TurnstileAI({ apiKey: "" });
12
+ }, /Missing TurnstileAI API key/);
13
+ });
14
+ (0, node_test_1.default)("TurnstileAI creates a client with valid apiKey", () => {
15
+ const client = new client_1.TurnstileAI({ apiKey: "ts_test_123" });
16
+ strict_1.default.ok(client);
17
+ strict_1.default.ok(client.records);
18
+ strict_1.default.ok(client.providers);
19
+ strict_1.default.ok(client.usage);
20
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turnstileai/sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Original TypeScript SDK for TurnstileAI",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,6 +13,7 @@
13
13
  ],
14
14
  "scripts": {
15
15
  "build": "tsc",
16
+ "test": "npm run build && node --test dist/test/**/*.test.js",
16
17
  "prepublishOnly": "npm run build"
17
18
  },
18
19
  "keywords": [
@@ -24,10 +25,10 @@
24
25
  ],
25
26
  "license": "MIT",
26
27
  "dependencies": {
27
- "openai": "^6.44.0"
28
+ "openai": "^4.0.0"
28
29
  },
29
30
  "devDependencies": {
30
- "@types/node": "^26.0.0",
31
- "typescript": "^6.0.3"
31
+ "@types/node": "^24.0.0",
32
+ "typescript": "^5.0.0"
32
33
  }
33
34
  }