@extrafemi-ai/lodestone 0.8.0 → 0.8.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/CHANGELOG.md +5 -0
- package/README.md +1 -0
- package/dist/errors.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lodestone.js +4 -1
- package/dist/providers/openaiCompatible.d.ts +4 -0
- package/dist/providers/openaiCompatible.js +21 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Versions before 1.0 may change between minor releases; each change that could break a caller is marked **breaking**.
|
|
4
4
|
|
|
5
|
+
## 0.8.1
|
|
6
|
+
|
|
7
|
+
- **`cencori()` preset** (TypeScript and Python) for [Cencori](https://cencori.com), a gateway to chat models from several labs with an OpenAI-compatible endpoint (`api.cencori.com/v1`). Use it as a `fallbacks` entry. It is a preset only: a key was accepted and its model list read on 4 Nov 2026 (95 entries: Lodestone keeps the available chat models, with price and context, and leaves out image and unavailable ones, so `discover: { fill }` works with it), but the first chat call was refused with 403 `credit_balance_exhausted`, so no answer has been seen from it. Its docs say it logs the full prompt and response of every request and are silent on training and retention, so a `private` call skips it unless you vouch for it. `scripts/live-check.mjs` takes `CENCORI_API_KEY` (and `CENCORI_MODEL`).
|
|
8
|
+
- **Fixed: a provider with no credit left is now reported as `kind: 'credit'`.** The kind existed, with a sentence for the person, but was never produced, so a provider's "credit exhausted" came out as `other` and the generic "something went wrong". It is now produced for a 402, and for a 403 whose own words are about credit, balance, quota or billing (Cencori and OmniaKey both answer 403); any other 403 is still `other`. Python: the same.
|
|
9
|
+
|
|
5
10
|
## 0.8.0
|
|
6
11
|
|
|
7
12
|
- **A spend share for each caller.** `createSpendLimit({ perCaller: { dailyUsd, monthlyUsd } })` gives each caller (`caller` on the call; only a hash is stored) their own share of the pool, so one person cannot use it up for everyone. A call over its share fails with `kind: 'budget'` and `detail.scope: 'caller'` (`'app'` when the whole pool ran out); `explain()` words each. `spendCap` on a call lets a person lower their own share, never raise it. `spend.callerReport(caller)` says what they have used. A custom `SpendControl` can implement `refusal(id)` to report the scope.
|
package/README.md
CHANGED
|
@@ -171,6 +171,7 @@ OpenRouter is the default, but one provider's outage should not stop your tool.
|
|
|
171
171
|
| `llmapi()` | [LLM API](https://llmapi.ai) | Gateway to 150+ chat models. Lists price; ignores its image, video and speech models. |
|
|
172
172
|
| `groq()`, `cerebras()` | Groq, Cerebras | Fast inference with free tiers. Use `free: true` so they are not counted against a spend limit. |
|
|
173
173
|
| `omniakey()` | [OmniaKey](https://omniakey.com) | A prepaid gateway for text, image, video and music models, with an OpenAI-compatible text endpoint. Text and JSON calls only here. Its model list needs a key and mixes chat with image, video and music models, so name your models. Not yet called live: the account's first chat call was refused for insufficient quota. |
|
|
174
|
+
| `cencori()` | [Cencori](https://cencori.com) | A gateway to chat models from OpenAI, Anthropic, Google, xAI, Mistral, DeepSeek and Meta, with an OpenAI-compatible endpoint. Its docs say it logs the full prompt and response of every request and do not say whether prompts are trained on or kept, so a call marked `private` skips it unless you vouch for it with `privacy: 'no-training'`. Its model list needs a key and is read live (95 entries on 4 Nov 2026): Lodestone keeps the available chat models, with their price and context, so `discover: { fill }` works with it. Its rate limits were not found, and it is not marked `free`. Not yet called live: the account's first chat call was refused with 403, credit balance exhausted. |
|
|
174
175
|
| `openai()`, `mistral()`, `together()` | the providers themselves | |
|
|
175
176
|
| `ollama()` | a local server | Free and private. |
|
|
176
177
|
| `anthropic()`, `google()` | direct | Not OpenAI-style, so they have their own adapters. `anthropic()` leaves the temperature out, because Anthropic's current models reject one (Claude 4.7 and later answer 400 to a non-default value, and API version 2026-10-21 removes it); pass `anthropic({ sendTemperature: true })` for an older model that still accepts one. Model ids are retired on a schedule (`claude-sonnet-4-20250514` was retired on 15 June 2026). `anthropic()` reads Anthropic's own model list, so a retired id is dropped from the chain and one with a retirement date within a week is left out; see [Anthropic self-healing](#anthropic-self-healing). Keep a second model or provider in the chain as well, so a retired id costs one attempt, not the call. |
|
package/dist/errors.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type FailureKind =
|
|
|
16
16
|
| 'rate_limit'
|
|
17
17
|
/** Every attempt timed out. */
|
|
18
18
|
| 'slow'
|
|
19
|
-
/**
|
|
19
|
+
/** A provider says its account has no credit left (402, or a 403 about credit, balance or quota). The app's owner has to top it up. */
|
|
20
20
|
| 'credit'
|
|
21
21
|
/** Models the provider no longer has (404). */
|
|
22
22
|
| 'withdrawn'
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export { CANDIDATES_SCHEMA } from './candidates.js';
|
|
|
28
28
|
export type { Candidates, Candidate } from './candidates.js';
|
|
29
29
|
export { createHealth } from './health.js';
|
|
30
30
|
export type { Health, HealthOptions, ModelHealth } from './health.js';
|
|
31
|
-
export { openaiCompatible, requesty, llmapi, groq, cerebras, omniakey, openai, mistral, together, ollama, normalizeRequesty, normalizeLlmapi, normalizeGroq } from './providers/openaiCompatible.js';
|
|
31
|
+
export { openaiCompatible, requesty, llmapi, groq, cerebras, omniakey, cencori, openai, mistral, together, ollama, normalizeRequesty, normalizeLlmapi, normalizeGroq, normalizeCencori } from './providers/openaiCompatible.js';
|
|
32
32
|
export type { OpenAICompatibleOptions, PresetOptions } from './providers/openaiCompatible.js';
|
|
33
33
|
export { vet, publisherOf, DEFAULT_PUBLISHERS } from './trust.js';
|
|
34
34
|
export type { TrustPolicy, Verdict } from './trust.js';
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export { SCORECARD_SCHEMA, ScorecardError, parseScorecard, fetchScorecard, rankM
|
|
|
16
16
|
export { createStats } from './stats.js';
|
|
17
17
|
export { CANDIDATES_SCHEMA } from './candidates.js';
|
|
18
18
|
export { createHealth } from './health.js';
|
|
19
|
-
export { openaiCompatible, requesty, llmapi, groq, cerebras, omniakey, openai, mistral, together, ollama, normalizeRequesty, normalizeLlmapi, normalizeGroq } from './providers/openaiCompatible.js';
|
|
19
|
+
export { openaiCompatible, requesty, llmapi, groq, cerebras, omniakey, cencori, openai, mistral, together, ollama, normalizeRequesty, normalizeLlmapi, normalizeGroq, normalizeCencori } from './providers/openaiCompatible.js';
|
|
20
20
|
export { vet, publisherOf, DEFAULT_PUBLISHERS } from './trust.js';
|
|
21
21
|
export { resolveProviderModels, healProviderModels } from './discover.js';
|
|
22
22
|
export { netlifyBlobsStore, cloudflareKvStore, upstashStore, denoKvStore, safeKey } from './stores/index.js';
|
package/dist/lodestone.js
CHANGED
|
@@ -408,6 +408,8 @@ export function createLodestone(config = {}) {
|
|
|
408
408
|
throw classify(rateLimited ?? (lastFail?.kind === 'fail' ? lastFail : null), ownKey, authFailed, needsCredit);
|
|
409
409
|
}
|
|
410
410
|
/** Turns the failure that explains why nothing answered into a LodestoneError. */
|
|
411
|
+
/** The provider says the account has no money left: 402, or a 403 whose own words are about credit, balance or quota (Cencori, OmniaKey and others answer 403). Nothing the person can fix; the app's owner needs to top up. */
|
|
412
|
+
const outOfCredit = (f) => f !== null && (f.status === 402 || (f.status === 403 && /credit|balance|quota|top.?up|billing/i.test(f.body)));
|
|
411
413
|
function classify(failure, ownKey, authFailed, needsCredit) {
|
|
412
414
|
const status = failure?.status ?? 0;
|
|
413
415
|
const kind = failure?.unusable ? 'bad_output'
|
|
@@ -415,7 +417,8 @@ export function createLodestone(config = {}) {
|
|
|
415
417
|
: status === 429 ? 'rate_limit'
|
|
416
418
|
: status === 404 ? 'withdrawn'
|
|
417
419
|
: status >= 500 ? 'unavailable'
|
|
418
|
-
: '
|
|
420
|
+
: outOfCredit(failure) ? 'credit'
|
|
421
|
+
: 'other';
|
|
419
422
|
const rateLimit = status === 429 && failure ? readRateLimit(failure.body) : undefined;
|
|
420
423
|
return new LodestoneError(kind, { status, rateLimit, ownKey, needsCredit, providerMessage: failure?.message });
|
|
421
424
|
}
|
|
@@ -25,6 +25,8 @@ export declare const normalizeRequesty: (r: Record<string, unknown>) => CatalogM
|
|
|
25
25
|
export declare const normalizeLlmapi: (r: Record<string, unknown>) => CatalogModel | null;
|
|
26
26
|
/** Groq lists speech, text-to-speech and safety-classifier models beside its chat models (seen 28 Oct 2026: whisper, orpheus, prompt-guard, safeguard). Those are not chat models, so they are left out. */
|
|
27
27
|
export declare const normalizeGroq: (r: Record<string, unknown>) => CatalogModel | null;
|
|
28
|
+
/** Cencori's list (read live 4 Nov 2026) says for each model its `type` (chat, image...), whether it is `available` now, its `context_window` and, when priced, `pricing.input_per_million` and `output_per_million` in US dollars. Only available chat models are kept: an image model, or one marked unavailable (the image models said `pricing_required`), is left out, so a named model that has gone from the list is reported as withdrawn. It says nothing about training or retention, so nothing is claimed about either. */
|
|
29
|
+
export declare const normalizeCencori: (r: Record<string, unknown>) => CatalogModel | null;
|
|
28
30
|
export interface PresetOptions {
|
|
29
31
|
fetch?: typeof fetch;
|
|
30
32
|
headers?: Record<string, string>;
|
|
@@ -40,6 +42,8 @@ export declare const llmapi: (o?: PresetOptions) => Provider;
|
|
|
40
42
|
export declare const groq: (o?: PresetOptions) => Provider;
|
|
41
43
|
/** https://omniakey.com: a prepaid gateway to text, image, video and music models, with an OpenAI-compatible text endpoint (api.omniakey.com/v1). Its model list needs a key (401 without one), and its site says it does not switch a request to a different model by itself, which is what Lodestone does on top of it. Not yet called live. */
|
|
42
44
|
export declare const omniakey: (o?: PresetOptions) => Provider;
|
|
45
|
+
/** https://cencori.com: a gateway to chat models from OpenAI, Anthropic, Google, xAI, Mistral, DeepSeek and Meta, with an OpenAI-compatible endpoint (api.cencori.com/v1, `Authorization: Bearer`). Its docs say it logs the full prompt and response of every request and do not say whether prompts are trained on or how long they are kept, so a call marked `private` skips it unless you vouch for it with `privacy: 'no-training'`. The model list needs a key (401 without one), is read live, and carries each model's type, availability, context and price. Not yet called for chat: the account's first call was refused for credit. */
|
|
46
|
+
export declare const cencori: (o?: PresetOptions) => Provider;
|
|
43
47
|
/** https://cerebras.ai: fast inference with a free tier. */
|
|
44
48
|
export declare const cerebras: (o?: PresetOptions) => Provider;
|
|
45
49
|
export declare const openai: (o?: PresetOptions) => Provider;
|
|
@@ -83,6 +83,25 @@ export const normalizeGroq = (r) => {
|
|
|
83
83
|
return null;
|
|
84
84
|
return { id: r.id, ...(num(r.context_window) !== undefined ? { context_length: num(r.context_window) } : {}) };
|
|
85
85
|
};
|
|
86
|
+
/** Cencori's list (read live 4 Nov 2026) says for each model its `type` (chat, image...), whether it is `available` now, its `context_window` and, when priced, `pricing.input_per_million` and `output_per_million` in US dollars. Only available chat models are kept: an image model, or one marked unavailable (the image models said `pricing_required`), is left out, so a named model that has gone from the list is reported as withdrawn. It says nothing about training or retention, so nothing is claimed about either. */
|
|
87
|
+
export const normalizeCencori = (r) => {
|
|
88
|
+
if (typeof r.id !== 'string' || !r.id)
|
|
89
|
+
return null;
|
|
90
|
+
const types = Array.isArray(r.types) ? r.types : [];
|
|
91
|
+
if ((typeof r.type === 'string' && r.type !== 'chat') || (typeof r.type !== 'string' && types.length && !types.includes('chat')))
|
|
92
|
+
return null;
|
|
93
|
+
if (r.available === false || (typeof r.status === 'string' && r.status !== 'active'))
|
|
94
|
+
return null;
|
|
95
|
+
const p = r.pricing && typeof r.pricing === 'object' ? r.pricing : {};
|
|
96
|
+
const inPrice = num(p.input_per_million);
|
|
97
|
+
const outPrice = num(p.output_per_million);
|
|
98
|
+
return {
|
|
99
|
+
id: r.id,
|
|
100
|
+
...(num(r.context_window) ? { context_length: num(r.context_window) } : {}),
|
|
101
|
+
...(typeof r.owned_by === 'string' && r.owned_by ? { publisher: r.owned_by.toLowerCase() } : {}),
|
|
102
|
+
...(inPrice !== undefined && outPrice !== undefined ? { pricing: { prompt: inPrice / 1e6, completion: outPrice / 1e6 }, free: inPrice === 0 && outPrice === 0 } : {}),
|
|
103
|
+
};
|
|
104
|
+
};
|
|
86
105
|
/** https://www.requesty.ai: a gateway to 800+ models, with failover between providers. `region: 'eu'` keeps prompts in the EU. */
|
|
87
106
|
export const requesty = (o = {}) => openaiCompatible({ name: 'requesty', baseUrl: o.region === 'eu' ? 'https://router.eu.requesty.ai/v1' : 'https://router.requesty.ai/v1', normalize: normalizeRequesty, ...o });
|
|
88
107
|
/** https://llmapi.ai: a gateway to 150+ chat models. */
|
|
@@ -91,6 +110,8 @@ export const llmapi = (o = {}) => openaiCompatible({ name: 'llmapi', baseUrl: 'h
|
|
|
91
110
|
export const groq = (o = {}) => openaiCompatible({ name: 'groq', baseUrl: 'https://api.groq.com/openai/v1', normalize: normalizeGroq, ...o });
|
|
92
111
|
/** https://omniakey.com: a prepaid gateway to text, image, video and music models, with an OpenAI-compatible text endpoint (api.omniakey.com/v1). Its model list needs a key (401 without one), and its site says it does not switch a request to a different model by itself, which is what Lodestone does on top of it. Not yet called live. */
|
|
93
112
|
export const omniakey = (o = {}) => openaiCompatible({ name: 'omniakey', baseUrl: 'https://api.omniakey.com/v1', ...o });
|
|
113
|
+
/** https://cencori.com: a gateway to chat models from OpenAI, Anthropic, Google, xAI, Mistral, DeepSeek and Meta, with an OpenAI-compatible endpoint (api.cencori.com/v1, `Authorization: Bearer`). Its docs say it logs the full prompt and response of every request and do not say whether prompts are trained on or how long they are kept, so a call marked `private` skips it unless you vouch for it with `privacy: 'no-training'`. The model list needs a key (401 without one), is read live, and carries each model's type, availability, context and price. Not yet called for chat: the account's first call was refused for credit. */
|
|
114
|
+
export const cencori = (o = {}) => openaiCompatible({ name: 'cencori', baseUrl: 'https://api.cencori.com/v1', normalize: normalizeCencori, ...o });
|
|
94
115
|
/** https://cerebras.ai: fast inference with a free tier. */
|
|
95
116
|
export const cerebras = (o = {}) => openaiCompatible({ name: 'cerebras', baseUrl: 'https://api.cerebras.ai/v1', ...o });
|
|
96
117
|
export const openai = (o = {}) => openaiCompatible({ name: 'openai', baseUrl: 'https://api.openai.com/v1', ...o });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@extrafemi-ai/lodestone",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Calls AI models so your tool keeps working when a model is withdrawn, slow, rate-limited or down: failover across providers, self-updating model lists, spend limits.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|