@neondatabase/ai-sdk-provider 0.0.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.
Files changed (53) hide show
  1. package/LICENSE.md +178 -0
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.js +7 -0
  4. package/dist/lib/neon-anthropic-language-model.d.ts +23 -0
  5. package/dist/lib/neon-anthropic-language-model.d.ts.map +1 -0
  6. package/dist/lib/neon-anthropic-language-model.js +38 -0
  7. package/dist/lib/neon-anthropic-language-model.js.map +1 -0
  8. package/dist/lib/neon-capabilities.d.ts +20 -0
  9. package/dist/lib/neon-capabilities.d.ts.map +1 -0
  10. package/dist/lib/neon-capabilities.js +101 -0
  11. package/dist/lib/neon-capabilities.js.map +1 -0
  12. package/dist/lib/neon-chat-language-model.d.ts +21 -0
  13. package/dist/lib/neon-chat-language-model.d.ts.map +1 -0
  14. package/dist/lib/neon-chat-language-model.js +34 -0
  15. package/dist/lib/neon-chat-language-model.js.map +1 -0
  16. package/dist/lib/neon-chat-options.d.ts +5 -0
  17. package/dist/lib/neon-chat-options.d.ts.map +1 -0
  18. package/dist/lib/neon-chat-options.js +1 -0
  19. package/dist/lib/neon-model-capabilities.d.ts +41 -0
  20. package/dist/lib/neon-model-capabilities.d.ts.map +1 -0
  21. package/dist/lib/neon-model-capabilities.js +74 -0
  22. package/dist/lib/neon-model-capabilities.js.map +1 -0
  23. package/dist/lib/neon-responses-language-model.d.ts +26 -0
  24. package/dist/lib/neon-responses-language-model.d.ts.map +1 -0
  25. package/dist/lib/neon-responses-language-model.js +44 -0
  26. package/dist/lib/neon-responses-language-model.js.map +1 -0
  27. package/dist/lib/provider.d.ts +48 -0
  28. package/dist/lib/provider.d.ts.map +1 -0
  29. package/dist/lib/provider.js +112 -0
  30. package/dist/lib/provider.js.map +1 -0
  31. package/dist/lib/version.d.ts +5 -0
  32. package/dist/lib/version.d.ts.map +1 -0
  33. package/dist/lib/version.js +7 -0
  34. package/dist/lib/version.js.map +1 -0
  35. package/dist/package.js +6 -0
  36. package/dist/package.js.map +1 -0
  37. package/dist/v1.d.ts +7 -0
  38. package/dist/v1.js +6 -0
  39. package/package.json +74 -23
  40. package/src/index.ts +0 -5
  41. package/src/lib/neon-anthropic-language-model.ts +0 -51
  42. package/src/lib/neon-capabilities.ts +0 -133
  43. package/src/lib/neon-chat-language-model.ts +0 -56
  44. package/src/lib/neon-chat-options.ts +0 -48
  45. package/src/lib/neon-model-capabilities.test.ts +0 -66
  46. package/src/lib/neon-model-capabilities.ts +0 -137
  47. package/src/lib/neon-responses-language-model.ts +0 -60
  48. package/src/lib/provider.ts +0 -211
  49. package/src/lib/version.ts +0 -2
  50. package/src/v1.ts +0 -26
  51. package/tsconfig.json +0 -4
  52. package/tsdown.config.ts +0 -12
  53. package/vitest.config.ts +0 -17
