@providerkit/core 0.5.1 → 0.7.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 +15 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +249 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +199 -0
- package/dist/presets.js.map +1 -0
- package/dist/providers/anthropic.d.ts +9 -0
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +19 -3
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/factory.d.ts +19 -0
- package/dist/providers/factory.d.ts.map +1 -0
- package/dist/providers/factory.js +82 -0
- package/dist/providers/factory.js.map +1 -0
- package/dist/providers/openai.d.ts +4 -0
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +1 -1
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/zai.d.ts +18 -0
- package/dist/providers/zai.d.ts.map +1 -0
- package/dist/providers/zai.js +27 -0
- package/dist/providers/zai.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/presets.ts +265 -0
- package/src/providers/anthropic.ts +36 -10
- package/src/providers/factory.ts +102 -0
- package/src/providers/openai.ts +5 -1
- package/src/providers/zai.ts +31 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ProviderPresetId } from "../presets.ts";
|
|
2
|
+
import type { Effort, Provider } from "../types.ts";
|
|
3
|
+
export interface PresetProviderConfig {
|
|
4
|
+
/** The credential: an API key for `key`/`bearer` presets, an ACCESS TOKEN
|
|
5
|
+
* for `oauth` ones. Acquiring the token is the caller's job. */
|
|
6
|
+
apiKey: string;
|
|
7
|
+
/** Which model to run. Absent = the preset's `defaultModel`; a preset
|
|
8
|
+
* without either throws rather than sending a request nobody chose. */
|
|
9
|
+
model?: string;
|
|
10
|
+
effort?: Effort;
|
|
11
|
+
/** Output ceiling. The Anthropic shape requires one; adapters default it. */
|
|
12
|
+
maxTokens?: number;
|
|
13
|
+
/** Per-request headers (request ids, `ChatGPT-Account-Id`) on top of the
|
|
14
|
+
* preset's static protocol headers. */
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
fetchImpl?: typeof fetch;
|
|
17
|
+
}
|
|
18
|
+
export declare function createPresetProvider(id: ProviderPresetId, config: PresetProviderConfig): Provider;
|
|
19
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/providers/factory.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAqD,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,WAAW,oBAAoB;IACnC;qEACiE;IACjE,MAAM,EAAE,MAAM,CAAC;IACf;4EACwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;4CACwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,gBAAgB,EAAE,MAAM,EAAE,oBAAoB,GAAG,QAAQ,CAkEjG"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// The one-line switch: resolve a preset id into a wired provider.
|
|
2
|
+
//
|
|
3
|
+
// Consumers used to write their own switch over providers — the same
|
|
4
|
+
// dispatch, re-derived per codebase, each quietly accumulating dialect
|
|
5
|
+
// knowledge (which gateway takes Bearer, which needs the thinking marker).
|
|
6
|
+
// The presets table + this factory is that dispatch, said once: a caller
|
|
7
|
+
// names an id and hands over a credential, and the header style, endpoint
|
|
8
|
+
// and adapter come from the table.
|
|
9
|
+
//
|
|
10
|
+
// `effort` passes through to the adapter unchanged — the per-endpoint
|
|
11
|
+
// thinking dialects (Z.ai's explicit disabled marker, OpenRouter's floors)
|
|
12
|
+
// are the adapters' knowledge, and this factory must not re-derive them.
|
|
13
|
+
import { createAnthropicProvider } from "./anthropic.js";
|
|
14
|
+
import { createGeminiProvider } from "./gemini.js";
|
|
15
|
+
import { createOpenAIProvider } from "./openai.js";
|
|
16
|
+
import { createResponsesProvider } from "./responses.js";
|
|
17
|
+
import { PRESET_IDS, PROVIDER_PRESETS } from "../presets.js";
|
|
18
|
+
export function createPresetProvider(id, config) {
|
|
19
|
+
// The table is closed (`satisfies`), but a caller may hold an id as a plain
|
|
20
|
+
// string — validate rather than index into undefined.
|
|
21
|
+
if (!(id in PROVIDER_PRESETS)) {
|
|
22
|
+
throw new Error(`[providerkit] Unknown provider preset "${id}". Valid ids: ${PRESET_IDS.join(", ")}`);
|
|
23
|
+
}
|
|
24
|
+
const preset = PROVIDER_PRESETS[id];
|
|
25
|
+
const model = config.model ?? preset.defaultModel;
|
|
26
|
+
if (!model) {
|
|
27
|
+
throw new Error(`[providerkit] Preset "${id}" has no defaultModel — pass a model.`);
|
|
28
|
+
}
|
|
29
|
+
const headers = { ...preset.headers, ...config.headers };
|
|
30
|
+
switch (preset.shape) {
|
|
31
|
+
case "anthropic":
|
|
32
|
+
// `key` rides Anthropic's native x-api-key; coding plans and OAuth
|
|
33
|
+
// tokens read Bearer (measured across the family's coding endpoints).
|
|
34
|
+
return createAnthropicProvider({
|
|
35
|
+
apiKey: config.apiKey,
|
|
36
|
+
model,
|
|
37
|
+
effort: config.effort,
|
|
38
|
+
maxTokens: config.maxTokens,
|
|
39
|
+
baseUrl: preset.baseUrl,
|
|
40
|
+
id,
|
|
41
|
+
headers,
|
|
42
|
+
bearer: preset.auth !== "key",
|
|
43
|
+
// The endpoint's thinking dialect rides the table (zai: silence means
|
|
44
|
+
// the model default, which is ON — "none" must be said out loud).
|
|
45
|
+
...(preset.explicitNone ? { explicitNone: true } : {}),
|
|
46
|
+
fetchImpl: config.fetchImpl,
|
|
47
|
+
});
|
|
48
|
+
case "openai":
|
|
49
|
+
return createOpenAIProvider({
|
|
50
|
+
id,
|
|
51
|
+
apiKey: config.apiKey,
|
|
52
|
+
model,
|
|
53
|
+
effort: config.effort,
|
|
54
|
+
maxTokens: config.maxTokens,
|
|
55
|
+
baseUrl: preset.baseUrl,
|
|
56
|
+
headers,
|
|
57
|
+
fetchImpl: config.fetchImpl,
|
|
58
|
+
});
|
|
59
|
+
case "responses":
|
|
60
|
+
return createResponsesProvider({
|
|
61
|
+
apiKey: config.apiKey,
|
|
62
|
+
model,
|
|
63
|
+
effort: config.effort,
|
|
64
|
+
maxTokens: config.maxTokens,
|
|
65
|
+
baseUrl: preset.baseUrl,
|
|
66
|
+
id,
|
|
67
|
+
headers,
|
|
68
|
+
fetchImpl: config.fetchImpl,
|
|
69
|
+
});
|
|
70
|
+
case "gemini":
|
|
71
|
+
return createGeminiProvider({
|
|
72
|
+
apiKey: config.apiKey,
|
|
73
|
+
model,
|
|
74
|
+
effort: config.effort,
|
|
75
|
+
baseUrl: preset.baseUrl,
|
|
76
|
+
id,
|
|
77
|
+
headers,
|
|
78
|
+
fetchImpl: config.fetchImpl,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/providers/factory.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,2EAA2E;AAC3E,yEAAyE;AACzE,0EAA0E;AAC1E,mCAAmC;AACnC,EAAE;AACF,sEAAsE;AACtE,2EAA2E;AAC3E,yEAAyE;AACzE,OAAO,EAAE,uBAAuB,EAA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AClE,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACtD,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;QACL,KAAK,QAAQ;YACX,OAAO,oBAAoB,CAAC;gBAC1B,EAAE;gBACF,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,KAAK;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,OAAO;gBACP,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;QACL,KAAK,WAAW;YACd,OAAO,uBAAuB,CAAC;gBAC7B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,KAAK;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,EAAE;gBACF,OAAO;gBACP,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;QACL,KAAK,QAAQ;YACX,OAAO,oBAAoB,CAAC;gBAC1B,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,KAAK;gBACL,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,EAAE;gBACF,OAAO;gBACP,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC,CAAC;IACP,CAAC;AACH,CAAC"}
|
|
@@ -4,6 +4,10 @@ export interface OpenAIConfig {
|
|
|
4
4
|
model: string;
|
|
5
5
|
/** Any OpenAI-compatible endpoint. Defaults to OpenAI itself. */
|
|
6
6
|
baseUrl?: string;
|
|
7
|
+
/** Path appended to baseUrl. Defaults to /v1/chat/completions. Set
|
|
8
|
+
* /chat/completions when the base already includes the API version, such as
|
|
9
|
+
* a gateway using /v4 rather than /v1. */
|
|
10
|
+
path?: string;
|
|
7
11
|
/** Names the provider in errors and logs — "openrouter", "deepseek", … It
|
|
8
12
|
* also picks the effort dialect below, unless `effortDialect` overrides. */
|
|
9
13
|
id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EAEN,aAAa,EACb,QAAQ,EAIT,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;iFAC6E;IAC7E,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAID;4EAC4E;AAC5E,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,KAAK,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,C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C1B,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA6CzB;AAmCD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,GAAG,OAAO,EAAE,CAyD5E;AA+BD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,QAAQ,CA4LnE"}
|
package/dist/providers/openai.js
CHANGED
|
@@ -278,7 +278,7 @@ export function createOpenAIProvider(config) {
|
|
|
278
278
|
request.provider = { order: config.providerOrder, allow_fallbacks: true };
|
|
279
279
|
}
|
|
280
280
|
for await (const data of streamSse({
|
|
281
|
-
url: apiUrl(baseUrl, "/v1/chat/completions"),
|
|
281
|
+
url: apiUrl(baseUrl, config.path ?? "/v1/chat/completions"),
|
|
282
282
|
headers: { authorization: `Bearer ${config.apiKey}`, ...config.headers },
|
|
283
283
|
body: request,
|
|
284
284
|
provider: id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,yEAAyE;AACzE,+EAA+E;AAC/E,2DAA2D;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAYpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,EAAE;AACF,yEAAyE;AACzE,+EAA+E;AAC/E,2DAA2D;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,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oBACb,CAAC;oBACD,IAAI,GAAG;wBAAE,MAAM,GAAG,CAAC;gBACrB,CAAC;gBAED,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAC3D,IAAI,YAAY;oBAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;YAC3D,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type AnthropicConfig } from "./anthropic.ts";
|
|
2
|
+
import type { Provider } from "../types.ts";
|
|
3
|
+
/** Z.ai Coding Plan's Anthropic-compatible API root, not its pay-per-token API. */
|
|
4
|
+
export declare const ZAI_CODING_BASE_URL = "https://api.z.ai/api/anthropic";
|
|
5
|
+
export type ZaiCodingConfig = Omit<AnthropicConfig, "baseUrl" | "id" | "bearer">;
|
|
6
|
+
/** Use a Z.ai Coding Plan key with the shared Messages adapter. The preset owns
|
|
7
|
+
* the endpoint, Bearer auth and the thinking dialect; callers still choose
|
|
8
|
+
* their model and effort. Tool calls, usage and errors use the existing
|
|
9
|
+
* adapter.
|
|
10
|
+
*
|
|
11
|
+
* Dialect notes, measured 2026-09-13 against the live endpoint on
|
|
12
|
+
* `glm-5.3-flash`: an absent thinking field means the MODEL's default —
|
|
13
|
+
* thinking ON — so `effort: "none"` is sent as an explicit
|
|
14
|
+
* `thinking: { type: "disabled" }`; `low`–`max` ride the standard thinking
|
|
15
|
+
* budgets, which the endpoint accepts. Images force a thinking block even
|
|
16
|
+
* under `disabled` (the model's choice, billed as output). */
|
|
17
|
+
export declare function createZaiCodingProvider(config: ZaiCodingConfig): Provider;
|
|
18
|
+
//# sourceMappingURL=zai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zai.d.ts","sourceRoot":"","sources":["../../src/providers/zai.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,mCAAmC,CAAC;AAEpE,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,IAAI,GAAG,QAAQ,CAAC,CAAC;AAEjF;;;;;;;;;;+DAU+D;AAC/D,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,eAAe,GAAG,QAAQ,CAWzE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createAnthropicProvider } from "./anthropic.js";
|
|
2
|
+
/** Z.ai Coding Plan's Anthropic-compatible API root, not its pay-per-token API. */
|
|
3
|
+
export const ZAI_CODING_BASE_URL = "https://api.z.ai/api/anthropic";
|
|
4
|
+
/** Use a Z.ai Coding Plan key with the shared Messages adapter. The preset owns
|
|
5
|
+
* the endpoint, Bearer auth and the thinking dialect; callers still choose
|
|
6
|
+
* their model and effort. Tool calls, usage and errors use the existing
|
|
7
|
+
* adapter.
|
|
8
|
+
*
|
|
9
|
+
* Dialect notes, measured 2026-09-13 against the live endpoint on
|
|
10
|
+
* `glm-5.3-flash`: an absent thinking field means the MODEL's default —
|
|
11
|
+
* thinking ON — so `effort: "none"` is sent as an explicit
|
|
12
|
+
* `thinking: { type: "disabled" }`; `low`–`max` ride the standard thinking
|
|
13
|
+
* budgets, which the endpoint accepts. Images force a thinking block even
|
|
14
|
+
* under `disabled` (the model's choice, billed as output). */
|
|
15
|
+
export function createZaiCodingProvider(config) {
|
|
16
|
+
return createAnthropicProvider({
|
|
17
|
+
...config,
|
|
18
|
+
id: "zai",
|
|
19
|
+
baseUrl: ZAI_CODING_BASE_URL,
|
|
20
|
+
bearer: true,
|
|
21
|
+
explicitNone: true,
|
|
22
|
+
// Coding gateways can allocate a 32K thinking budget themselves. Leave room
|
|
23
|
+
// for the answer; callers can still set a smaller cap for their model.
|
|
24
|
+
maxTokens: config.maxTokens ?? 65_536,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=zai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zai.js","sourceRoot":"","sources":["../../src/providers/zai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAwB,MAAM,gBAAgB,CAAC;AAG/E,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,gCAAgC,CAAC;AAIpE;;;;;;;;;;+DAU+D;AAC/D,MAAM,UAAU,uBAAuB,CAAC,MAAuB;IAC7D,OAAO,uBAAuB,CAAC;QAC7B,GAAG,MAAM;QACT,EAAE,EAAE,KAAK;QACT,OAAO,EAAE,mBAAmB;QAC5B,MAAM,EAAE,IAAI;QACZ,YAAY,EAAE,IAAI;QAClB,4EAA4E;QAC5E,uEAAuE;QACvE,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,MAAM;KACtC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -11,7 +11,10 @@ export * from "./tools.ts";
|
|
|
11
11
|
export * from "./schema.ts";
|
|
12
12
|
export * from "./context.ts";
|
|
13
13
|
export * from "./capability.ts";
|
|
14
|
+
export * from "./presets.ts";
|
|
14
15
|
export * from "./providers/anthropic.ts";
|
|
15
16
|
export * from "./providers/openai.ts";
|
|
16
17
|
export * from "./providers/responses.ts";
|
|
17
18
|
export * from "./providers/gemini.ts";
|
|
19
|
+
export * from "./providers/zai.ts";
|
|
20
|
+
export * from "./providers/factory.ts";
|
package/src/presets.ts
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider presets — hand-curated, wire-level facts only.
|
|
3
|
+
*
|
|
4
|
+
* A preset is everything `createPresetProvider` needs to speak to one
|
|
5
|
+
* endpoint: which adapter shape it speaks, its API root, how the credential
|
|
6
|
+
* rides, and what it is called. Deliberately absent: prices (invariant 9 —
|
|
7
|
+
* they drift on a vendor's schedule and a wrong number in a library is a
|
|
8
|
+
* wrong number in everyone's ledger), icons, colors, marketing names, and
|
|
9
|
+
* sign-in flows (an `oauth` preset expects the CALLER to hand over an access
|
|
10
|
+
* token; acquiring one stays app-side).
|
|
11
|
+
*
|
|
12
|
+
* Sources: the coding-plan endpoints and auth quirks are measured
|
|
13
|
+
* (tabrunner's extension + this repo's adopters, 2026-09); the model lists
|
|
14
|
+
* are representative, not exhaustive — every adapter takes a per-call model,
|
|
15
|
+
* so a missing id costs nothing.
|
|
16
|
+
*
|
|
17
|
+
* Azure is deliberately ABSENT: its base URL is per-deployment
|
|
18
|
+
* (`https://<resource>.openai.azure.com`), so no static preset can carry it —
|
|
19
|
+
* point createOpenAIProvider's baseUrl at your resource instead.
|
|
20
|
+
*/
|
|
21
|
+
export type PresetShape = "anthropic" | "openai" | "responses" | "gemini";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* How the credential reaches the endpoint.
|
|
25
|
+
* - `key`: the vendor's native key header (Anthropic reads `x-api-key`,
|
|
26
|
+
* Gemini `x-goog-api-key`); the OpenAI shapes have only Bearer, so they
|
|
27
|
+
* never use this.
|
|
28
|
+
* - `bearer`: `Authorization: Bearer` — the OpenAI shapes' only mode, and the
|
|
29
|
+
* coding-plan gateways' mode on the Anthropic wire (measured: Z.ai's coding
|
|
30
|
+
* endpoint ignores `x-api-key` and reads Bearer).
|
|
31
|
+
* - `oauth`: same wire as `bearer`, but the token is a short-lived access
|
|
32
|
+
* token from a sign-in flow the caller owns. The preset may carry the beta
|
|
33
|
+
* headers that switch the endpoint into OAuth mode.
|
|
34
|
+
*/
|
|
35
|
+
export type PresetAuth = "key" | "bearer" | "oauth";
|
|
36
|
+
|
|
37
|
+
export interface ProviderPreset {
|
|
38
|
+
/** Adapter wire format. */
|
|
39
|
+
shape: PresetShape;
|
|
40
|
+
/** API root — the adapter appends its own path (/v1/chat/completions,
|
|
41
|
+
* /v1/messages, …), so this must NOT carry the version. */
|
|
42
|
+
baseUrl: string;
|
|
43
|
+
auth: PresetAuth;
|
|
44
|
+
/** Fallback when the caller passes no model. */
|
|
45
|
+
defaultModel?: string;
|
|
46
|
+
/** Representative model ids. */
|
|
47
|
+
models?: string[];
|
|
48
|
+
/** Static protocol headers the endpoint requires (e.g. OAuth beta flags).
|
|
49
|
+
* Per-request headers (request ids, account ids) are the caller's. */
|
|
50
|
+
headers?: Record<string, string>;
|
|
51
|
+
/** True when the endpoint hard-400s image parts (measured on DeepSeek). */
|
|
52
|
+
textOnly?: boolean;
|
|
53
|
+
/** Anthropic-shape dialect: say "no thinking" with an explicit
|
|
54
|
+
* `thinking: { type: "disabled" }` marker when effort is none. For
|
|
55
|
+
* endpoints where an ABSENT field means the model's default — thinking ON
|
|
56
|
+
* for reasoning-mandatory models (measured on Z.ai's coding endpoint:
|
|
57
|
+
* omit → thinking block; disabled → none). Native Anthropic defaults to
|
|
58
|
+
* off when the field is absent and must stay unset. */
|
|
59
|
+
explicitNone?: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const PROVIDER_PRESETS = {
|
|
63
|
+
// ── Keyed, native shapes ────────────────────────────────────────────────
|
|
64
|
+
anthropic: {
|
|
65
|
+
shape: "anthropic",
|
|
66
|
+
baseUrl: "https://api.anthropic.com",
|
|
67
|
+
auth: "key",
|
|
68
|
+
defaultModel: "claude-sonnet-4-6",
|
|
69
|
+
models: ["claude-sonnet-4-6", "claude-opus-5", "claude-fable-5-1"],
|
|
70
|
+
},
|
|
71
|
+
openai: {
|
|
72
|
+
shape: "openai",
|
|
73
|
+
baseUrl: "https://api.openai.com",
|
|
74
|
+
auth: "key",
|
|
75
|
+
defaultModel: "gpt-5.6-sol",
|
|
76
|
+
models: ["gpt-5.6-sol", "gpt-5-pro", "gpt-5-nano"],
|
|
77
|
+
},
|
|
78
|
+
google: {
|
|
79
|
+
// Native Generative Language REST — the adapter authenticates with
|
|
80
|
+
// `x-goog-api-key` (NOT Bearer) and fixes its own /v1… paths.
|
|
81
|
+
shape: "gemini",
|
|
82
|
+
baseUrl: "https://generativelanguage.googleapis.com",
|
|
83
|
+
auth: "key",
|
|
84
|
+
defaultModel: "gemini-3.1-pro",
|
|
85
|
+
models: ["gemini-3.1-pro", "gemini-2.5-flash"],
|
|
86
|
+
},
|
|
87
|
+
/** Gemini behind its OpenAI-compatible route — the drop-in for codebases
|
|
88
|
+
* that only speak the openai shape. */
|
|
89
|
+
"google-openai": {
|
|
90
|
+
shape: "openai",
|
|
91
|
+
baseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
|
|
92
|
+
auth: "key",
|
|
93
|
+
defaultModel: "gemini-3.1-pro",
|
|
94
|
+
models: ["gemini-3.1-pro", "gemini-2.5-flash"],
|
|
95
|
+
},
|
|
96
|
+
deepseek: {
|
|
97
|
+
shape: "openai",
|
|
98
|
+
baseUrl: "https://api.deepseek.com",
|
|
99
|
+
auth: "key",
|
|
100
|
+
defaultModel: "deepseek-v4-flash",
|
|
101
|
+
models: ["deepseek-v4-flash", "deepseek-v4-pro", "deepseek-flash"],
|
|
102
|
+
// Text-only API — an image part in the body is a hard 400 (measured).
|
|
103
|
+
textOnly: true,
|
|
104
|
+
},
|
|
105
|
+
openrouter: {
|
|
106
|
+
shape: "openai",
|
|
107
|
+
baseUrl: "https://openrouter.ai/api",
|
|
108
|
+
auth: "key",
|
|
109
|
+
defaultModel: "deepseek/deepseek-v4.1-flash",
|
|
110
|
+
models: ["deepseek/deepseek-v4.1-flash", "z-ai/glm-5.3-flash", "qwen/qwen3.7-max"],
|
|
111
|
+
},
|
|
112
|
+
groq: {
|
|
113
|
+
shape: "openai",
|
|
114
|
+
baseUrl: "https://api.groq.com/openai/v1",
|
|
115
|
+
auth: "key",
|
|
116
|
+
defaultModel: "llama-3.3-70b-versatile",
|
|
117
|
+
models: ["llama-3.3-70b-versatile", "qwen/qwen3.8-27b"],
|
|
118
|
+
},
|
|
119
|
+
mistral: {
|
|
120
|
+
shape: "openai",
|
|
121
|
+
baseUrl: "https://api.mistral.ai/v1",
|
|
122
|
+
auth: "key",
|
|
123
|
+
defaultModel: "devstral-2512",
|
|
124
|
+
models: ["devstral-2512", "magistral-small", "mistral-small-2506"],
|
|
125
|
+
},
|
|
126
|
+
xai: {
|
|
127
|
+
shape: "openai",
|
|
128
|
+
baseUrl: "https://api.x.ai/v1",
|
|
129
|
+
auth: "key",
|
|
130
|
+
defaultModel: "grok-4.5",
|
|
131
|
+
models: ["grok-4.5", "grok-4.3", "grok-4.20-0309-reasoning"],
|
|
132
|
+
},
|
|
133
|
+
together: {
|
|
134
|
+
shape: "openai",
|
|
135
|
+
baseUrl: "https://api.together.xyz/v1",
|
|
136
|
+
auth: "key",
|
|
137
|
+
defaultModel: "deepseek-ai/DeepSeek-V3",
|
|
138
|
+
},
|
|
139
|
+
fireworks: {
|
|
140
|
+
shape: "openai",
|
|
141
|
+
baseUrl: "https://api.fireworks.ai/inference/v1",
|
|
142
|
+
auth: "key",
|
|
143
|
+
},
|
|
144
|
+
cerebras: {
|
|
145
|
+
shape: "openai",
|
|
146
|
+
baseUrl: "https://api.cerebras.ai/v1",
|
|
147
|
+
auth: "key",
|
|
148
|
+
defaultModel: "gpt-oss-120b",
|
|
149
|
+
models: ["gpt-oss-120b", "qwen-3.8-27b"],
|
|
150
|
+
},
|
|
151
|
+
moonshot: {
|
|
152
|
+
shape: "openai",
|
|
153
|
+
baseUrl: "https://api.moonshot.ai/v1",
|
|
154
|
+
auth: "key",
|
|
155
|
+
defaultModel: "kimi-k2.7-code",
|
|
156
|
+
models: ["kimi-k2.7-code", "kimi-k2.7-code-highspeed", "kimi-k3"],
|
|
157
|
+
},
|
|
158
|
+
zhipu: {
|
|
159
|
+
shape: "openai",
|
|
160
|
+
baseUrl: "https://api.z.ai/api/paas/v4",
|
|
161
|
+
auth: "key",
|
|
162
|
+
defaultModel: "glm-5.3-flash",
|
|
163
|
+
models: ["glm-5.3-flash", "glm-5.2", "glm-4.7"],
|
|
164
|
+
},
|
|
165
|
+
minimax: {
|
|
166
|
+
shape: "anthropic",
|
|
167
|
+
baseUrl: "https://api.minimax.io/anthropic",
|
|
168
|
+
auth: "key",
|
|
169
|
+
defaultModel: "MiniMax-M2.5",
|
|
170
|
+
models: ["MiniMax-M3", "MiniMax-M2.5", "MiniMax-M2.1"],
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
// ── Coding plans — Anthropic wire + Bearer (measured family trait) ─────
|
|
174
|
+
zai: {
|
|
175
|
+
shape: "anthropic",
|
|
176
|
+
baseUrl: "https://api.z.ai/api/anthropic",
|
|
177
|
+
auth: "bearer",
|
|
178
|
+
defaultModel: "glm-5.3-flash",
|
|
179
|
+
models: ["glm-5.3-flash", "glm-5.3-highspeed", "glm-5.2", "glm-5-turbo"],
|
|
180
|
+
// Model ids are BARE here — the gateway-prefixed spelling
|
|
181
|
+
// (`z-ai/glm-5.3-flash`) answers 400 [1211] Unknown Model.
|
|
182
|
+
explicitNone: true,
|
|
183
|
+
},
|
|
184
|
+
kimi: {
|
|
185
|
+
shape: "anthropic",
|
|
186
|
+
baseUrl: "https://api.kimi.ai/coding",
|
|
187
|
+
auth: "bearer",
|
|
188
|
+
defaultModel: "kimi-for-coding",
|
|
189
|
+
models: ["kimi-for-coding", "kimi-for-coding-highspeed", "k3"],
|
|
190
|
+
},
|
|
191
|
+
/** Alibaba's dashscope coding plan — OpenAI-compatible per its registry. */
|
|
192
|
+
"alibaba-coding-plan": {
|
|
193
|
+
shape: "openai",
|
|
194
|
+
baseUrl: "https://coding-intl.dashscope.aliyuncs.com/v1",
|
|
195
|
+
auth: "bearer",
|
|
196
|
+
defaultModel: "qwen3.7-max",
|
|
197
|
+
models: ["qwen3.7-max", "qwen3-coder-next", "glm-4.7"],
|
|
198
|
+
},
|
|
199
|
+
/** QwenCloud's token plan — Anthropic wire (measured by tabrunner). */
|
|
200
|
+
qwen: {
|
|
201
|
+
shape: "anthropic",
|
|
202
|
+
baseUrl: "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
|
|
203
|
+
auth: "bearer",
|
|
204
|
+
defaultModel: "qwen3.8-max",
|
|
205
|
+
models: ["qwen3.8-max", "qwen3.6-flash"],
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
// ── Local runtimes ──────────────────────────────────────────────────────
|
|
209
|
+
ollama: {
|
|
210
|
+
shape: "openai",
|
|
211
|
+
baseUrl: "http://localhost:11434/v1",
|
|
212
|
+
auth: "bearer",
|
|
213
|
+
},
|
|
214
|
+
lmstudio: {
|
|
215
|
+
shape: "openai",
|
|
216
|
+
baseUrl: "http://127.0.0.1:1234/v1",
|
|
217
|
+
auth: "bearer",
|
|
218
|
+
},
|
|
219
|
+
vllm: {
|
|
220
|
+
shape: "openai",
|
|
221
|
+
baseUrl: "http://localhost:8000/v1",
|
|
222
|
+
auth: "bearer",
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
// ── OAuth — the caller owns the sign-in flow and hands over the token ───
|
|
226
|
+
claude: {
|
|
227
|
+
shape: "anthropic",
|
|
228
|
+
baseUrl: "https://api.anthropic.com",
|
|
229
|
+
auth: "oauth",
|
|
230
|
+
defaultModel: "claude-sonnet-4-6",
|
|
231
|
+
models: ["claude-sonnet-4-6", "claude-opus-5"],
|
|
232
|
+
// The beta flag is what switches the API into OAuth-token mode (measured
|
|
233
|
+
// by tabrunner's Claude plan sign-in).
|
|
234
|
+
headers: { "anthropic-beta": "claude-code-20250219,oauth-2025-04-20" },
|
|
235
|
+
},
|
|
236
|
+
/** The Codex backend behind a ChatGPT sign-in — Responses wire, no public
|
|
237
|
+
* model list, so these ids are the list. */
|
|
238
|
+
chatgpt: {
|
|
239
|
+
shape: "responses",
|
|
240
|
+
baseUrl: "https://chatgpt.com/backend-api/codex",
|
|
241
|
+
auth: "oauth",
|
|
242
|
+
defaultModel: "gpt-5.3-codex",
|
|
243
|
+
models: ["gpt-5.3-codex", "gpt-5.5", "gpt-5.4-mini"],
|
|
244
|
+
},
|
|
245
|
+
/** Kimi's coding endpoint reached with a subscription token instead of a
|
|
246
|
+
* key — Kimi bills the two separately. */
|
|
247
|
+
"kimi-plan": {
|
|
248
|
+
shape: "anthropic",
|
|
249
|
+
baseUrl: "https://api.kimi.ai/coding",
|
|
250
|
+
auth: "oauth",
|
|
251
|
+
defaultModel: "kimi-for-coding",
|
|
252
|
+
},
|
|
253
|
+
"github-copilot": {
|
|
254
|
+
shape: "openai",
|
|
255
|
+
baseUrl: "https://api.githubcopilot.com",
|
|
256
|
+
auth: "oauth",
|
|
257
|
+
defaultModel: "gpt-5.6-sol",
|
|
258
|
+
models: ["gpt-5.6-sol", "claude-opus-5", "claude-opus-4.8", "kimi-k2.7-code"],
|
|
259
|
+
},
|
|
260
|
+
} as const satisfies Record<string, ProviderPreset>;
|
|
261
|
+
|
|
262
|
+
export type ProviderPresetId = keyof typeof PROVIDER_PRESETS;
|
|
263
|
+
|
|
264
|
+
/** Every valid preset id — the factory's unknown-id error lists these. */
|
|
265
|
+
export const PRESET_IDS = Object.keys(PROVIDER_PRESETS) as ProviderPresetId[];
|
|
@@ -37,6 +37,15 @@ export interface AnthropicConfig {
|
|
|
37
37
|
/** Send the key as a Bearer instead of `x-api-key` — what a subscription
|
|
38
38
|
* access token needs. */
|
|
39
39
|
bearer?: boolean;
|
|
40
|
+
/** Say "no thinking" with an explicit `thinking: { type: "disabled" }` when
|
|
41
|
+
* effort resolves to none, instead of omitting the field. For endpoints
|
|
42
|
+
* where an absent field means the MODEL's default, not off — Z.ai's coding
|
|
43
|
+
* endpoint reads silence as thinking ON for reasoning-mandatory models like
|
|
44
|
+
* GLM 5.3 Flash (measured 2026-09-13: omit → thinking block; disabled →
|
|
45
|
+
* none), and it accepts the marker natively. Native Anthropic has no such
|
|
46
|
+
* marker and defaults to off when the field is absent, so leave this unset
|
|
47
|
+
* there. */
|
|
48
|
+
explicitNone?: boolean;
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
const DEFAULT_BASE_URL = "https://api.anthropic.com";
|
|
@@ -181,15 +190,17 @@ export function toAnthropicMessages(messages: readonly ChatMessage[]): {
|
|
|
181
190
|
return { ...(blocks ? { system: blocks } : {}), messages: out };
|
|
182
191
|
}
|
|
183
192
|
|
|
193
|
+
interface AnthropicUsage {
|
|
194
|
+
input_tokens?: number;
|
|
195
|
+
output_tokens?: number;
|
|
196
|
+
cache_read_input_tokens?: number;
|
|
197
|
+
cache_creation_input_tokens?: number;
|
|
198
|
+
}
|
|
199
|
+
|
|
184
200
|
interface AnthropicEvent {
|
|
185
201
|
type?: string;
|
|
186
202
|
message?: {
|
|
187
|
-
usage?:
|
|
188
|
-
input_tokens?: number;
|
|
189
|
-
output_tokens?: number;
|
|
190
|
-
cache_read_input_tokens?: number;
|
|
191
|
-
cache_creation_input_tokens?: number;
|
|
192
|
-
};
|
|
203
|
+
usage?: AnthropicUsage;
|
|
193
204
|
};
|
|
194
205
|
content_block?: { type?: string; id?: string; name?: string };
|
|
195
206
|
delta?: {
|
|
@@ -199,7 +210,7 @@ interface AnthropicEvent {
|
|
|
199
210
|
partial_json?: string;
|
|
200
211
|
stop_reason?: string;
|
|
201
212
|
};
|
|
202
|
-
usage?:
|
|
213
|
+
usage?: AnthropicUsage;
|
|
203
214
|
index?: number;
|
|
204
215
|
error?: { message?: string; type?: string };
|
|
205
216
|
}
|
|
@@ -254,13 +265,17 @@ export function createAnthropicProvider(config: AnthropicConfig): Provider {
|
|
|
254
265
|
// Thinking and sampling are mutually exclusive on this shape.
|
|
255
266
|
delete request.temperature;
|
|
256
267
|
delete request.top_p;
|
|
268
|
+
} else if (config.explicitNone) {
|
|
269
|
+
// The one dialect where silence means the model default — which is ON
|
|
270
|
+
// for a reasoning-mandatory model — so "none" has to be said out loud.
|
|
271
|
+
request.thinking = { type: "disabled" };
|
|
257
272
|
}
|
|
258
273
|
|
|
259
274
|
// Anthropic reports cache reads and writes as fields of their OWN,
|
|
260
275
|
// EXCLUDED from `input_tokens` — where the OpenAI shapes report a cached
|
|
261
276
|
// subset already inside the prompt count. Reconciling here is what keeps
|
|
262
277
|
// one usage record meaningful across both, and a cost figure honest.
|
|
263
|
-
let
|
|
278
|
+
let freshInputTokens = 0;
|
|
264
279
|
let cachedInputTokens = 0;
|
|
265
280
|
let cacheWriteTokens = 0;
|
|
266
281
|
let outputTokens = 0;
|
|
@@ -300,7 +315,7 @@ export function createAnthropicProvider(config: AnthropicConfig): Provider {
|
|
|
300
315
|
const usage = event.message?.usage;
|
|
301
316
|
cachedInputTokens = usage?.cache_read_input_tokens ?? 0;
|
|
302
317
|
cacheWriteTokens = usage?.cache_creation_input_tokens ?? 0;
|
|
303
|
-
|
|
318
|
+
freshInputTokens = usage?.input_tokens ?? 0;
|
|
304
319
|
break;
|
|
305
320
|
}
|
|
306
321
|
|
|
@@ -340,6 +355,12 @@ export function createAnthropicProvider(config: AnthropicConfig): Provider {
|
|
|
340
355
|
break;
|
|
341
356
|
|
|
342
357
|
case "message_delta": {
|
|
358
|
+
// Z.ai starts with zero input usage and reports the real totals here.
|
|
359
|
+
// These are cumulative counters, not increments. Native Anthropic
|
|
360
|
+
// usually sends only output_tokens here, so absent fields retain theirs.
|
|
361
|
+
freshInputTokens = event.usage?.input_tokens ?? freshInputTokens;
|
|
362
|
+
cachedInputTokens = event.usage?.cache_read_input_tokens ?? cachedInputTokens;
|
|
363
|
+
cacheWriteTokens = event.usage?.cache_creation_input_tokens ?? cacheWriteTokens;
|
|
343
364
|
outputTokens = event.usage?.output_tokens ?? outputTokens;
|
|
344
365
|
const finishReason = mapStopReason(event.delta?.stop_reason);
|
|
345
366
|
if (finishReason) yield { type: "finish", finishReason };
|
|
@@ -349,7 +370,12 @@ export function createAnthropicProvider(config: AnthropicConfig): Provider {
|
|
|
349
370
|
case "message_stop":
|
|
350
371
|
yield {
|
|
351
372
|
type: "usage",
|
|
352
|
-
usage: {
|
|
373
|
+
usage: {
|
|
374
|
+
inputTokens: freshInputTokens + cachedInputTokens + cacheWriteTokens,
|
|
375
|
+
cachedInputTokens,
|
|
376
|
+
cacheWriteTokens,
|
|
377
|
+
outputTokens,
|
|
378
|
+
},
|
|
353
379
|
};
|
|
354
380
|
break;
|
|
355
381
|
}
|