@verial-ai/sdk 0.1.0 → 0.3.0
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 +176 -0
- package/dist/cli/index.js +736 -293
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +300 -86
- package/dist/index.js +308 -34
- package/dist/index.js.map +1 -1
- package/package.json +15 -4
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# @verial-ai/sdk
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@verial-ai/sdk)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
TypeScript SDK and CLI for [Verial](https://verial.ai), the healthcare agent simulation and testing platform.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @verial-ai/sdk
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- Node.js 18+
|
|
17
|
+
- ESM only (`"type": "module"` in your package.json)
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
Create an environment, add a simulator, define a benchmark with evals, run it, and check results:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { Verial } from "@verial-ai/sdk";
|
|
25
|
+
|
|
26
|
+
const verial = new Verial({ apiKey: process.env.VERIAL_API_KEY });
|
|
27
|
+
|
|
28
|
+
// 1. Create an environment (a simulated health system)
|
|
29
|
+
const env = await verial.environments.create({
|
|
30
|
+
name: "Cardiology Clinic",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// 2. Add a FHIR simulator to the environment
|
|
34
|
+
const sim = await verial.simulators.create({
|
|
35
|
+
type: "FHIR",
|
|
36
|
+
name: "Primary EHR",
|
|
37
|
+
});
|
|
38
|
+
await verial.environments.addSimulator({
|
|
39
|
+
environmentId: env.id,
|
|
40
|
+
simulatorId: sim.id,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// 3. Create a benchmark with a task and eval
|
|
44
|
+
const benchmark = await verial.benchmarks.create({
|
|
45
|
+
name: "Prior Auth Workflow",
|
|
46
|
+
environmentId: env.id,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const task = await verial.tasks.create({
|
|
50
|
+
benchmarkId: benchmark.id,
|
|
51
|
+
name: "Submit prior auth for MRI",
|
|
52
|
+
instruction: "Submit a prior authorization request for a brain MRI",
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
await verial.evals.create({
|
|
56
|
+
taskId: task.id,
|
|
57
|
+
label: "Prior auth submitted",
|
|
58
|
+
assert: "A prior authorization request was successfully submitted for the MRI",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// 4. Run the benchmark
|
|
62
|
+
const run = await verial.runs.create({ benchmarkId: benchmark.id });
|
|
63
|
+
|
|
64
|
+
// 5. Check results
|
|
65
|
+
const result = await verial.runs.get({ id: run.id });
|
|
66
|
+
console.log(result.verdict, result.score);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Authentication
|
|
70
|
+
|
|
71
|
+
Get your API key from the [Verial dashboard](https://app.verial.ai), then pass it to the client:
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const verial = new Verial({ apiKey: "your-api-key" });
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or set it via the CLI:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
verial auth set-key your-api-key
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Common Use Cases
|
|
84
|
+
|
|
85
|
+
### Run a benchmark
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const run = await verial.runs.create({ benchmarkId: "bench_abc123" });
|
|
89
|
+
const result = await verial.runs.get({ id: run.id });
|
|
90
|
+
|
|
91
|
+
// Inspect individual task results
|
|
92
|
+
const { data: taskRuns } = await verial.taskRuns.list({ runId: run.id });
|
|
93
|
+
for (const tr of taskRuns) {
|
|
94
|
+
const { data: evalRuns } = await verial.evalRuns.list({ taskRunId: tr.id });
|
|
95
|
+
console.log(tr.name, evalRuns.map((e) => e.verdict));
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Create a playground for manual testing
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
const playground = await verial.playgrounds.create({
|
|
103
|
+
environmentId: "env_abc123",
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Access provisioned sandboxes (FHIR stores, voice lines, etc.)
|
|
107
|
+
const pg = await verial.playgrounds.get({ id: playground.id });
|
|
108
|
+
console.log(pg.sandboxes);
|
|
109
|
+
|
|
110
|
+
// Clean up when done
|
|
111
|
+
await verial.playgrounds.teardown({ id: playground.id });
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Generate synthetic data
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
const dataset = await verial.datasets.create({ name: "Diabetic cohort" });
|
|
118
|
+
await verial.datasets.generate({
|
|
119
|
+
id: dataset.id,
|
|
120
|
+
prompt: "10 patients with Type 2 diabetes, ages 45-70",
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Error Handling
|
|
125
|
+
|
|
126
|
+
All API errors throw `VerialApiError` with structured fields:
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import { Verial, VerialApiError } from "@verial-ai/sdk";
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
await verial.environments.get({ id: "nonexistent" });
|
|
133
|
+
} catch (err) {
|
|
134
|
+
if (err instanceof VerialApiError) {
|
|
135
|
+
console.error(err.status); // 404
|
|
136
|
+
console.error(err.code); // "NOT_FOUND"
|
|
137
|
+
console.error(err.message); // "Environment not found"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## CLI
|
|
143
|
+
|
|
144
|
+
The package includes a CLI for managing resources from the terminal.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Install globally
|
|
148
|
+
npm install -g @verial-ai/sdk
|
|
149
|
+
|
|
150
|
+
# Authenticate
|
|
151
|
+
verial auth set-key your-api-key
|
|
152
|
+
|
|
153
|
+
# Manage resources
|
|
154
|
+
verial environments list
|
|
155
|
+
verial benchmarks list
|
|
156
|
+
verial runs create --benchmark-id bench_abc123
|
|
157
|
+
verial runs get run_abc123
|
|
158
|
+
verial playgrounds create --environment-id env_abc123
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Run `verial --help` or `verial <command> --help` for all available commands.
|
|
162
|
+
|
|
163
|
+
## Configuration
|
|
164
|
+
|
|
165
|
+
| Option | Default | Description |
|
|
166
|
+
| --------- | ------------------------ | ----------------- |
|
|
167
|
+
| `apiKey` | (required) | Your Verial API key |
|
|
168
|
+
| `baseUrl` | `https://api.verial.ai` | API base URL |
|
|
169
|
+
|
|
170
|
+
## Documentation
|
|
171
|
+
|
|
172
|
+
For complete API reference and guides, visit [docs.verial.ai](https://docs.verial.ai).
|
|
173
|
+
|
|
174
|
+
## License
|
|
175
|
+
|
|
176
|
+
MIT
|