@turnstileai/sdk 0.1.5 → 0.1.7
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 +57 -5
- package/package.json +16 -2
package/README.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# @turnstileai/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
TypeScript SDK for TurnstileAI, a verification-first AI gateway for trustable completions, receipts, and on-chain proof.
|
|
8
|
+
|
|
9
|
+
Repository: https://github.com/turnstileai/TurnstileAI
|
|
10
|
+
|
|
11
|
+
## Why TurnstileAI
|
|
12
|
+
|
|
13
|
+
TurnstileAI is designed for applications that want more than plain text completions. It adds verification-oriented records, provider visibility, and optional Solana-backed checkpoints so inference can be easier to inspect, trust, and audit.
|
|
4
14
|
|
|
5
15
|
## Installation
|
|
6
16
|
|
|
@@ -34,7 +44,30 @@ console.log(JSON.stringify(result.record, null, 2));
|
|
|
34
44
|
console.log(JSON.stringify(result.verification, null, 2));
|
|
35
45
|
```
|
|
36
46
|
|
|
37
|
-
##
|
|
47
|
+
## Full Example
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { TurnstileAI } from "@turnstileai/sdk";
|
|
51
|
+
|
|
52
|
+
const client = new TurnstileAI({
|
|
53
|
+
apiKey: process.env.TURNSTILEAI_API_KEY!
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const result = await client.chat({
|
|
57
|
+
model: "openrouter/llama-3.1-70b",
|
|
58
|
+
messages: [
|
|
59
|
+
{ role: "user", content: "Summarize why Solana finality matters." }
|
|
60
|
+
],
|
|
61
|
+
receipt: true,
|
|
62
|
+
anchor: "solana"
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
console.log(result.output);
|
|
66
|
+
console.log(result.record?.id);
|
|
67
|
+
console.log(result.verification?.status);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Sandboxed Local Testing
|
|
38
71
|
|
|
39
72
|
If the SDK detects an API key starting with `ts_test_` or the environment variable `TURNSTILEAI_MOCK=true` is set, it can fall back to local mock mode for offline development and integration testing.
|
|
40
73
|
|
|
@@ -43,7 +76,7 @@ If the SDK detects an API key starting with `ts_test_` or the environment variab
|
|
|
43
76
|
| Parameter | Type | Description |
|
|
44
77
|
| --- | --- | --- |
|
|
45
78
|
| `apiKey` | `string` | Your TurnstileAI API key. |
|
|
46
|
-
| `baseURL` | `string` |
|
|
79
|
+
| `baseURL` | `string` | API base URL, defaults to `https://api.turnstileai.com/v1`. |
|
|
47
80
|
| `timeout` | `number` | Request timeout in milliseconds. |
|
|
48
81
|
| `defaultRouteMode` | `RouteMode` | Optional default routing strategy. |
|
|
49
82
|
| `defaultLedgerMode` | `LedgerMode` | Optional default ledger/checkpoint mode. |
|
|
@@ -58,8 +91,8 @@ If the SDK detects an API key starting with `ts_test_` or the environment variab
|
|
|
58
91
|
| `anchor` | `string` | `"off-chain"` | Checkpoint mode: `"solana"`, `"off-chain"`, or `"none"`. |
|
|
59
92
|
| `routeMode` | `string` | `"trust-first"` | Routing strategy for provider selection. |
|
|
60
93
|
| `provider` | `string` | Optional | Pin inference to a provider. |
|
|
61
|
-
| `maxSpendUsd` | `number` | Optional |
|
|
62
|
-
| `temperature` | `number` | Optional | Sampling temperature
|
|
94
|
+
| `maxSpendUsd` | `number` | Optional | Maximum spend cap for a request. |
|
|
95
|
+
| `temperature` | `number` | Optional | Sampling temperature. |
|
|
63
96
|
| `maxTokens` | `number` | Optional | Output token limit. |
|
|
64
97
|
|
|
65
98
|
## Record APIs
|
|
@@ -82,6 +115,25 @@ turnstileai providers list --key=ts_live_xxx
|
|
|
82
115
|
turnstileai usage overview --key=ts_live_xxx
|
|
83
116
|
```
|
|
84
117
|
|
|
118
|
+
## Development
|
|
119
|
+
|
|
120
|
+
Build the package:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm run build
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Run tests:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npm test
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Repository
|
|
133
|
+
|
|
134
|
+
- GitHub: https://github.com/turnstileai/TurnstileAI
|
|
135
|
+
- Issues: https://github.com/turnstileai/TurnstileAI/issues
|
|
136
|
+
|
|
85
137
|
## License
|
|
86
138
|
|
|
87
139
|
MIT
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turnstileai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"description": "TypeScript SDK for TurnstileAI, a verification-first AI gateway",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"bin": {
|
|
@@ -19,11 +19,25 @@
|
|
|
19
19
|
"keywords": [
|
|
20
20
|
"ai",
|
|
21
21
|
"sdk",
|
|
22
|
+
"solana",
|
|
23
|
+
"verification",
|
|
22
24
|
"llm",
|
|
23
25
|
"typescript",
|
|
24
26
|
"turnstileai"
|
|
25
27
|
],
|
|
28
|
+
"author": "TurnstileAI",
|
|
26
29
|
"license": "MIT",
|
|
30
|
+
"homepage": "https://github.com/turnstileai/TurnstileAI",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/turnstileai/TurnstileAI.git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/turnstileai/TurnstileAI/issues"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
40
|
+
},
|
|
27
41
|
"dependencies": {
|
|
28
42
|
"openai": "^4.0.0"
|
|
29
43
|
},
|