tolvyn 1.0.6 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +105 -20
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,9 +1,11 @@
1
- # tolvyn · npm
1
+ # tolvyn
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/tolvyn.svg)](https://www.npmjs.com/package/tolvyn)
3
+ Drop-in replacement for `openai` and `@anthropic-ai/sdk`. One line change. Every AI call metered, attributed, and governed.
4
4
 
5
- Drop-in replacement for `openai` and `@anthropic-ai/sdk`.
6
- One line change. Every AI call metered, attributed, and governed.
5
+ [![npm](https://img.shields.io/npm/v/tolvyn.svg)](https://www.npmjs.com/package/tolvyn)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
+
8
+ **10,000 free requests forever. No credit card.**
7
9
 
8
10
  ## Install
9
11
 
@@ -11,6 +13,14 @@ One line change. Every AI call metered, attributed, and governed.
11
13
  npm install tolvyn
12
14
  ```
13
15
 
16
+ Node 18 or later required. Ships dual ESM/CJS builds. TypeScript types included.
17
+
18
+ Google support requires the optional peer dependency:
19
+
20
+ ```bash
21
+ npm install tolvyn @google/generative-ai
22
+ ```
23
+
14
24
  ## Quick start
15
25
 
16
26
  ```typescript
@@ -33,13 +43,6 @@ const response = await client.chat.completions.create({
33
43
  });
34
44
  ```
35
45
 
36
- Works the same way for Anthropic:
37
-
38
- ```typescript
39
- import { Anthropic } from "tolvyn";
40
- const client = new Anthropic({ tolvynApiKey: "tlv_live_...", team: "ml", service: "classifier" });
41
- ```
42
-
43
46
  CommonJS:
44
47
 
45
48
  ```javascript
@@ -47,17 +50,99 @@ const { OpenAI } = require("tolvyn");
47
50
  const client = new OpenAI({ tolvynApiKey: process.env.TOLVYN_API_KEY, team: "backend" });
48
51
  ```
49
52
 
50
- ## What you get
53
+ ## All three providers
54
+
55
+ ```typescript
56
+ import { OpenAI, Anthropic, Google } from "tolvyn";
57
+
58
+ // OpenAI
59
+ const oai = new OpenAI({
60
+ tolvynApiKey: "tlv_live_...",
61
+ openAIApiKey: "sk-...", // optional — enables fail-open fallback
62
+ });
63
+
64
+ // Anthropic
65
+ const anth = new Anthropic({
66
+ tolvynApiKey: "tlv_live_...",
67
+ anthropicApiKey: "sk-ant-...", // optional — enables fail-open fallback
68
+ });
69
+
70
+ // Google (requires @google/generative-ai peer dep)
71
+ const goog = new Google({ tolvynApiKey: "tlv_live_..." });
72
+ const model = goog.getGenerativeModel({ model: "gemini-1.5-flash" });
73
+ ```
74
+
75
+ ## Attribution headers
76
+
77
+ Set any combination of these on construction; the SDK sends them as `X-Tolvyn-*` headers automatically:
78
+
79
+ ```typescript
80
+ const client = new OpenAI({
81
+ tolvynApiKey: "tlv_live_...",
82
+ team: "backend",
83
+ service: "invoice-summarizer",
84
+ feature: "summarize",
85
+ agent: "claude-code",
86
+ user: "alice@company.com",
87
+ endCustomer: "acme-corp",
88
+ });
89
+ ```
90
+
91
+ The TOLVYN proxy strips all six headers before forwarding the request upstream — they never reach OpenAI/Anthropic/Google.
92
+
93
+ ## Fail-open behavior
94
+
95
+ If TOLVYN's proxy is unreachable, the SDK automatically retries the request directly against the provider (requires `openAIApiKey` / `anthropicApiKey` / `googleApiKey` to be set). Disable with `failOpen: false`.
96
+
97
+ Triggers on: connection refused, timeout, DNS failure, HTTP 503.
98
+ Does NOT trigger on: 4xx errors (auth failures, rate limits, bad requests).
99
+
100
+ Requests that fail open bypass the proxy and are not metered for that call.
101
+
102
+ ## Environment variables
103
+
104
+ | Variable | Required | Description |
105
+ |---|---|---|
106
+ | `TOLVYN_API_KEY` | Yes (unless `tolvynApiKey` option is passed) | Your TOLVYN API key (`tlv_live_...`) |
107
+ | `OPENAI_API_KEY` | For fail-open | Fallback OpenAI key if proxy unreachable |
108
+ | `ANTHROPIC_API_KEY` | For fail-open | Fallback Anthropic key if proxy unreachable |
109
+ | `GOOGLE_API_KEY` | For fail-open | Reserved; Google fail-open is implemented in v1.0.6+ |
110
+ | `TOLVYN_PROXY_URL` | No | Override proxy URL |
111
+
112
+ ## API keys
113
+
114
+ - Production keys start with `tlv_live_`
115
+ - Test keys start with `tlv_test_` (use these in CI / staging)
116
+ - Get your key at [app.tolvyn.io](https://app.tolvyn.io) → API Keys
117
+ - **Provider keys** (OpenAI / Anthropic / Google) go in the dashboard under **Account → Provider Keys** — never in code. They are stored encrypted server-side.
118
+
119
+ ## TypeScript
120
+
121
+ Fully typed. Import the option interfaces directly when you need them:
122
+
123
+ ```typescript
124
+ import type {
125
+ TolvynOpenAIOptions,
126
+ TolvynAnthropicOptions,
127
+ TolvynGoogleOptions,
128
+ } from "tolvyn";
129
+ ```
130
+
131
+ ## Changelog
132
+
133
+ [github.com/tolvyn/tolvyn-cli/releases](https://github.com/tolvyn/tolvyn-cli/releases)
134
+
135
+ ## Links
136
+
137
+ - Docs: [docs.tolvyn.io/sdks/nodejs](https://docs.tolvyn.io/sdks/nodejs)
138
+ - Quickstart: [docs.tolvyn.io/getting-started/quickstart](https://docs.tolvyn.io/getting-started/quickstart)
139
+ - Dashboard: [app.tolvyn.io](https://app.tolvyn.io)
140
+ - Issues: [github.com/tolvyn/tolvyn-nodejs/issues](https://github.com/tolvyn/tolvyn-nodejs/issues)
51
141
 
52
- - **Cost metering** — every request logged with exact token counts and cost in microdollars
53
- - **Team attribution** — see spend by team and service, not just a total invoice number
54
- - **Budget enforcement** — set hard limits that block requests before they hit your provider
55
- - **Immutable ledger** — hash-chained audit trail, verifiable at any time
56
- - **Drop-in** — no changes to your existing API calls, models, or response handling
142
+ ## Feedback
57
143
 
58
- Full docs: [docs.tolvyn.io/nodejs-sdk](https://docs.tolvyn.io/nodejs-sdk)
59
- Free trial: [tolvyn.io](https://tolvyn.io)
144
+ [founder@tolvyn.io](mailto:founder@tolvyn.io) — we read every message.
60
145
 
61
146
  ---
62
147
 
63
- © 2026 TOLVYN. All rights reserved.
148
+ © 2026 TOLVYN. MIT licensed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tolvyn",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Drop-in replacement for the OpenAI/Anthropic SDK — routes through TOLVYN for cost attribution, budget enforcement, and audit logging.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",