@tessera-llm/mastra 0.1.0 → 0.1.1
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 +39 -26
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# `@tessera-llm/mastra`
|
|
2
2
|
|
|
3
|
-
**Drop-in cost optimization for the [Mastra](https://mastra.ai) agent framework.** One line of config routes every Mastra Agent's LLM calls through the [Tessera](https://tesseraai.io) optimization proxy
|
|
3
|
+
**Drop-in cost optimization for the [Mastra](https://mastra.ai) agent framework.** One line of config routes every Mastra Agent's LLM calls through the [Tessera](https://tesseraai.io) optimization proxy: auto-route to cheaper-equivalent models, exact + provider-prompt-cache hits, prompt compression with per-stack quality canary, batch arbitrage on async-tolerant calls. Free Sandbox tier: **60M tokens/month, no card**. Production: **20% of measured savings, $0 if we save you nothing**.
|
|
4
4
|
|
|
5
5
|
<!-- COMPANION-PACKAGES-START -->
|
|
6
|
-
Companion to [`tessera-sdk`](https://github.com/tessera-llm/tessera-sdk) (vanilla provider SDKs), [`tessera-langchain`](https://github.com/tessera-llm/tessera-langchain) (LangChain integration), [`tessera-vercel-ai`](https://github.com/tessera-llm/tessera-vercel-ai) (Vercel AI SDK integration), [`tessera-llamaindex`](https://github.com/tessera-llm/tessera-llamaindex) (LlamaIndex integration), [`tessera-pydantic-ai`](https://
|
|
6
|
+
Companion to [`tessera-sdk`](https://github.com/tessera-llm/tessera-sdk) (vanilla provider SDKs), [`tessera-langchain`](https://github.com/tessera-llm/tessera-langchain) (LangChain integration), [`tessera-vercel-ai`](https://github.com/tessera-llm/tessera-vercel-ai) (Vercel AI SDK integration), [`tessera-llamaindex`](https://github.com/tessera-llm/tessera-llamaindex) (LlamaIndex integration), [`tessera-pydantic-ai`](https://pypi.org/project/tessera-pydantic-ai/) (Pydantic AI integration), [`tessera-crewai`](https://pypi.org/project/tessera-crewai/) (CrewAI multi-agent integration), and [`tessera-autogen`](https://pypi.org/project/tessera-autogen/) (AutoGen 0.4+ multi-agent integration). Same proxy, same mechanic stack, Mastra-shaped API.
|
|
7
7
|
<!-- COMPANION-PACKAGES-END -->
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/@tessera-llm/mastra) [](LICENSE)
|
|
@@ -61,9 +61,9 @@ npm install @tessera-llm/mastra @mastra/core
|
|
|
61
61
|
npm install @ai-sdk/openai # or @ai-sdk/anthropic / @ai-sdk/mistral / @ai-sdk/groq / @ai-sdk/cohere
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
The `@ai-sdk/*` and `@mastra/core` packages are peer dependencies
|
|
64
|
+
The `@ai-sdk/*` and `@mastra/core` packages are peer dependencies. Install only the providers you actually use. The Mastra core SDK is whatever version you already have on the project.
|
|
65
65
|
|
|
66
|
-
Get a free Tessera API key (60M tokens/mo, no card) at **[tesseraai.io/dev](https://tesseraai.io/dev)
|
|
66
|
+
Get a free Tessera API key (60M tokens/mo, no card) at **[tesseraai.io/dev](https://tesseraai.io/dev)**. Sign-up takes ~30 seconds and returns an instant `tk_…` key plus magic-link dashboard access.
|
|
67
67
|
|
|
68
68
|
---
|
|
69
69
|
|
|
@@ -77,7 +77,7 @@ Get a free Tessera API key (60M tokens/mo, no card) at **[tesseraai.io/dev](http
|
|
|
77
77
|
| Groq | `@ai-sdk/groq` | `tesseraGroqConfig` | `tesseraGroq` |
|
|
78
78
|
| Cohere | `@ai-sdk/cohere` | `tesseraCohereConfig` | `tesseraCohere` |
|
|
79
79
|
|
|
80
|
-
Generic dispatcher available too: `tesseraConfig("openai", { apiKey: "
|
|
80
|
+
Generic dispatcher available too: `tesseraConfig("openai", { apiKey: "tk_..." })` returns the right `{ baseURL, headers }` object regardless of provider. Useful when the provider is parameterized at runtime.
|
|
81
81
|
|
|
82
82
|
---
|
|
83
83
|
|
|
@@ -87,12 +87,12 @@ Real customer-support agent on `gpt-4o`, 5B tokens/month, OpenAI list prices:
|
|
|
87
87
|
|
|
88
88
|
| Stage | Cost / mo | Saved |
|
|
89
89
|
|---|---:|---:|
|
|
90
|
-
| Baseline
|
|
90
|
+
| Baseline (OpenAI direct via Mastra) | $24,000 | n/a |
|
|
91
91
|
| + Tessera (route, cache, prompt-cache headers, compress, M9 ceiling, batch) | $9,400 | $14,600 |
|
|
92
|
-
| Tessera fee (20% × savings) | $2,920 |
|
|
92
|
+
| Tessera fee (20% × savings) | $2,920 | n/a |
|
|
93
93
|
| **You net pay** | **$12,320** | **$11,680 / mo saved** |
|
|
94
94
|
|
|
95
|
-
Quality canary across the full mechanic stack: mean-score 0.96 (floor 0.95)
|
|
95
|
+
Quality canary across the full mechanic stack: mean-score 0.96 (floor 0.95). 0.95 SLA held all 30 days. Full breakdown: [worked example with mechanic-level numbers + canary results](https://tesseraai.io/blog/cut-openai-bill-48-percent-without-quality-regression).
|
|
96
96
|
|
|
97
97
|
---
|
|
98
98
|
|
|
@@ -105,21 +105,21 @@ Same mechanic stack as the main [`tessera-sdk`](https://github.com/tessera-llm/t
|
|
|
105
105
|
| **Auto-route** <sub>(m1)</sub> | Route to a cheaper-equivalent model gated by a daily promptfoo canary on your eval set | 15–35% on routed calls |
|
|
106
106
|
| **Auto-cache** <sub>(m2)</sub> | sha256 cache on the canonical request body, 7-day TTL, Cloudflare edge KV | 5–40% depending on prompt repetition |
|
|
107
107
|
| **Auto-compress** <sub>(m3)</sub> | Per-role heuristic compression (system + user toggles independent). Preserves code fences and JSON shapes. | 5–15% on prompt tokens |
|
|
108
|
-
| **Prompt cache** <sub>(m6)</sub> | Inject provider-native cache headers
|
|
108
|
+
| **Prompt cache** <sub>(m6)</sub> | Inject provider-native cache headers: OpenAI cached-input (50% off), Anthropic `cache_control: ephemeral` (90% off cache reads) | 50–90% on cached prefixes |
|
|
109
109
|
| **Context prune** <sub>(m7)</sub> | Conservative trim on long conversations (system + last 8 turns; TF-IDF rerank on RAG attachments) | 5–25% on multi-turn workloads |
|
|
110
110
|
| **Output-length ceiling** <sub>(m9)</sub> | Daily compute fits p90 of completion length per workload, injects `maxTokens = p90 × 1.3` | 5–15% on completion cost |
|
|
111
111
|
| **Batch arbitrage** <sub>(m10)</sub> | Route async-tolerant Agent calls to provider Batch APIs (OpenAI Batch + Anthropic Message Batches both 50% off) | 50% on batch-eligible traffic |
|
|
112
112
|
| **Cross-provider failover** <sub>(m11)</sub> | When primary upstream returns 5xx / connection error / timeout, retry on OpenRouter (opt-in, default OFF) | Reliability primitive, n/a cost |
|
|
113
|
-
| **Per-provider circuit breaker** | Rolling 5xx-rate state machine per upstream
|
|
113
|
+
| **Per-provider circuit breaker** | Rolling 5xx-rate state machine per upstream. When a provider degrades, auto-route skips its intra-provider alternative mappings until the half-open probe succeeds. | n/a (keeps the savings stack honest) |
|
|
114
114
|
|
|
115
115
|
---
|
|
116
116
|
|
|
117
117
|
## Pricing
|
|
118
118
|
|
|
119
|
-
- **Free
|
|
120
|
-
- **Production
|
|
119
|
+
- **Free Sandbox**: 60M tokens/month, 30 requests/minute, observability-only mechanics, no card. Forever.
|
|
120
|
+
- **Production**: over 60M tokens/month or higher rate limit. **20% of measured savings only.** Zero savings, zero fee. Prepaid Stripe balance, $100 minimum top-up. No subscription, no commit, no minimum monthly.
|
|
121
121
|
|
|
122
|
-
Existing customers of `tessera-sdk`, `tessera-langchain`, `tessera-llamaindex`, or `tessera-vercel-ai` keep their `rate_locked_pct` (if any) on this package too
|
|
122
|
+
Existing customers of `tessera-sdk`, `tessera-langchain`, `tessera-llamaindex`, or `tessera-vercel-ai` keep their `rate_locked_pct` (if any) on this package too. Same `tk_…` key, same billing record.
|
|
123
123
|
|
|
124
124
|
---
|
|
125
125
|
|
|
@@ -129,29 +129,29 @@ Existing customers of `tessera-sdk`, `tessera-langchain`, `tessera-llamaindex`,
|
|
|
129
129
|
|
|
130
130
|
Same proxy. Same mechanics. Same billing. The five packages target different code surfaces:
|
|
131
131
|
|
|
132
|
-
- **`tessera-sdk
|
|
133
|
-
- **`tessera-langchain
|
|
134
|
-
- **`tessera-llamaindex
|
|
135
|
-
- **`tessera-vercel-ai
|
|
136
|
-
- **`tessera-mastra`** *(this package)
|
|
132
|
+
- **`tessera-sdk`**: patches the underlying provider client constructors (OpenAI, Anthropic, etc.) directly via `tessera.activate(key)`. Use when calling provider SDKs without a framework.
|
|
133
|
+
- **`tessera-langchain`**: wires into LangChain ChatModel constructors. Use when you're on LangChain.
|
|
134
|
+
- **`tessera-llamaindex`**: wires into LlamaIndex `LLM` adapter constructors. Use when you're on LlamaIndex.
|
|
135
|
+
- **`tessera-vercel-ai`**: wires into the Vercel AI SDK provider factories. Use when you're on `ai` core + `@ai-sdk/*` without Mastra.
|
|
136
|
+
- **`tessera-mastra`** *(this package)*: same Vercel AI SDK provider factory shape, Mastra-shaped README and E2E gate. Use when you're on Mastra Agents.
|
|
137
137
|
|
|
138
|
-
Pick whichever fits your codebase. Side-by-side install is supported
|
|
138
|
+
Pick whichever fits your codebase. Side-by-side install is supported: all five resolve to the same proxy and same billing record.
|
|
139
139
|
|
|
140
140
|
### Q: Does this break my Agent tools / structured outputs / streaming / RAG?
|
|
141
141
|
|
|
142
|
-
No. The Vercel AI SDK provider object that Mastra accepts is unchanged in shape
|
|
142
|
+
No. The Vercel AI SDK provider object that Mastra accepts is unchanged in shape (`agent.generate()`, `agent.stream()`, `generateObject`, schema-constrained tool calls, and RAG retrieval workflows all work unchanged). Auto-route gates on tool-calling capability so an agent using tools never gets routed to a non-tool-capable model.
|
|
143
143
|
|
|
144
144
|
### Q: Does this work with Mastra's string-shorthand model ID (`"openai/gpt-4o"`)?
|
|
145
145
|
|
|
146
|
-
Not directly. Mastra's string shorthand uses environment variables like `OPENAI_API_KEY` against the provider's canonical endpoint. Tessera needs a custom `baseURL` + custom `x-tessera-api-key` header, which the string shorthand doesn't surface. Use the AI SDK provider factory form (shown in the examples above)
|
|
146
|
+
Not directly. Mastra's string shorthand uses environment variables like `OPENAI_API_KEY` against the provider's canonical endpoint. Tessera needs a custom `baseURL` + custom `x-tessera-api-key` header, which the string shorthand doesn't surface. Use the AI SDK provider factory form (shown in the examples above); Mastra accepts it as a first-class alternative to the string shorthand.
|
|
147
147
|
|
|
148
148
|
### Q: What happens if Tessera's proxy is down?
|
|
149
149
|
|
|
150
|
-
Your Agent gets HTTP errors instead of LLM responses. On the proxy side, a per-provider circuit breaker tracks rolling 5xx rates and skips degraded providers in auto-route decisions. Cross-provider failover (m11) is opt-in and re-routes to OpenRouter when the primary upstream is down
|
|
150
|
+
Your Agent gets HTTP errors instead of LLM responses. On the proxy side, a per-provider circuit breaker tracks rolling 5xx rates and skips degraded providers in auto-route decisions. Cross-provider failover (m11) is opt-in and re-routes to OpenRouter when the primary upstream is down. See the workload toggle in the dashboard.
|
|
151
151
|
|
|
152
152
|
### Q: What happens to my OpenAI / Anthropic rate limits?
|
|
153
153
|
|
|
154
|
-
They pass through. Tessera does not aggregate quotas across customers. Your provider rate limits apply normally; the proxy enforces only the Tessera tier limits (30 rpm Free
|
|
154
|
+
They pass through. Tessera does not aggregate quotas across customers. Your provider rate limits apply normally; the proxy enforces only the Tessera tier limits (30 rpm Free Sandbox, 60 rpm Production by default; higher on request).
|
|
155
155
|
|
|
156
156
|
### Q: Are you storing my prompts and completions?
|
|
157
157
|
|
|
@@ -159,7 +159,7 @@ No. We log only token counts, cost deltas, mechanics_stack, and provider respons
|
|
|
159
159
|
|
|
160
160
|
### Q: Why are there two API surfaces (`tesseraOpenAIConfig` vs `tesseraOpenAI`)?
|
|
161
161
|
|
|
162
|
-
The config function returns the kwargs object you spread into `createOpenAI(...)
|
|
162
|
+
The config function returns the kwargs object you spread into `createOpenAI(...)`: explicit, easy to combine with other settings (organization, custom fetch, etc.). The convenience factory imports `createOpenAI` for you and pre-merges. Use whichever you find more readable. Both ship in the same package.
|
|
163
163
|
|
|
164
164
|
---
|
|
165
165
|
|
|
@@ -168,7 +168,20 @@ The config function returns the kwargs object you spread into `createOpenAI(...)
|
|
|
168
168
|
- **Dashboard + free signup:** [tesseraai.io/dev](https://tesseraai.io/dev)
|
|
169
169
|
- **How it works (per-mechanic deep dives):** [tesseraai.io/how-it-works](https://tesseraai.io/how-it-works)
|
|
170
170
|
- **Security + data handling:** [tesseraai.io/security](https://tesseraai.io/security)
|
|
171
|
-
- **Worked-numbers blog post:** [
|
|
171
|
+
- **Worked-numbers blog post:** [Customer-support workload, 48% saved, quality held](https://tesseraai.io/blog/cut-openai-bill-48-percent-without-quality-regression)
|
|
172
172
|
- **Mastra docs:** [mastra.ai](https://mastra.ai)
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## About Tessera
|
|
177
|
+
|
|
178
|
+
Tessera is the **substrate layer** for **LLM cost optimization**, also called the **Optimize Layer** in our product surface. A thin proxy that sits in your application's **request-path**, applies a conservative cascade of optimization mechanics, and measures every saved dollar against an **audit-immutable** baseline. We bill **20% of verified savings**, prepaid. Zero savings = zero fee. No per-token gateway fee, no subscription, no minimum monthly commitment; the category we operate in is "**success-fee LLM optimizer**," distinct from per-token **AI gateways** and observability dashboards.
|
|
179
|
+
|
|
180
|
+
Where observability tools tell you what you spent and AI gateways re-shape the request without measuring the cost delta, Tessera is the layer that does both, and only takes a cut when the measured savings are positive. The **verified-savings ledger** at [`ledger.tesseraai.io`](https://ledger.tesseraai.io) shows every original-vs-actual cost pair, snapshot-pinned to a `pricing_catalog` version captured at request time. Mid-contract price changes don't retroactively alter past savings. This is the **FinOps**-friendly model for AI inference: every line of the bill traces to a code-enforced rule.
|
|
181
|
+
|
|
182
|
+
Apache-2.0. Operated by Fintechagency OÜ (Tallinn, Estonia, registry code 16638667). Issues: [github.com/tessera-llm/tessera-mastra/issues](https://github.com/tessera-llm/tessera-mastra/issues).
|
|
183
|
+
|
|
184
|
+
- Developer entry: [tesseraai.io/dev](https://tesseraai.io/dev)
|
|
185
|
+
- Mechanic reference: [tesseraai.io/how-it-works](https://tesseraai.io/how-it-works)
|
|
186
|
+
- Dashboard: [ledger.tesseraai.io](https://ledger.tesseraai.io)
|
|
187
|
+
- Engineering blog: [tesseraai.io/blog](https://tesseraai.io/blog)
|
package/dist/index.d.cts
CHANGED
|
@@ -91,7 +91,7 @@ declare function tesseraConfig(provider: ProviderName, input: TesseraConfigInput
|
|
|
91
91
|
interface TesseraOpenAIFactoryInput {
|
|
92
92
|
/** Your OpenAI API key (sk-...). Stays in your env, forwarded upstream. */
|
|
93
93
|
openaiApiKey: string;
|
|
94
|
-
/** Your Tessera API key (
|
|
94
|
+
/** Your Tessera API key (tk_...). Get one at tesseraai.io/dev. */
|
|
95
95
|
tesseraApiKey: string;
|
|
96
96
|
/** Additional headers to merge with the Tessera auth header. */
|
|
97
97
|
extraHeaders?: Record<string, string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ declare function tesseraConfig(provider: ProviderName, input: TesseraConfigInput
|
|
|
91
91
|
interface TesseraOpenAIFactoryInput {
|
|
92
92
|
/** Your OpenAI API key (sk-...). Stays in your env, forwarded upstream. */
|
|
93
93
|
openaiApiKey: string;
|
|
94
|
-
/** Your Tessera API key (
|
|
94
|
+
/** Your Tessera API key (tk_...). Get one at tesseraai.io/dev. */
|
|
95
95
|
tesseraApiKey: string;
|
|
96
96
|
/** Additional headers to merge with the Tessera auth header. */
|
|
97
97
|
extraHeaders?: Record<string, string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tessera-llm/mastra",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Drop-in Tessera integration for the Mastra agent framework. One line of config routes every Mastra Agent's LLM calls through Tessera's auto-route + auto-cache + auto-compress + auto-batch proxy. Compatible with @ai-sdk/openai, @ai-sdk/anthropic, @ai-sdk/mistral, @ai-sdk/groq, @ai-sdk/cohere — Mastra's first-class AI SDK provider interop. Free 60M tokens/mo. Production: 20% of measured savings.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tessera",
|