@providerkit/core 0.5.0 → 0.5.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/dist/providers/openai.d.ts +14 -10
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +36 -13
- package/dist/providers/openai.js.map +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +7 -1
- package/dist/schema.js.map +1 -1
- package/package.json +1 -1
- package/src/providers/openai.ts +36 -13
- package/src/schema.ts +7 -1
|
@@ -67,16 +67,20 @@ export type EffortDialect = "openai" | "openrouter" | "deepseek" | "off";
|
|
|
67
67
|
*
|
|
68
68
|
* One knob, three incompatible spellings, and the differences are not cosmetic:
|
|
69
69
|
*
|
|
70
|
-
* - **OpenRouter
|
|
71
|
-
* `reasoning.enabled: false`
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
70
|
+
* - **On OpenRouter, a model that must think refuses BOTH off switches.**
|
|
71
|
+
* `reasoning.enabled: false` is refused by GLM 5.3 Flash with
|
|
72
|
+
* `400 "Reasoning is mandatory for this endpoint and cannot be disabled."`,
|
|
73
|
+
* which cost one app its onboarding read, and is why nothing here ever emits
|
|
74
|
+
* that field. That was then read as "OpenRouter has no off switch" and `none`
|
|
75
|
+
* was floored to `low` on the strength of it — wrong, because `none` is a
|
|
76
|
+
* member of OpenRouter's own effort enum and the floor bought a thinking pass
|
|
77
|
+
* on every turn that asked for none. But the correction over-reached: `none`
|
|
78
|
+
* is NOT universally safe either. Re-measured 2026-09-09, the same model
|
|
79
|
+
* answers the same 400 to `effort: "none"`. An unsupported level is mapped to
|
|
80
|
+
* the nearest only where the model CAN vary its effort; where thinking is
|
|
81
|
+
* mandatory, `none` is refused outright and the whole call is lost.
|
|
82
|
+
* The honest way to ask for the least thinking on this dialect is to pass no
|
|
83
|
+
* effort at all — see `effortParams`, where the numbers live.
|
|
80
84
|
* - **DeepSeek V4 defaults thinking ON**, so `none` has to be an explicit
|
|
81
85
|
* refusal. That is the case proving OpenRouter's floor is a constraint and
|
|
82
86
|
* not a preference for always thinking.
|
|
@@ -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
|
|
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,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
|
@@ -13,16 +13,20 @@ const DEFAULT_BASE_URL = "https://api.openai.com";
|
|
|
13
13
|
*
|
|
14
14
|
* One knob, three incompatible spellings, and the differences are not cosmetic:
|
|
15
15
|
*
|
|
16
|
-
* - **OpenRouter
|
|
17
|
-
* `reasoning.enabled: false`
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
16
|
+
* - **On OpenRouter, a model that must think refuses BOTH off switches.**
|
|
17
|
+
* `reasoning.enabled: false` is refused by GLM 5.3 Flash with
|
|
18
|
+
* `400 "Reasoning is mandatory for this endpoint and cannot be disabled."`,
|
|
19
|
+
* which cost one app its onboarding read, and is why nothing here ever emits
|
|
20
|
+
* that field. That was then read as "OpenRouter has no off switch" and `none`
|
|
21
|
+
* was floored to `low` on the strength of it — wrong, because `none` is a
|
|
22
|
+
* member of OpenRouter's own effort enum and the floor bought a thinking pass
|
|
23
|
+
* on every turn that asked for none. But the correction over-reached: `none`
|
|
24
|
+
* is NOT universally safe either. Re-measured 2026-09-09, the same model
|
|
25
|
+
* answers the same 400 to `effort: "none"`. An unsupported level is mapped to
|
|
26
|
+
* the nearest only where the model CAN vary its effort; where thinking is
|
|
27
|
+
* mandatory, `none` is refused outright and the whole call is lost.
|
|
28
|
+
* The honest way to ask for the least thinking on this dialect is to pass no
|
|
29
|
+
* effort at all — see `effortParams`, where the numbers live.
|
|
26
30
|
* - **DeepSeek V4 defaults thinking ON**, so `none` has to be an explicit
|
|
27
31
|
* refusal. That is the case proving OpenRouter's floor is a constraint and
|
|
28
32
|
* not a preference for always thinking.
|
|
@@ -57,9 +61,28 @@ export function effortParams(dialect, effort) {
|
|
|
57
61
|
case "openrouter":
|
|
58
62
|
// Its own enum runs xhigh > high > medium > low > minimal > none, so `max`
|
|
59
63
|
// has a real tier here and clamping it to `high` throws the top one away —
|
|
60
|
-
// 0.95 of the budget against 0.8.
|
|
61
|
-
//
|
|
62
|
-
//
|
|
64
|
+
// 0.95 of the budget against 0.8.
|
|
65
|
+
//
|
|
66
|
+
// CAUTION, measured 2026-09-09 against z-ai/glm-5.3-flash: the claim that
|
|
67
|
+
// "OpenRouter maps an unsupported level to its nearest rather than
|
|
68
|
+
// refusing" does NOT hold for `none`. That model answers
|
|
69
|
+
// `400 "Reasoning is mandatory for this endpoint and cannot be disabled."`
|
|
70
|
+
// to `reasoning.effort: "none"` exactly as it does to
|
|
71
|
+
// `reasoning.enabled: false` — so on a model that must think, `none` is a
|
|
72
|
+
// refusal and not a floor. Callers that mean "as little as possible"
|
|
73
|
+
// should pass no effort at all rather than `none`, which is why the
|
|
74
|
+
// absent-effort branch above stays load-bearing.
|
|
75
|
+
//
|
|
76
|
+
// Same measurement, same model, one structured-output call three ways:
|
|
77
|
+
//
|
|
78
|
+
// no reasoning field 4,1s · 1 reasoning token
|
|
79
|
+
// effort "minimal" 46,6s · 474 reasoning tokens
|
|
80
|
+
// max_tokens 2000 30,3s · 484 reasoning tokens
|
|
81
|
+
//
|
|
82
|
+
// Its default sat below every level on offer, so naming one RAISED the
|
|
83
|
+
// thinking — an effort is a request, never a cap. Nearly all of the extra
|
|
84
|
+
// time was spent before the first token arrived, so it does not show up as
|
|
85
|
+
// slow streaming; it shows up as a call that looks hung.
|
|
63
86
|
return { reasoning: { effort: effort === "max" ? "xhigh" : (level ?? "none") } };
|
|
64
87
|
case "openai":
|
|
65
88
|
return { reasoning_effort: level ?? "none" };
|
|
@@ -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;AA+D5D,MAAM,gBAAg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C5D,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,KAAK,SAAS;gCACxC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;gCACxC,CAAC,CAAC,EAAE,CAAC;yBACR,CAAC,CAAC,CAAC;wBACJ,GAAG,GAAG,IAAI,CAAC;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"}
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAgBA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAkDpE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAgBA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAkDpE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAWpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAmBrD"}
|
package/dist/schema.js
CHANGED
|
@@ -80,7 +80,13 @@ export function clampToSchema(value, node) {
|
|
|
80
80
|
* nothing whatsoever about its shape.
|
|
81
81
|
*/
|
|
82
82
|
export function schemaPrompt(schema) {
|
|
83
|
-
return ("Respond with a single JSON object matching this schema. No prose, no code fence
|
|
83
|
+
return ("Respond with a single JSON object matching this schema. No prose, no code fence.\n" +
|
|
84
|
+
// Nothing pins the decoder when the schema rides in the prompt, so the model
|
|
85
|
+
// is free to pretty-print its reply — and it does, putting a real line break
|
|
86
|
+
// inside a string value, which is invalid JSON and costs the whole response.
|
|
87
|
+
// Saying so is not a guarantee (the caller still has to survive a violation)
|
|
88
|
+
// but this is the only place the model is told at all.
|
|
89
|
+
"Write a line break inside a string value as \\n. A real line break there is invalid JSON.\n" +
|
|
84
90
|
JSON.stringify(schema));
|
|
85
91
|
}
|
|
86
92
|
export function isStrictSchema(node) {
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAgBA,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,IAAa;IACzD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACpD,MAAM,MAAM,GAAG,IAAkB,CAAC;IAElC,8EAA8E;IAC9E,4EAA4E;IAC5E,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC;IAC3C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,MAAM,CAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;IAC3F,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC;QAC7B,2EAA2E;QAC3E,yEAAyE;QACzE,oBAA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,oBAAoB,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IACxD,MAAM,UAAU,GAAG,MAAM,CAAC,UAAqC,CAAC;IAChE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAE,MAAM,CAAC,QAAqB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9F,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,KAAK,CACrC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,CAC7D,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/providers/openai.ts
CHANGED
|
@@ -91,16 +91,20 @@ export type EffortDialect = "openai" | "openrouter" | "deepseek" | "off";
|
|
|
91
91
|
*
|
|
92
92
|
* One knob, three incompatible spellings, and the differences are not cosmetic:
|
|
93
93
|
*
|
|
94
|
-
* - **OpenRouter
|
|
95
|
-
* `reasoning.enabled: false`
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
94
|
+
* - **On OpenRouter, a model that must think refuses BOTH off switches.**
|
|
95
|
+
* `reasoning.enabled: false` is refused by GLM 5.3 Flash with
|
|
96
|
+
* `400 "Reasoning is mandatory for this endpoint and cannot be disabled."`,
|
|
97
|
+
* which cost one app its onboarding read, and is why nothing here ever emits
|
|
98
|
+
* that field. That was then read as "OpenRouter has no off switch" and `none`
|
|
99
|
+
* was floored to `low` on the strength of it — wrong, because `none` is a
|
|
100
|
+
* member of OpenRouter's own effort enum and the floor bought a thinking pass
|
|
101
|
+
* on every turn that asked for none. But the correction over-reached: `none`
|
|
102
|
+
* is NOT universally safe either. Re-measured 2026-09-09, the same model
|
|
103
|
+
* answers the same 400 to `effort: "none"`. An unsupported level is mapped to
|
|
104
|
+
* the nearest only where the model CAN vary its effort; where thinking is
|
|
105
|
+
* mandatory, `none` is refused outright and the whole call is lost.
|
|
106
|
+
* The honest way to ask for the least thinking on this dialect is to pass no
|
|
107
|
+
* effort at all — see `effortParams`, where the numbers live.
|
|
104
108
|
* - **DeepSeek V4 defaults thinking ON**, so `none` has to be an explicit
|
|
105
109
|
* refusal. That is the case proving OpenRouter's floor is a constraint and
|
|
106
110
|
* not a preference for always thinking.
|
|
@@ -136,9 +140,28 @@ export function effortParams(
|
|
|
136
140
|
case "openrouter":
|
|
137
141
|
// Its own enum runs xhigh > high > medium > low > minimal > none, so `max`
|
|
138
142
|
// has a real tier here and clamping it to `high` throws the top one away —
|
|
139
|
-
// 0.95 of the budget against 0.8.
|
|
140
|
-
//
|
|
141
|
-
//
|
|
143
|
+
// 0.95 of the budget against 0.8.
|
|
144
|
+
//
|
|
145
|
+
// CAUTION, measured 2026-09-09 against z-ai/glm-5.3-flash: the claim that
|
|
146
|
+
// "OpenRouter maps an unsupported level to its nearest rather than
|
|
147
|
+
// refusing" does NOT hold for `none`. That model answers
|
|
148
|
+
// `400 "Reasoning is mandatory for this endpoint and cannot be disabled."`
|
|
149
|
+
// to `reasoning.effort: "none"` exactly as it does to
|
|
150
|
+
// `reasoning.enabled: false` — so on a model that must think, `none` is a
|
|
151
|
+
// refusal and not a floor. Callers that mean "as little as possible"
|
|
152
|
+
// should pass no effort at all rather than `none`, which is why the
|
|
153
|
+
// absent-effort branch above stays load-bearing.
|
|
154
|
+
//
|
|
155
|
+
// Same measurement, same model, one structured-output call three ways:
|
|
156
|
+
//
|
|
157
|
+
// no reasoning field 4,1s · 1 reasoning token
|
|
158
|
+
// effort "minimal" 46,6s · 474 reasoning tokens
|
|
159
|
+
// max_tokens 2000 30,3s · 484 reasoning tokens
|
|
160
|
+
//
|
|
161
|
+
// Its default sat below every level on offer, so naming one RAISED the
|
|
162
|
+
// thinking — an effort is a request, never a cap. Nearly all of the extra
|
|
163
|
+
// time was spent before the first token arrived, so it does not show up as
|
|
164
|
+
// slow streaming; it shows up as a call that looks hung.
|
|
142
165
|
return { reasoning: { effort: effort === "max" ? "xhigh" : (level ?? "none") } };
|
|
143
166
|
case "openai":
|
|
144
167
|
return { reasoning_effort: level ?? "none" };
|
package/src/schema.ts
CHANGED
|
@@ -102,7 +102,13 @@ export function clampToSchema(value: unknown, node: unknown): unknown {
|
|
|
102
102
|
*/
|
|
103
103
|
export function schemaPrompt(schema: unknown): string {
|
|
104
104
|
return (
|
|
105
|
-
"Respond with a single JSON object matching this schema. No prose, no code fence
|
|
105
|
+
"Respond with a single JSON object matching this schema. No prose, no code fence.\n" +
|
|
106
|
+
// Nothing pins the decoder when the schema rides in the prompt, so the model
|
|
107
|
+
// is free to pretty-print its reply — and it does, putting a real line break
|
|
108
|
+
// inside a string value, which is invalid JSON and costs the whole response.
|
|
109
|
+
// Saying so is not a guarantee (the caller still has to survive a violation)
|
|
110
|
+
// but this is the only place the model is told at all.
|
|
111
|
+
"Write a line break inside a string value as \\n. A real line break there is invalid JSON.\n" +
|
|
106
112
|
JSON.stringify(schema)
|
|
107
113
|
);
|
|
108
114
|
}
|