package/LICENSE.md ADDED
@@ -0,0 +1,178 @@
1
+ # Apache License 2.0
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,7 @@
1
+ import { NeonAnthropicLanguageModel } from "./lib/neon-anthropic-language-model.js";
2
+ import { NeonChatLanguageModel } from "./lib/neon-chat-language-model.js";
3
+ import { NeonChatModelId } from "./lib/neon-chat-options.js";
4
+ import { NeonModelCapabilities, NeonModelFamily, NeonModelRoute, getNeonModelCapabilities, getNeonModelRoute } from "./lib/neon-model-capabilities.js";
5
+ import { NeonResponsesLanguageModel } from "./lib/neon-responses-language-model.js";
6
+ import { NeonErrorData, NeonProvider, NeonProviderSettings, createNeon, neon } from "./lib/provider.js";
7
+ export { NeonAnthropicLanguageModel, NeonChatLanguageModel, NeonChatModelId, NeonErrorData, NeonModelCapabilities, NeonModelFamily, NeonModelRoute, NeonProvider, NeonProviderSettings, NeonResponsesLanguageModel, createNeon, getNeonModelCapabilities, getNeonModelRoute, neon };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import { NeonAnthropicLanguageModel } from "./lib/neon-anthropic-language-model.js";
2
+ import { getNeonModelCapabilities, getNeonModelRoute } from "./lib/neon-model-capabilities.js";
3
+ import { NeonChatLanguageModel } from "./lib/neon-chat-language-model.js";
4
+ import { NeonResponsesLanguageModel } from "./lib/neon-responses-language-model.js";
5
+ import { createNeon, neon } from "./lib/provider.js";
6
+ import "./v1.js";
7
+ export { NeonAnthropicLanguageModel, NeonChatLanguageModel, NeonResponsesLanguageModel, createNeon, getNeonModelCapabilities, getNeonModelRoute, neon };
@@ -0,0 +1,23 @@
1
+ import { AnthropicLanguageModel } from "@ai-sdk/anthropic/internal";
2
+ import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult } from "@ai-sdk/provider";
3
+
4
+ //#region src/lib/neon-anthropic-language-model.d.ts
5
+
6
+ /**
7
+ * Language model for Anthropic models served via the Neon AI Gateway's native
8
+ * Messages API (`/ai-gateway/anthropic/v1/messages`). Unlocks streaming
9
+ * structured output and native reasoning for Claude.
10
+ *
11
+ * The shared Anthropic model defaults to fine-grained tool-input streaming
12
+ * (`eager_input_streaming: true`) on streaming tool calls, which the gateway
13
+ * rejects (`Extra inputs are not permitted`). We disable it via the model's own
14
+ * `toolStreaming` option so streaming tool calls work. Users can still override.
15
+ */
16
+ declare class NeonAnthropicLanguageModel extends AnthropicLanguageModel implements LanguageModelV4 {
17
+ private withGatewayCompat;
18
+ doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
19
+ doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
20
+ }
21
+ //#endregion
22
+ export { NeonAnthropicLanguageModel };
23
+ //# sourceMappingURL=neon-anthropic-language-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-anthropic-language-model.d.ts","names":[],"sources":["../../src/lib/neon-anthropic-language-model.ts"],"mappings":";;;;;;;AAkBA;;;;;;;;AACS,cADI,0BAAA,SACJ,sBAAA,YACG,eADH,CAAA;UACG,iBAAA;EAAe,UAAA,CAAA,OAAA,EAoBhB,0BApBgB,CAAA,EAqBvB,OArBuB,CAqBf,6BArBe,CAAA;oBA0BhB,6BACP,QAAQ"}
@@ -0,0 +1,38 @@
1
+ import { AnthropicLanguageModel } from "@ai-sdk/anthropic/internal";
2
+ //#region src/lib/neon-anthropic-language-model.ts
3
+ /**
4
+ * Language model for Anthropic models served via the Neon AI Gateway's native
5
+ * Messages API (`/ai-gateway/anthropic/v1/messages`). Unlocks streaming
6
+ * structured output and native reasoning for Claude.
7
+ *
8
+ * The shared Anthropic model defaults to fine-grained tool-input streaming
9
+ * (`eager_input_streaming: true`) on streaming tool calls, which the gateway
10
+ * rejects (`Extra inputs are not permitted`). We disable it via the model's own
11
+ * `toolStreaming` option so streaming tool calls work. Users can still override.
12
+ */
13
+ var NeonAnthropicLanguageModel = class extends AnthropicLanguageModel {
14
+ withGatewayCompat(options) {
15
+ const anthropic = options.providerOptions?.anthropic;
16
+ if (anthropic != null && "toolStreaming" in anthropic) return options;
17
+ return {
18
+ ...options,
19
+ providerOptions: {
20
+ ...options.providerOptions,
21
+ anthropic: {
22
+ ...anthropic,
23
+ toolStreaming: false
24
+ }
25
+ }
26
+ };
27
+ }
28
+ doGenerate(options) {
29
+ return super.doGenerate(this.withGatewayCompat(options));
30
+ }
31
+ doStream(options) {
32
+ return super.doStream(this.withGatewayCompat(options));
33
+ }
34
+ };
35
+ //#endregion
36
+ export { NeonAnthropicLanguageModel };
37
+
38
+ //# sourceMappingURL=neon-anthropic-language-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-anthropic-language-model.js","names":[],"sources":["../../src/lib/neon-anthropic-language-model.ts"],"sourcesContent":["import { AnthropicLanguageModel } from \"@ai-sdk/anthropic/internal\";\nimport type {\n\tLanguageModelV4,\n\tLanguageModelV4CallOptions,\n\tLanguageModelV4GenerateResult,\n\tLanguageModelV4StreamResult,\n} from \"@ai-sdk/provider\";\n\n/**\n * Language model for Anthropic models served via the Neon AI Gateway's native\n * Messages API (`/ai-gateway/anthropic/v1/messages`). Unlocks streaming\n * structured output and native reasoning for Claude.\n *\n * The shared Anthropic model defaults to fine-grained tool-input streaming\n * (`eager_input_streaming: true`) on streaming tool calls, which the gateway\n * rejects (`Extra inputs are not permitted`). We disable it via the model's own\n * `toolStreaming` option so streaming tool calls work. Users can still override.\n */\nexport class NeonAnthropicLanguageModel\n\textends AnthropicLanguageModel\n\timplements LanguageModelV4\n{\n\tprivate withGatewayCompat(\n\t\toptions: LanguageModelV4CallOptions,\n\t): LanguageModelV4CallOptions {\n\t\tconst anthropic = options.providerOptions?.anthropic;\n\t\t// Respect an explicit user setting.\n\t\tif (anthropic != null && \"toolStreaming\" in anthropic) {\n\t\t\treturn options;\n\t\t}\n\t\treturn {\n\t\t\t...options,\n\t\t\tproviderOptions: {\n\t\t\t\t...options.providerOptions,\n\t\t\t\tanthropic: { ...anthropic, toolStreaming: false },\n\t\t\t},\n\t\t};\n\t}\n\n\toverride doGenerate(\n\t\toptions: LanguageModelV4CallOptions,\n\t): Promise<LanguageModelV4GenerateResult> {\n\t\treturn super.doGenerate(this.withGatewayCompat(options));\n\t}\n\n\toverride doStream(\n\t\toptions: LanguageModelV4CallOptions,\n\t): Promise<LanguageModelV4StreamResult> {\n\t\treturn super.doStream(this.withGatewayCompat(options));\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,IAAa,6BAAb,cACS,uBAET;CACC,kBACC,SAC6B;EAC7B,MAAM,YAAY,QAAQ,iBAAiB;EAE3C,IAAI,aAAa,QAAQ,mBAAmB,WAC3C,OAAO;EAER,OAAO;GACN,GAAG;GACH,iBAAiB;IAChB,GAAG,QAAQ;IACX,WAAW;KAAE,GAAG;KAAW,eAAe;IAAM;GACjD;EACD;CACD;CAEA,WACC,SACyC;EACzC,OAAO,MAAM,WAAW,KAAK,kBAAkB,OAAO,CAAC;CACxD;CAEA,SACC,SACuC;EACvC,OAAO,MAAM,SAAS,KAAK,kBAAkB,OAAO,CAAC;CACtD;AACD"}
@@ -0,0 +1,20 @@
1
+ import { LanguageModelV4CallOptions, LanguageModelV4StreamPart, SharedV4Warning } from "@ai-sdk/provider";
2
+
3
+ //#region src/lib/neon-capabilities.d.ts
4
+
5
+ /**
6
+ * Drop call options the resolved model's upstream backend does not accept and
7
+ * collect a warning for each, so callers get a clear signal instead of a hard
8
+ * `400` from the gateway.
9
+ */
10
+ declare function applyNeonCapabilities(modelId: string, options: LanguageModelV4CallOptions): {
11
+ options: LanguageModelV4CallOptions;
12
+ warnings: SharedV4Warning[];
13
+ };
14
+ /**
15
+ * Merge additional warnings into the `stream-start` part of a model stream.
16
+ */
17
+ declare function mergeStreamStartWarnings(extra: SharedV4Warning[]): TransformStream<LanguageModelV4StreamPart, LanguageModelV4StreamPart>;
18
+ //#endregion
19
+ export { applyNeonCapabilities, mergeStreamStartWarnings };
20
+ //# sourceMappingURL=neon-capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-capabilities.d.ts","names":[],"sources":["../../src/lib/neon-capabilities.ts"],"mappings":";;;;;;AAcA;;;AAGc,iBAHE,qBAAA,CAGF,OAAA,EAAA,MAAA,EAAA,OAAA,EADJ,0BACI,CAAA,EAAA;SAAsC,EAAtC,0BAAsC;EAAe,QAAA,EAAf,eAAe,EAAA;AAiGnE,CAAA;;;;AAAiE,iBAAjD,wBAAA,CAAiD,KAAA,EAAjB,eAAiB,EAAA,CAAA,EAAA,eAAA,CAAA,yBAAA,EAAA,yBAAA,CAAA"}
@@ -0,0 +1,101 @@
1
+ import { getNeonModelCapabilities } from "./neon-model-capabilities.js";
2
+ import { isCustomReasoning } from "@ai-sdk/provider-utils";
3
+ //#region src/lib/neon-capabilities.ts
4
+ /**
5
+ * Drop call options the resolved model's upstream backend does not accept and
6
+ * collect a warning for each, so callers get a clear signal instead of a hard
7
+ * `400` from the gateway.
8
+ */
9
+ function applyNeonCapabilities(modelId, options) {
10
+ const caps = getNeonModelCapabilities(modelId);
11
+ const warnings = [];
12
+ const patch = {};
13
+ const dropUnsupported = (feature) => {
14
+ warnings.push({
15
+ type: "unsupported",
16
+ feature,
17
+ details: `${feature} is not supported by the Neon AI Gateway for ${caps.family} model "${modelId}" and was dropped.`
18
+ });
19
+ };
20
+ if (options.temperature != null && !caps.supportsTemperature) {
21
+ patch.temperature = void 0;
22
+ dropUnsupported("temperature");
23
+ }
24
+ if (options.topP != null && !caps.supportsTopP) {
25
+ patch.topP = void 0;
26
+ dropUnsupported("topP");
27
+ }
28
+ const effectiveTemperature = "temperature" in patch ? patch.temperature : options.temperature;
29
+ const effectiveTopP = "topP" in patch ? patch.topP : options.topP;
30
+ if (caps.temperatureTopPMutuallyExclusive && effectiveTemperature != null && effectiveTopP != null) {
31
+ patch.topP = void 0;
32
+ warnings.push({
33
+ type: "compatibility",
34
+ feature: "topP",
35
+ details: `${caps.family} models accept only one of temperature or topP; topP was dropped.`
36
+ });
37
+ }
38
+ if (options.frequencyPenalty != null && !caps.supportsPenalties) {
39
+ patch.frequencyPenalty = void 0;
40
+ dropUnsupported("frequencyPenalty");
41
+ }
42
+ if (options.presencePenalty != null && !caps.supportsPenalties) {
43
+ patch.presencePenalty = void 0;
44
+ dropUnsupported("presencePenalty");
45
+ }
46
+ if (options.seed != null && !caps.supportsSeed) {
47
+ patch.seed = void 0;
48
+ dropUnsupported("seed");
49
+ }
50
+ if (options.stopSequences != null && !caps.supportsStopSequences) {
51
+ patch.stopSequences = void 0;
52
+ dropUnsupported("stopSequences");
53
+ }
54
+ if (!caps.supportsReasoningEffort) {
55
+ const { providerOptions } = options;
56
+ const hasProviderEffort = providerOptions != null && Object.values(providerOptions).some((group) => "reasoningEffort" in group && group.reasoningEffort != null);
57
+ const hasReasoningOption = isCustomReasoning(options.reasoning) && options.reasoning !== "none";
58
+ if (hasProviderEffort || hasReasoningOption) {
59
+ dropUnsupported("reasoningEffort");
60
+ if (hasProviderEffort && providerOptions != null) {
61
+ const cleaned = {};
62
+ for (const [key, group] of Object.entries(providerOptions)) if ("reasoningEffort" in group) {
63
+ const { reasoningEffort: _removed, ...rest } = group;
64
+ cleaned[key] = rest;
65
+ } else cleaned[key] = group;
66
+ patch.providerOptions = cleaned;
67
+ }
68
+ if (hasReasoningOption) patch.reasoning = void 0;
69
+ }
70
+ }
71
+ if (Object.keys(patch).length === 0) return {
72
+ options,
73
+ warnings
74
+ };
75
+ return {
76
+ options: {
77
+ ...options,
78
+ ...patch
79
+ },
80
+ warnings
81
+ };
82
+ }
83
+ /**
84
+ * Merge additional warnings into the `stream-start` part of a model stream.
85
+ */
86
+ function mergeStreamStartWarnings(extra) {
87
+ let merged = false;
88
+ return new TransformStream({ transform(part, controller) {
89
+ if (!merged && part.type === "stream-start") {
90
+ merged = true;
91
+ controller.enqueue({
92
+ ...part,
93
+ warnings: [...extra, ...part.warnings]
94
+ });
95
+ } else controller.enqueue(part);
96
+ } });
97
+ }
98
+ //#endregion
99
+ export { applyNeonCapabilities, mergeStreamStartWarnings };
100
+
101
+ //# sourceMappingURL=neon-capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-capabilities.js","names":[],"sources":["../../src/lib/neon-capabilities.ts"],"sourcesContent":["import type {\n\tLanguageModelV4CallOptions,\n\tLanguageModelV4StreamPart,\n\tSharedV4ProviderOptions,\n\tSharedV4Warning,\n} from \"@ai-sdk/provider\";\nimport { isCustomReasoning } from \"@ai-sdk/provider-utils\";\nimport { getNeonModelCapabilities } from \"./neon-model-capabilities.js\";\n\n/**\n * Drop call options the resolved model's upstream backend does not accept and\n * collect a warning for each, so callers get a clear signal instead of a hard\n * `400` from the gateway.\n */\nexport function applyNeonCapabilities(\n\tmodelId: string,\n\toptions: LanguageModelV4CallOptions,\n): { options: LanguageModelV4CallOptions; warnings: SharedV4Warning[] } {\n\tconst caps = getNeonModelCapabilities(modelId);\n\tconst warnings: SharedV4Warning[] = [];\n\tconst patch: Partial<LanguageModelV4CallOptions> = {};\n\n\tconst dropUnsupported = (feature: string) => {\n\t\twarnings.push({\n\t\t\ttype: \"unsupported\",\n\t\t\tfeature,\n\t\t\tdetails: `${feature} is not supported by the Neon AI Gateway for ${caps.family} model \"${modelId}\" and was dropped.`,\n\t\t});\n\t};\n\n\tif (options.temperature != null && !caps.supportsTemperature) {\n\t\tpatch.temperature = undefined;\n\t\tdropUnsupported(\"temperature\");\n\t}\n\tif (options.topP != null && !caps.supportsTopP) {\n\t\tpatch.topP = undefined;\n\t\tdropUnsupported(\"topP\");\n\t}\n\n\t// Anthropic-style models accept only one of temperature / topP.\n\tconst effectiveTemperature =\n\t\t\"temperature\" in patch ? patch.temperature : options.temperature;\n\tconst effectiveTopP = \"topP\" in patch ? patch.topP : options.topP;\n\tif (\n\t\tcaps.temperatureTopPMutuallyExclusive &&\n\t\teffectiveTemperature != null &&\n\t\teffectiveTopP != null\n\t) {\n\t\tpatch.topP = undefined;\n\t\twarnings.push({\n\t\t\ttype: \"compatibility\",\n\t\t\tfeature: \"topP\",\n\t\t\tdetails: `${caps.family} models accept only one of temperature or topP; topP was dropped.`,\n\t\t});\n\t}\n\n\tif (options.frequencyPenalty != null && !caps.supportsPenalties) {\n\t\tpatch.frequencyPenalty = undefined;\n\t\tdropUnsupported(\"frequencyPenalty\");\n\t}\n\tif (options.presencePenalty != null && !caps.supportsPenalties) {\n\t\tpatch.presencePenalty = undefined;\n\t\tdropUnsupported(\"presencePenalty\");\n\t}\n\tif (options.seed != null && !caps.supportsSeed) {\n\t\tpatch.seed = undefined;\n\t\tdropUnsupported(\"seed\");\n\t}\n\tif (options.stopSequences != null && !caps.supportsStopSequences) {\n\t\tpatch.stopSequences = undefined;\n\t\tdropUnsupported(\"stopSequences\");\n\t}\n\n\tif (!caps.supportsReasoningEffort) {\n\t\tconst { providerOptions } = options;\n\t\tconst hasProviderEffort =\n\t\t\tproviderOptions != null &&\n\t\t\tObject.values(providerOptions).some(\n\t\t\t\t(group) =>\n\t\t\t\t\t\"reasoningEffort\" in group && group.reasoningEffort != null,\n\t\t\t);\n\t\tconst hasReasoningOption =\n\t\t\tisCustomReasoning(options.reasoning) &&\n\t\t\toptions.reasoning !== \"none\";\n\n\t\tif (hasProviderEffort || hasReasoningOption) {\n\t\t\tdropUnsupported(\"reasoningEffort\");\n\t\t\tif (hasProviderEffort && providerOptions != null) {\n\t\t\t\tconst cleaned: SharedV4ProviderOptions = {};\n\t\t\t\tfor (const [key, group] of Object.entries(providerOptions)) {\n\t\t\t\t\tif (\"reasoningEffort\" in group) {\n\t\t\t\t\t\tconst { reasoningEffort: _removed, ...rest } = group;\n\t\t\t\t\t\tcleaned[key] = rest;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcleaned[key] = group;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpatch.providerOptions = cleaned;\n\t\t\t}\n\t\t\tif (hasReasoningOption) {\n\t\t\t\tpatch.reasoning = undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (Object.keys(patch).length === 0) {\n\t\treturn { options, warnings };\n\t}\n\treturn { options: { ...options, ...patch }, warnings };\n}\n\n/**\n * Merge additional warnings into the `stream-start` part of a model stream.\n */\nexport function mergeStreamStartWarnings(extra: SharedV4Warning[]) {\n\tlet merged = false;\n\treturn new TransformStream<\n\t\tLanguageModelV4StreamPart,\n\t\tLanguageModelV4StreamPart\n\t>({\n\t\ttransform(part, controller) {\n\t\t\tif (!merged && part.type === \"stream-start\") {\n\t\t\t\tmerged = true;\n\t\t\t\tcontroller.enqueue({\n\t\t\t\t\t...part,\n\t\t\t\t\twarnings: [...extra, ...part.warnings],\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tcontroller.enqueue(part);\n\t\t\t}\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;;;AAcA,SAAgB,sBACf,SACA,SACuE;CACvE,MAAM,OAAO,yBAAyB,OAAO;CAC7C,MAAM,WAA8B,CAAC;CACrC,MAAM,QAA6C,CAAC;CAEpD,MAAM,mBAAmB,YAAoB;EAC5C,SAAS,KAAK;GACb,MAAM;GACN;GACA,SAAS,GAAG,QAAQ,+CAA+C,KAAK,OAAO,UAAU,QAAQ;EAClG,CAAC;CACF;CAEA,IAAI,QAAQ,eAAe,QAAQ,CAAC,KAAK,qBAAqB;EAC7D,MAAM,cAAc,KAAA;EACpB,gBAAgB,aAAa;CAC9B;CACA,IAAI,QAAQ,QAAQ,QAAQ,CAAC,KAAK,cAAc;EAC/C,MAAM,OAAO,KAAA;EACb,gBAAgB,MAAM;CACvB;CAGA,MAAM,uBACL,iBAAiB,QAAQ,MAAM,cAAc,QAAQ;CACtD,MAAM,gBAAgB,UAAU,QAAQ,MAAM,OAAO,QAAQ;CAC7D,IACC,KAAK,oCACL,wBAAwB,QACxB,iBAAiB,MAChB;EACD,MAAM,OAAO,KAAA;EACb,SAAS,KAAK;GACb,MAAM;GACN,SAAS;GACT,SAAS,GAAG,KAAK,OAAO;EACzB,CAAC;CACF;CAEA,IAAI,QAAQ,oBAAoB,QAAQ,CAAC,KAAK,mBAAmB;EAChE,MAAM,mBAAmB,KAAA;EACzB,gBAAgB,kBAAkB;CACnC;CACA,IAAI,QAAQ,mBAAmB,QAAQ,CAAC,KAAK,mBAAmB;EAC/D,MAAM,kBAAkB,KAAA;EACxB,gBAAgB,iBAAiB;CAClC;CACA,IAAI,QAAQ,QAAQ,QAAQ,CAAC,KAAK,cAAc;EAC/C,MAAM,OAAO,KAAA;EACb,gBAAgB,MAAM;CACvB;CACA,IAAI,QAAQ,iBAAiB,QAAQ,CAAC,KAAK,uBAAuB;EACjE,MAAM,gBAAgB,KAAA;EACtB,gBAAgB,eAAe;CAChC;CAEA,IAAI,CAAC,KAAK,yBAAyB;EAClC,MAAM,EAAE,oBAAoB;EAC5B,MAAM,oBACL,mBAAmB,QACnB,OAAO,OAAO,eAAe,CAAC,CAAC,MAC7B,UACA,qBAAqB,SAAS,MAAM,mBAAmB,IACzD;EACD,MAAM,qBACL,kBAAkB,QAAQ,SAAS,KACnC,QAAQ,cAAc;EAEvB,IAAI,qBAAqB,oBAAoB;GAC5C,gBAAgB,iBAAiB;GACjC,IAAI,qBAAqB,mBAAmB,MAAM;IACjD,MAAM,UAAmC,CAAC;IAC1C,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,eAAe,GACxD,IAAI,qBAAqB,OAAO;KAC/B,MAAM,EAAE,iBAAiB,UAAU,GAAG,SAAS;KAC/C,QAAQ,OAAO;IAChB,OACC,QAAQ,OAAO;IAGjB,MAAM,kBAAkB;GACzB;GACA,IAAI,oBACH,MAAM,YAAY,KAAA;EAEpB;CACD;CAEA,IAAI,OAAO,KAAK,KAAK,CAAC,CAAC,WAAW,GACjC,OAAO;EAAE;EAAS;CAAS;CAE5B,OAAO;EAAE,SAAS;GAAE,GAAG;GAAS,GAAG;EAAM;EAAG;CAAS;AACtD;;;;AAKA,SAAgB,yBAAyB,OAA0B;CAClE,IAAI,SAAS;CACb,OAAO,IAAI,gBAGT,EACD,UAAU,MAAM,YAAY;EAC3B,IAAI,CAAC,UAAU,KAAK,SAAS,gBAAgB;GAC5C,SAAS;GACT,WAAW,QAAQ;IAClB,GAAG;IACH,UAAU,CAAC,GAAG,OAAO,GAAG,KAAK,QAAQ;GACtC,CAAC;EACF,OACC,WAAW,QAAQ,IAAI;CAEzB,EACD,CAAC;AACF"}
@@ -0,0 +1,21 @@
1
+ import { OpenAICompatibleChatLanguageModel } from "@ai-sdk/openai-compatible";
2
+ import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult } from "@ai-sdk/provider";
3
+
4
+ //#region src/lib/neon-chat-language-model.d.ts
5
+
6
+ /**
7
+ * Language model for the Neon AI Gateway unified (MLflow) endpoint.
8
+ *
9
+ * Used for every model that is not routed to a provider-native endpoint
10
+ * (Gemini, Llama, Qwen, gpt-oss, ...). It is a thin specialization of the shared
11
+ * OpenAI-compatible chat model that adds per-model capability handling:
12
+ * parameters an upstream backend is known to reject are dropped and reported as
13
+ * warnings instead of failing the request.
14
+ */
15
+ declare class NeonChatLanguageModel extends OpenAICompatibleChatLanguageModel implements LanguageModelV4 {
16
+ doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
17
+ doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
18
+ }
19
+ //#endregion
20
+ export { NeonChatLanguageModel };
21
+ //# sourceMappingURL=neon-chat-language-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-chat-language-model.d.ts","names":[],"sources":["../../src/lib/neon-chat-language-model.ts"],"mappings":";;;;;;;AAqBA;;;;;;;AAmBI,cAnBS,qBAAA,SACJ,iCAAA,YACG,eAiBR,CAAA;YAlBK,CAAA,OAAA,EAIE,0BAJF,CAAA,EAKL,OALK,CAKG,6BALH,CAAA;UACG,CAAA,OAAA,EAgBD,0BAhBC,CAAA,EAiBR,OAjBQ,CAiBA,2BAjBA,CAAA;AAAe"}
@@ -0,0 +1,34 @@
1
+ import { applyNeonCapabilities, mergeStreamStartWarnings } from "./neon-capabilities.js";
2
+ import { OpenAICompatibleChatLanguageModel } from "@ai-sdk/openai-compatible";
3
+ //#region src/lib/neon-chat-language-model.ts
4
+ /**
5
+ * Language model for the Neon AI Gateway unified (MLflow) endpoint.
6
+ *
7
+ * Used for every model that is not routed to a provider-native endpoint
8
+ * (Gemini, Llama, Qwen, gpt-oss, ...). It is a thin specialization of the shared
9
+ * OpenAI-compatible chat model that adds per-model capability handling:
10
+ * parameters an upstream backend is known to reject are dropped and reported as
11
+ * warnings instead of failing the request.
12
+ */
13
+ var NeonChatLanguageModel = class extends OpenAICompatibleChatLanguageModel {
14
+ async doGenerate(options) {
15
+ const { options: adjusted, warnings } = applyNeonCapabilities(this.modelId, options);
16
+ const result = await super.doGenerate(adjusted);
17
+ return warnings.length > 0 ? {
18
+ ...result,
19
+ warnings: [...warnings, ...result.warnings]
20
+ } : result;
21
+ }
22
+ async doStream(options) {
23
+ const { options: adjusted, warnings } = applyNeonCapabilities(this.modelId, options);
24
+ const result = await super.doStream(adjusted);
25
+ return warnings.length > 0 ? {
26
+ ...result,
27
+ stream: result.stream.pipeThrough(mergeStreamStartWarnings(warnings))
28
+ } : result;
29
+ }
30
+ };
31
+ //#endregion
32
+ export { NeonChatLanguageModel };
33
+
34
+ //# sourceMappingURL=neon-chat-language-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-chat-language-model.js","names":[],"sources":["../../src/lib/neon-chat-language-model.ts"],"sourcesContent":["import { OpenAICompatibleChatLanguageModel } from \"@ai-sdk/openai-compatible\";\nimport type {\n\tLanguageModelV4,\n\tLanguageModelV4CallOptions,\n\tLanguageModelV4GenerateResult,\n\tLanguageModelV4StreamResult,\n} from \"@ai-sdk/provider\";\nimport {\n\tapplyNeonCapabilities,\n\tmergeStreamStartWarnings,\n} from \"./neon-capabilities.js\";\n\n/**\n * Language model for the Neon AI Gateway unified (MLflow) endpoint.\n *\n * Used for every model that is not routed to a provider-native endpoint\n * (Gemini, Llama, Qwen, gpt-oss, ...). It is a thin specialization of the shared\n * OpenAI-compatible chat model that adds per-model capability handling:\n * parameters an upstream backend is known to reject are dropped and reported as\n * warnings instead of failing the request.\n */\nexport class NeonChatLanguageModel\n\textends OpenAICompatibleChatLanguageModel\n\timplements LanguageModelV4\n{\n\toverride async doGenerate(\n\t\toptions: LanguageModelV4CallOptions,\n\t): Promise<LanguageModelV4GenerateResult> {\n\t\tconst { options: adjusted, warnings } = applyNeonCapabilities(\n\t\t\tthis.modelId,\n\t\t\toptions,\n\t\t);\n\t\tconst result = await super.doGenerate(adjusted);\n\t\treturn warnings.length > 0\n\t\t\t? { ...result, warnings: [...warnings, ...result.warnings] }\n\t\t\t: result;\n\t}\n\n\toverride async doStream(\n\t\toptions: LanguageModelV4CallOptions,\n\t): Promise<LanguageModelV4StreamResult> {\n\t\tconst { options: adjusted, warnings } = applyNeonCapabilities(\n\t\t\tthis.modelId,\n\t\t\toptions,\n\t\t);\n\t\tconst result = await super.doStream(adjusted);\n\t\treturn warnings.length > 0\n\t\t\t? {\n\t\t\t\t\t...result,\n\t\t\t\t\tstream: result.stream.pipeThrough(\n\t\t\t\t\t\tmergeStreamStartWarnings(warnings),\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t: result;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,IAAa,wBAAb,cACS,kCAET;CACC,MAAe,WACd,SACyC;EACzC,MAAM,EAAE,SAAS,UAAU,aAAa,sBACvC,KAAK,SACL,OACD;EACA,MAAM,SAAS,MAAM,MAAM,WAAW,QAAQ;EAC9C,OAAO,SAAS,SAAS,IACtB;GAAE,GAAG;GAAQ,UAAU,CAAC,GAAG,UAAU,GAAG,OAAO,QAAQ;EAAE,IACzD;CACJ;CAEA,MAAe,SACd,SACuC;EACvC,MAAM,EAAE,SAAS,UAAU,aAAa,sBACvC,KAAK,SACL,OACD;EACA,MAAM,SAAS,MAAM,MAAM,SAAS,QAAQ;EAC5C,OAAO,SAAS,SAAS,IACtB;GACA,GAAG;GACH,QAAQ,OAAO,OAAO,YACrB,yBAAyB,QAAQ,CAClC;EACD,IACC;CACJ;AACD"}
@@ -0,0 +1,5 @@
1
+ //#region src/lib/neon-chat-options.d.ts
2
+ type NeonChatModelId = "databricks-claude-opus-4-8" | "databricks-claude-opus-4-7" | "databricks-claude-opus-4-6" | "databricks-claude-opus-4-5" | "databricks-claude-opus-4-1" | "databricks-claude-sonnet-4-6" | "databricks-claude-sonnet-4-5" | "databricks-claude-sonnet-4" | "databricks-claude-haiku-4-5" | "databricks-gpt-5" | "databricks-gpt-5-mini" | "databricks-gpt-5-nano" | "databricks-gpt-5-1" | "databricks-gpt-5-2" | "databricks-gpt-5-2-codex" | "databricks-gpt-5-3-codex" | "databricks-gpt-5-4" | "databricks-gpt-5-4-mini" | "databricks-gpt-5-4-nano" | "databricks-gpt-5-5" | "databricks-gpt-5-5-pro" | "databricks-gpt-oss-120b" | "databricks-gpt-oss-20b" | "databricks-gemini-3-5-flash" | "databricks-gemini-3-1-flash-lite" | "databricks-gemini-2-5-pro" | "databricks-gemini-2-5-flash" | "databricks-gemma-3-12b" | "databricks-llama-4-maverick" | "databricks-meta-llama-3-3-70b-instruct" | "databricks-meta-llama-3-1-8b-instruct" | "databricks-qwen3-next-80b-a3b-instruct" | "databricks-qwen35-122b-a10b" | (string & {});
3
+ //#endregion
4
+ export { NeonChatModelId };
5
+ //# sourceMappingURL=neon-chat-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-chat-options.d.ts","names":[],"sources":["../../src/lib/neon-chat-options.ts"],"mappings":";KAOY,eAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ //#region src/lib/neon-model-capabilities.d.ts
2
+ type NeonModelFamily = "anthropic" | "google" | "openai" | "meta" | "other";
3
+ /**
4
+ * Which gateway endpoint a model should be routed to.
5
+ *
6
+ * - `anthropic`: native Messages API — streaming structured output + native reasoning.
7
+ * - `openai`: native Responses API — models served only natively (e.g. Codex),
8
+ * native reasoning, and the image-generation tool.
9
+ * - `mlflow`: the unified, OpenAI-compatible endpoint (the fallback). Gemini is
10
+ * routed here because the gateway's native Gemini endpoint does not support
11
+ * streaming (`streamGenerateContent` is rejected).
12
+ */
13
+ type NeonModelRoute = "anthropic" | "openai" | "mlflow";
14
+ declare function getNeonModelRoute(modelId: string): NeonModelRoute;
15
+ interface NeonModelCapabilities {
16
+ family: NeonModelFamily;
17
+ supportsTemperature: boolean;
18
+ supportsTopP: boolean;
19
+ /**
20
+ * Whether `temperature` and `topP` may be sent together. Anthropic models
21
+ * accept only one of the two.
22
+ */
23
+ temperatureTopPMutuallyExclusive: boolean;
24
+ supportsPenalties: boolean;
25
+ supportsSeed: boolean;
26
+ supportsStopSequences: boolean;
27
+ supportsReasoningEffort: boolean;
28
+ }
29
+ /**
30
+ * Heuristic, prefix-based capability detection for MLflow-routed Neon models.
31
+ *
32
+ * The unified endpoint proxies to heterogeneous upstream providers, each of
33
+ * which accepts a different subset of the OpenAI-style parameters the AI SDK
34
+ * emits. Sending a parameter an upstream rejects results in a hard `400`, so we
35
+ * strip the parameters a family is known to reject and surface a warning
36
+ * instead. Unknown/untested models stay permissive (passed through unchanged).
37
+ */
38
+ declare function getNeonModelCapabilities(modelId: string): NeonModelCapabilities;
39
+ //#endregion
40
+ export { NeonModelCapabilities, NeonModelFamily, NeonModelRoute, getNeonModelCapabilities, getNeonModelRoute };
41
+ //# sourceMappingURL=neon-model-capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-model-capabilities.d.ts","names":[],"sources":["../../src/lib/neon-model-capabilities.ts"],"mappings":";KAAY,eAAA;AAAZ;AAiBA;AAEA;AAiBA;AAkCA;;;;;;KArDY,cAAA;iBAEI,iBAAA,mBAAoC;UAiBnC,qBAAA;UACR;;;;;;;;;;;;;;;;;;;;;;iBAiCO,wBAAA,mBAEb"}
@@ -0,0 +1,74 @@
1
+ //#region src/lib/neon-model-capabilities.ts
2
+ function getNeonModelRoute(modelId) {
3
+ const id = modelId.toLowerCase();
4
+ if (id.includes("claude")) return "anthropic";
5
+ if (id.includes("gpt-") && !id.includes("gpt-oss") || id.includes("codex")) return "openai";
6
+ return "mlflow";
7
+ }
8
+ const PERMISSIVE = {
9
+ supportsTemperature: true,
10
+ supportsTopP: true,
11
+ temperatureTopPMutuallyExclusive: false,
12
+ supportsPenalties: true,
13
+ supportsSeed: true,
14
+ supportsStopSequences: true,
15
+ supportsReasoningEffort: true
16
+ };
17
+ /**
18
+ * Heuristic, prefix-based capability detection for MLflow-routed Neon models.
19
+ *
20
+ * The unified endpoint proxies to heterogeneous upstream providers, each of
21
+ * which accepts a different subset of the OpenAI-style parameters the AI SDK
22
+ * emits. Sending a parameter an upstream rejects results in a hard `400`, so we
23
+ * strip the parameters a family is known to reject and surface a warning
24
+ * instead. Unknown/untested models stay permissive (passed through unchanged).
25
+ */
26
+ function getNeonModelCapabilities(modelId) {
27
+ const id = modelId.toLowerCase();
28
+ if (id.includes("claude")) return {
29
+ family: "anthropic",
30
+ supportsTemperature: true,
31
+ supportsTopP: true,
32
+ temperatureTopPMutuallyExclusive: true,
33
+ supportsPenalties: false,
34
+ supportsSeed: false,
35
+ supportsStopSequences: true,
36
+ supportsReasoningEffort: false
37
+ };
38
+ if (id.includes("gemini")) return {
39
+ family: "google",
40
+ ...PERMISSIVE,
41
+ supportsReasoningEffort: false
42
+ };
43
+ if (/gpt-5/.test(id)) {
44
+ const hasMinorVersion = /gpt-5[.-]\d/.test(id);
45
+ return {
46
+ family: "openai",
47
+ supportsTemperature: hasMinorVersion,
48
+ supportsTopP: hasMinorVersion,
49
+ temperatureTopPMutuallyExclusive: false,
50
+ supportsPenalties: true,
51
+ supportsSeed: true,
52
+ supportsStopSequences: true,
53
+ supportsReasoningEffort: true
54
+ };
55
+ }
56
+ if (id.includes("llama")) return {
57
+ family: "meta",
58
+ supportsTemperature: true,
59
+ supportsTopP: true,
60
+ temperatureTopPMutuallyExclusive: false,
61
+ supportsPenalties: false,
62
+ supportsSeed: false,
63
+ supportsStopSequences: true,
64
+ supportsReasoningEffort: true
65
+ };
66
+ return {
67
+ family: "other",
68
+ ...PERMISSIVE
69
+ };
70
+ }
71
+ //#endregion
72
+ export { getNeonModelCapabilities, getNeonModelRoute };
73
+
74
+ //# sourceMappingURL=neon-model-capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-model-capabilities.js","names":[],"sources":["../../src/lib/neon-model-capabilities.ts"],"sourcesContent":["export type NeonModelFamily =\n\t| \"anthropic\"\n\t| \"google\"\n\t| \"openai\"\n\t| \"meta\"\n\t| \"other\";\n\n/**\n * Which gateway endpoint a model should be routed to.\n *\n * - `anthropic`: native Messages API — streaming structured output + native reasoning.\n * - `openai`: native Responses API — models served only natively (e.g. Codex),\n * native reasoning, and the image-generation tool.\n * - `mlflow`: the unified, OpenAI-compatible endpoint (the fallback). Gemini is\n * routed here because the gateway's native Gemini endpoint does not support\n * streaming (`streamGenerateContent` is rejected).\n */\nexport type NeonModelRoute = \"anthropic\" | \"openai\" | \"mlflow\";\n\nexport function getNeonModelRoute(modelId: string): NeonModelRoute {\n\tconst id = modelId.toLowerCase();\n\tif (id.includes(\"claude\")) {\n\t\treturn \"anthropic\";\n\t}\n\t// OpenAI proprietary models (gpt-4/gpt-5 families, Codex) are served only via\n\t// the native Responses API. `gpt-oss` is open-weight and served on the\n\t// unified chat endpoint, so it is intentionally excluded here.\n\tif (\n\t\t(id.includes(\"gpt-\") && !id.includes(\"gpt-oss\")) ||\n\t\tid.includes(\"codex\")\n\t) {\n\t\treturn \"openai\";\n\t}\n\treturn \"mlflow\";\n}\n\nexport interface NeonModelCapabilities {\n\tfamily: NeonModelFamily;\n\tsupportsTemperature: boolean;\n\tsupportsTopP: boolean;\n\t/**\n\t * Whether `temperature` and `topP` may be sent together. Anthropic models\n\t * accept only one of the two.\n\t */\n\ttemperatureTopPMutuallyExclusive: boolean;\n\tsupportsPenalties: boolean;\n\tsupportsSeed: boolean;\n\tsupportsStopSequences: boolean;\n\tsupportsReasoningEffort: boolean;\n}\n\nconst PERMISSIVE: Omit<NeonModelCapabilities, \"family\"> = {\n\tsupportsTemperature: true,\n\tsupportsTopP: true,\n\ttemperatureTopPMutuallyExclusive: false,\n\tsupportsPenalties: true,\n\tsupportsSeed: true,\n\tsupportsStopSequences: true,\n\tsupportsReasoningEffort: true,\n};\n\n/**\n * Heuristic, prefix-based capability detection for MLflow-routed Neon models.\n *\n * The unified endpoint proxies to heterogeneous upstream providers, each of\n * which accepts a different subset of the OpenAI-style parameters the AI SDK\n * emits. Sending a parameter an upstream rejects results in a hard `400`, so we\n * strip the parameters a family is known to reject and surface a warning\n * instead. Unknown/untested models stay permissive (passed through unchanged).\n */\nexport function getNeonModelCapabilities(\n\tmodelId: string,\n): NeonModelCapabilities {\n\tconst id = modelId.toLowerCase();\n\n\t// Anthropic (Claude): rejects penalties and seed, accepts only one of\n\t// temperature/topP, and rejects the OpenAI `reasoning_effort` field.\n\tif (id.includes(\"claude\")) {\n\t\treturn {\n\t\t\tfamily: \"anthropic\",\n\t\t\tsupportsTemperature: true,\n\t\t\tsupportsTopP: true,\n\t\t\ttemperatureTopPMutuallyExclusive: true,\n\t\t\tsupportsPenalties: false,\n\t\t\tsupportsSeed: false,\n\t\t\tsupportsStopSequences: true,\n\t\t\tsupportsReasoningEffort: false,\n\t\t};\n\t}\n\n\t// Google (Gemini): accepts standard sampling params but rejects the OpenAI\n\t// `reasoning_effort` field (not part of Gemini's generation config).\n\tif (id.includes(\"gemini\")) {\n\t\treturn {\n\t\t\tfamily: \"google\",\n\t\t\t...PERMISSIVE,\n\t\t\tsupportsReasoningEffort: false,\n\t\t};\n\t}\n\n\t// OpenAI GPT-5 reasoning family (routed to the native Responses API). The\n\t// Responses model strips parameters the Responses API doesn't accept\n\t// (penalties, seed, stop), but its reasoning-model detection matches the bare\n\t// model id (`gpt-5`), which the gateway's `databricks-` prefix defeats. So we\n\t// only handle the temperature/topP restriction here: the original gpt-5 /\n\t// gpt-5-mini / gpt-5-nano require the default temperature and reject topP,\n\t// while gpt-5.1+ (a minor version digit follows) accept them again.\n\tif (/gpt-5/.test(id)) {\n\t\tconst hasMinorVersion = /gpt-5[.-]\\d/.test(id);\n\t\treturn {\n\t\t\tfamily: \"openai\",\n\t\t\tsupportsTemperature: hasMinorVersion,\n\t\t\tsupportsTopP: hasMinorVersion,\n\t\t\ttemperatureTopPMutuallyExclusive: false,\n\t\t\tsupportsPenalties: true,\n\t\t\tsupportsSeed: true,\n\t\t\tsupportsStopSequences: true,\n\t\t\tsupportsReasoningEffort: true,\n\t\t};\n\t}\n\n\t// Meta (Llama): rejects penalties and seed; accepts sampling params and stop.\n\tif (id.includes(\"llama\")) {\n\t\treturn {\n\t\t\tfamily: \"meta\",\n\t\t\tsupportsTemperature: true,\n\t\t\tsupportsTopP: true,\n\t\t\ttemperatureTopPMutuallyExclusive: false,\n\t\t\tsupportsPenalties: false,\n\t\t\tsupportsSeed: false,\n\t\t\tsupportsStopSequences: true,\n\t\t\tsupportsReasoningEffort: true,\n\t\t};\n\t}\n\n\treturn { family: \"other\", ...PERMISSIVE };\n}\n"],"mappings":";AAmBA,SAAgB,kBAAkB,SAAiC;CAClE,MAAM,KAAK,QAAQ,YAAY;CAC/B,IAAI,GAAG,SAAS,QAAQ,GACvB,OAAO;CAKR,IACE,GAAG,SAAS,MAAM,KAAK,CAAC,GAAG,SAAS,SAAS,KAC9C,GAAG,SAAS,OAAO,GAEnB,OAAO;CAER,OAAO;AACR;AAiBA,MAAM,aAAoD;CACzD,qBAAqB;CACrB,cAAc;CACd,kCAAkC;CAClC,mBAAmB;CACnB,cAAc;CACd,uBAAuB;CACvB,yBAAyB;AAC1B;;;;;;;;;;AAWA,SAAgB,yBACf,SACwB;CACxB,MAAM,KAAK,QAAQ,YAAY;CAI/B,IAAI,GAAG,SAAS,QAAQ,GACvB,OAAO;EACN,QAAQ;EACR,qBAAqB;EACrB,cAAc;EACd,kCAAkC;EAClC,mBAAmB;EACnB,cAAc;EACd,uBAAuB;EACvB,yBAAyB;CAC1B;CAKD,IAAI,GAAG,SAAS,QAAQ,GACvB,OAAO;EACN,QAAQ;EACR,GAAG;EACH,yBAAyB;CAC1B;CAUD,IAAI,QAAQ,KAAK,EAAE,GAAG;EACrB,MAAM,kBAAkB,cAAc,KAAK,EAAE;EAC7C,OAAO;GACN,QAAQ;GACR,qBAAqB;GACrB,cAAc;GACd,kCAAkC;GAClC,mBAAmB;GACnB,cAAc;GACd,uBAAuB;GACvB,yBAAyB;EAC1B;CACD;CAGA,IAAI,GAAG,SAAS,OAAO,GACtB,OAAO;EACN,QAAQ;EACR,qBAAqB;EACrB,cAAc;EACd,kCAAkC;EAClC,mBAAmB;EACnB,cAAc;EACd,uBAAuB;EACvB,yBAAyB;CAC1B;CAGD,OAAO;EAAE,QAAQ;EAAS,GAAG;CAAW;AACzC"}