@neon/ai-sdk-provider 0.0.0 → 0.5.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.
Files changed (39) hide show
  1. package/LICENSE.md +178 -0
  2. package/README.md +101 -0
  3. package/dist/index.d.ts +7 -0
  4. package/dist/index.js +7 -0
  5. package/dist/lib/neon-anthropic-language-model.d.ts +23 -0
  6. package/dist/lib/neon-anthropic-language-model.d.ts.map +1 -0
  7. package/dist/lib/neon-anthropic-language-model.js +38 -0
  8. package/dist/lib/neon-anthropic-language-model.js.map +1 -0
  9. package/dist/lib/neon-capabilities.d.ts +20 -0
  10. package/dist/lib/neon-capabilities.d.ts.map +1 -0
  11. package/dist/lib/neon-capabilities.js +97 -0
  12. package/dist/lib/neon-capabilities.js.map +1 -0
  13. package/dist/lib/neon-chat-language-model.d.ts +21 -0
  14. package/dist/lib/neon-chat-language-model.d.ts.map +1 -0
  15. package/dist/lib/neon-chat-language-model.js +34 -0
  16. package/dist/lib/neon-chat-language-model.js.map +1 -0
  17. package/dist/lib/neon-chat-options.d.ts +21 -0
  18. package/dist/lib/neon-chat-options.d.ts.map +1 -0
  19. package/dist/lib/neon-chat-options.js +52 -0
  20. package/dist/lib/neon-chat-options.js.map +1 -0
  21. package/dist/lib/neon-model-capabilities.d.ts +41 -0
  22. package/dist/lib/neon-model-capabilities.d.ts.map +1 -0
  23. package/dist/lib/neon-model-capabilities.js +74 -0
  24. package/dist/lib/neon-model-capabilities.js.map +1 -0
  25. package/dist/lib/neon-responses-language-model.d.ts +27 -0
  26. package/dist/lib/neon-responses-language-model.d.ts.map +1 -0
  27. package/dist/lib/neon-responses-language-model.js +45 -0
  28. package/dist/lib/neon-responses-language-model.js.map +1 -0
  29. package/dist/lib/provider.d.ts +52 -0
  30. package/dist/lib/provider.d.ts.map +1 -0
  31. package/dist/lib/provider.js +126 -0
  32. package/dist/lib/provider.js.map +1 -0
  33. package/dist/lib/version.d.ts +5 -0
  34. package/dist/lib/version.d.ts.map +1 -0
  35. package/dist/lib/version.js +7 -0
  36. package/dist/lib/version.js.map +1 -0
  37. package/dist/package.js +6 -0
  38. package/dist/package.js.map +1 -0
  39. package/package.json +62 -18
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
package/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # @neon/ai-sdk-provider
2
+
3
+ Community [Vercel AI SDK](https://ai-sdk.dev) provider for the [Neon](https://neon.com) AI Gateway. Requires **AI SDK v6** (`ai@^6`).
4
+
5
+ The Neon AI Gateway is **branch-scoped**: each Neon project branch gets its own gateway host, and a platform token authorizes requests for that branch. This provider routes each model to the best gateway endpoint (Anthropic → native Messages, OpenAI → native Responses incl. **Codex**, everything else → unified OpenAI-compatible MLflow endpoint), so a single `neon('claude-...')` call reaches the whole catalog.
6
+
7
+ Model ids use the canonical Neon (unprefixed) form — `claude-sonnet-4-6`, `gpt-5`, `gemini-2-5-flash` — matching the [`neon` provider on models.dev](https://models.dev). The typed catalog mirrors that provider exactly (kept in sync by a scheduled drift check), plus a few extra gateway-served ids that models.dev doesn't list yet (e.g. Codex, Llama, Qwen). Any other id — including the legacy `databricks-` prefixed form (`databricks-claude-sonnet-4-6`) — is still accepted as a plain string, so existing code keeps working.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @neon/ai-sdk-provider ai@^6
13
+ ```
14
+
15
+ ## Configuration
16
+
17
+ The gateway URL is branch-scoped, so both values come from the Neon Console (your project → a branch → **AI Gateway** tab), or from `neonctl env pull` / `neon dev`:
18
+
19
+ ```bash
20
+ NEON_AI_GATEWAY_BASE_URL="https://<branch-id>-api.ai.<region>.aws.neon.tech"
21
+ NEON_AI_GATEWAY_TOKEN="nt_live_..."
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ```ts
27
+ import { neon } from "@neon/ai-sdk-provider";
28
+ import { generateText } from "ai";
29
+
30
+ // Reads NEON_AI_GATEWAY_BASE_URL + NEON_AI_GATEWAY_TOKEN from the environment.
31
+ const { text } = await generateText({
32
+ model: neon("claude-haiku-4-5"), // or 'gpt-5-3-codex', etc.
33
+ prompt: "Summarize Postgres for me.",
34
+ });
35
+ ```
36
+
37
+ Or configure explicitly with `createNeon`:
38
+
39
+ ```ts
40
+ import { createNeon } from "@neon/ai-sdk-provider";
41
+
42
+ const neon = createNeon({
43
+ baseURL: process.env.NEON_AI_GATEWAY_BASE_URL,
44
+ apiKey: process.env.NEON_AI_GATEWAY_TOKEN,
45
+ });
46
+ ```
47
+
48
+ ## Routing
49
+
50
+ | Model family | Endpoint | Why |
51
+ | --- | --- | --- |
52
+ | Anthropic (`claude-*`) | native Messages API | streaming structured output + native reasoning |
53
+ | OpenAI (`gpt-*`, `*-codex`) | native Responses API | Codex (native-only), native reasoning, image-gen tool |
54
+ | Everything else (Gemini, Llama, Qwen, gpt-oss, ...) | unified MLflow endpoint | broad coverage; Gemini is here because its native endpoint does not support streaming |
55
+
56
+ Routing matches on the model id, so both the canonical (`gpt-5`) and the legacy `databricks-`-prefixed (`databricks-gpt-5`) forms route identically.
57
+
58
+ ## Capabilities
59
+
60
+ Verified across Anthropic, OpenAI (incl. Codex), Google, and Meta models: `generateText` / `streamText` (text, system prompts, multi-turn), tool calling (single and multi-step, generate and stream), `generateObject` / `streamObject`, and image (vision) input.
61
+
62
+ For MLflow-routed models, the provider detects the model family and drops parameters a backend rejects (e.g. penalties/`seed` for Llama, `reasoningEffort` for Gemini) with an AI SDK warning (`result.warnings`) instead of failing the request.
63
+
64
+ ## Image generation
65
+
66
+ Available on OpenAI models via the Responses `image_generation` tool (there is no `generateImage()` image-model endpoint). Use `streamText` — streaming returns the image as a `tool-result` part and avoids the gateway's non-streaming response-size cap and read timeout:
67
+
68
+ ```ts
69
+ import { streamText } from "ai";
70
+ import { neon } from "@neon/ai-sdk-provider";
71
+
72
+ const result = streamText({
73
+ model: neon("gpt-5-mini"),
74
+ prompt: "Generate an image of a red apple on a wooden table",
75
+ tools: { image: neon.tools.imageGeneration({ partialImages: 3 }) },
76
+ });
77
+
78
+ for await (const part of result.fullStream) {
79
+ if (part.type === "tool-result" && "result" in part.output) {
80
+ const png = Buffer.from(part.output.result as string, "base64");
81
+ // save or use the image
82
+ }
83
+ }
84
+ ```
85
+
86
+ ## Limitations
87
+
88
+ - `generateImage()` and embeddings (`embed` / `embedMany`) are not offered by the gateway and throw `NoSuchModelError`.
89
+ - `gpt-oss-*` models return a non-standard ("harmony") response shape on the unified endpoint and are not fully supported.
90
+ - OpenAI Responses multi-turn tool flows (`generateText` + `stepCountIs`) can return 502 from the gateway; tool calling is covered on Anthropic/Google/Meta in e2e.
91
+
92
+ ## End-to-end tests
93
+
94
+ Against a live branch with AI Gateway enabled:
95
+
96
+ ```bash
97
+ cp .env.example .env # fill NEON_AI_GATEWAY_BASE_URL + NEON_AI_GATEWAY_TOKEN from `neonctl env pull`
98
+ pnpm test:e2e
99
+ ```
100
+
101
+ The matrix covers one models.dev `neon` model per family (Anthropic, OpenAI, Codex, Gemini, Meta) across `generateText`, `streamText`, `generateObject`, tool calling, and `neon.tools.imageGeneration`. Skipped when gateway env vars are absent.
@@ -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 { NEON_EXTRA_MODEL_IDS, NEON_MODELS_DEV_IDS, NeonChatModelId, NeonKnownModelId } 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 { NEON_EXTRA_MODEL_IDS, NEON_MODELS_DEV_IDS, NeonAnthropicLanguageModel, NeonChatLanguageModel, type NeonChatModelId, type NeonErrorData, type NeonKnownModelId, type NeonModelCapabilities, type NeonModelFamily, type NeonModelRoute, type NeonProvider, type 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 { NEON_EXTRA_MODEL_IDS, NEON_MODELS_DEV_IDS } from "./lib/neon-chat-options.js";
5
+ import { NeonResponsesLanguageModel } from "./lib/neon-responses-language-model.js";
6
+ import { createNeon, neon } from "./lib/provider.js";
7
+ export { NEON_EXTRA_MODEL_IDS, NEON_MODELS_DEV_IDS, NeonAnthropicLanguageModel, NeonChatLanguageModel, NeonResponsesLanguageModel, createNeon, getNeonModelCapabilities, getNeonModelRoute, neon };
@@ -0,0 +1,23 @@
1
+ import { AnthropicMessagesLanguageModel } from "@ai-sdk/anthropic/internal";
2
+ import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } 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 AnthropicMessagesLanguageModel implements LanguageModelV3 {
17
+ private withGatewayCompat;
18
+ doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
19
+ doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
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,8BAAA,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 { AnthropicMessagesLanguageModel } 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 AnthropicMessagesLanguageModel {
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 { AnthropicMessagesLanguageModel } from \"@ai-sdk/anthropic/internal\";\nimport type {\n\tLanguageModelV3,\n\tLanguageModelV3CallOptions,\n\tLanguageModelV3GenerateResult,\n\tLanguageModelV3StreamResult,\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 AnthropicMessagesLanguageModel\n\timplements LanguageModelV3\n{\n\tprivate withGatewayCompat(\n\t\toptions: LanguageModelV3CallOptions,\n\t): LanguageModelV3CallOptions {\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: LanguageModelV3CallOptions,\n\t): Promise<LanguageModelV3GenerateResult> {\n\t\treturn super.doGenerate(this.withGatewayCompat(options));\n\t}\n\n\toverride doStream(\n\t\toptions: LanguageModelV3CallOptions,\n\t): Promise<LanguageModelV3StreamResult> {\n\t\treturn super.doStream(this.withGatewayCompat(options));\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,IAAa,6BAAb,cACS,+BAET;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 { LanguageModelV3CallOptions, LanguageModelV3StreamPart, SharedV3Warning } 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: LanguageModelV3CallOptions): {
11
+ options: LanguageModelV3CallOptions;
12
+ warnings: SharedV3Warning[];
13
+ };
14
+ /**
15
+ * Merge additional warnings into the `stream-start` part of a model stream.
16
+ */
17
+ declare function mergeStreamStartWarnings(extra: SharedV3Warning[]): TransformStream<LanguageModelV3StreamPart, LanguageModelV3StreamPart>;
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":";;;;;;AAaA;;;AAGc,iBAHE,qBAAA,CAGF,OAAA,EAAA,MAAA,EAAA,OAAA,EADJ,0BACI,CAAA,EAAA;SAAsC,EAAtC,0BAAsC;EAAe,QAAA,EAAf,eAAe,EAAA;AA4FnE,CAAA;;;;AAAiE,iBAAjD,wBAAA,CAAiD,KAAA,EAAjB,eAAiB,EAAA,CAAA,EAAA,eAAA,CAAA,yBAAA,EAAA,yBAAA,CAAA"}
@@ -0,0 +1,97 @@
1
+ import { getNeonModelCapabilities } from "./neon-model-capabilities.js";
2
+ //#region src/lib/neon-capabilities.ts
3
+ /**
4
+ * Drop call options the resolved model's upstream backend does not accept and
5
+ * collect a warning for each, so callers get a clear signal instead of a hard
6
+ * `400` from the gateway.
7
+ */
8
+ function applyNeonCapabilities(modelId, options) {
9
+ const caps = getNeonModelCapabilities(modelId);
10
+ const warnings = [];
11
+ const patch = {};
12
+ const dropUnsupported = (feature) => {
13
+ warnings.push({
14
+ type: "unsupported",
15
+ feature,
16
+ details: `${feature} is not supported by the Neon AI Gateway for ${caps.family} model "${modelId}" and was dropped.`
17
+ });
18
+ };
19
+ if (options.temperature != null && !caps.supportsTemperature) {
20
+ patch.temperature = void 0;
21
+ dropUnsupported("temperature");
22
+ }
23
+ if (options.topP != null && !caps.supportsTopP) {
24
+ patch.topP = void 0;
25
+ dropUnsupported("topP");
26
+ }
27
+ const effectiveTemperature = "temperature" in patch ? patch.temperature : options.temperature;
28
+ const effectiveTopP = "topP" in patch ? patch.topP : options.topP;
29
+ if (caps.temperatureTopPMutuallyExclusive && effectiveTemperature != null && effectiveTopP != null) {
30
+ patch.topP = void 0;
31
+ warnings.push({
32
+ type: "compatibility",
33
+ feature: "topP",
34
+ details: `${caps.family} models accept only one of temperature or topP; topP was dropped.`
35
+ });
36
+ }
37
+ if (options.frequencyPenalty != null && !caps.supportsPenalties) {
38
+ patch.frequencyPenalty = void 0;
39
+ dropUnsupported("frequencyPenalty");
40
+ }
41
+ if (options.presencePenalty != null && !caps.supportsPenalties) {
42
+ patch.presencePenalty = void 0;
43
+ dropUnsupported("presencePenalty");
44
+ }
45
+ if (options.seed != null && !caps.supportsSeed) {
46
+ patch.seed = void 0;
47
+ dropUnsupported("seed");
48
+ }
49
+ if (options.stopSequences != null && !caps.supportsStopSequences) {
50
+ patch.stopSequences = void 0;
51
+ dropUnsupported("stopSequences");
52
+ }
53
+ if (!caps.supportsReasoningEffort) {
54
+ const { providerOptions } = options;
55
+ if (providerOptions != null && Object.values(providerOptions).some((group) => "reasoningEffort" in group && group.reasoningEffort != null)) {
56
+ dropUnsupported("reasoningEffort");
57
+ if (providerOptions != null) {
58
+ const cleaned = {};
59
+ for (const [key, group] of Object.entries(providerOptions)) if ("reasoningEffort" in group) {
60
+ const { reasoningEffort: _removed, ...rest } = group;
61
+ cleaned[key] = rest;
62
+ } else cleaned[key] = group;
63
+ patch.providerOptions = cleaned;
64
+ }
65
+ }
66
+ }
67
+ if (Object.keys(patch).length === 0) return {
68
+ options,
69
+ warnings
70
+ };
71
+ return {
72
+ options: {
73
+ ...options,
74
+ ...patch
75
+ },
76
+ warnings
77
+ };
78
+ }
79
+ /**
80
+ * Merge additional warnings into the `stream-start` part of a model stream.
81
+ */
82
+ function mergeStreamStartWarnings(extra) {
83
+ let merged = false;
84
+ return new TransformStream({ transform(part, controller) {
85
+ if (!merged && part.type === "stream-start") {
86
+ merged = true;
87
+ controller.enqueue({
88
+ ...part,
89
+ warnings: [...extra, ...part.warnings]
90
+ });
91
+ } else controller.enqueue(part);
92
+ } });
93
+ }
94
+ //#endregion
95
+ export { applyNeonCapabilities, mergeStreamStartWarnings };
96
+
97
+ //# 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\tLanguageModelV3CallOptions,\n\tLanguageModelV3StreamPart,\n\tSharedV3ProviderOptions,\n\tSharedV3Warning,\n} from \"@ai-sdk/provider\";\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: LanguageModelV3CallOptions,\n): { options: LanguageModelV3CallOptions; warnings: SharedV3Warning[] } {\n\tconst caps = getNeonModelCapabilities(modelId);\n\tconst warnings: SharedV3Warning[] = [];\n\tconst patch: Partial<LanguageModelV3CallOptions> = {};\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\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\n\t\tif (hasProviderEffort) {\n\t\t\tdropUnsupported(\"reasoningEffort\");\n\t\t\tif (providerOptions != null) {\n\t\t\t\tconst cleaned: SharedV3ProviderOptions = {};\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}\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: SharedV3Warning[]) {\n\tlet merged = false;\n\treturn new TransformStream<\n\t\tLanguageModelV3StreamPart,\n\t\tLanguageModelV3StreamPart\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":";;;;;;;AAaA,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;CAEA,IAAI,QAAQ,iBAAiB,QAAQ,CAAC,KAAK,uBAAuB;EACjE,MAAM,gBAAgB,KAAA;EACtB,gBAAgB,eAAe;CAChC;CAEA,IAAI,CAAC,KAAK,yBAAyB;EAClC,MAAM,EAAE,oBAAoB;EAQ5B,IANC,mBAAmB,QACnB,OAAO,OAAO,eAAe,CAAC,CAAC,MAC7B,UACA,qBAAqB,SAAS,MAAM,mBAAmB,IACzD,GAEsB;GACtB,gBAAgB,iBAAiB;GACjC,IAAI,mBAAmB,MAAM;IAC5B,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;EACD;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 { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } 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 LanguageModelV3 {
16
+ doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
17
+ doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
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\tLanguageModelV3,\n\tLanguageModelV3CallOptions,\n\tLanguageModelV3GenerateResult,\n\tLanguageModelV3StreamResult,\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 LanguageModelV3\n{\n\toverride async doGenerate(\n\t\toptions: LanguageModelV3CallOptions,\n\t): Promise<LanguageModelV3GenerateResult> {\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: LanguageModelV3CallOptions,\n\t): Promise<LanguageModelV3StreamResult> {\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,21 @@
1
+ //#region src/lib/neon-chat-options.d.ts
2
+ /** The models.dev `neon` catalog (canonical, unprefixed ids). */
3
+ declare const NEON_MODELS_DEV_IDS: readonly ["claude-opus-4-7", "claude-opus-4-6", "claude-opus-4-5", "claude-opus-4-1", "claude-sonnet-4-6", "claude-sonnet-4-5", "claude-sonnet-4", "claude-haiku-4-5", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5-1", "gpt-5-2", "gpt-5-4", "gpt-5-4-mini", "gpt-5-4-nano", "gpt-5-5", "gpt-oss-120b", "gpt-oss-20b", "gemini-3-pro", "gemini-3-flash", "gemini-3-1-pro", "gemini-3-1-flash-lite", "gemini-2-5-pro", "gemini-2-5-flash"];
4
+ /**
5
+ * Ids the gateway serves that the models.dev `neon` provider does not list.
6
+ * Verified to resolve against the gateway; retained for autocomplete. If
7
+ * models.dev later lists one of these, the drift check flags it for promotion
8
+ * into `NEON_MODELS_DEV_IDS`.
9
+ */
10
+ declare const NEON_EXTRA_MODEL_IDS: readonly ["claude-opus-4-8", "gpt-5-2-codex", "gpt-5-3-codex", "gpt-5-5-pro", "gemini-3-5-flash", "gemma-3-12b", "llama-4-maverick", "meta-llama-3-3-70b-instruct", "meta-llama-3-1-8b-instruct", "qwen3-next-80b-a3b-instruct", "qwen35-122b-a10b"];
11
+ /** A known Neon AI Gateway model id (models.dev catalog + gateway extras). */
12
+ type NeonKnownModelId = (typeof NEON_MODELS_DEV_IDS)[number] | (typeof NEON_EXTRA_MODEL_IDS)[number];
13
+ /**
14
+ * A Neon AI Gateway model id. Known ids are listed for autocomplete; any other
15
+ * id (e.g. a brand-new model, or the legacy `databricks-` prefixed form) is
16
+ * accepted via the `(string & {})` fallback.
17
+ */
18
+ type NeonChatModelId = NeonKnownModelId | (string & {});
19
+ //#endregion
20
+ export { NEON_EXTRA_MODEL_IDS, NEON_MODELS_DEV_IDS, NeonChatModelId, NeonKnownModelId };
21
+ //# 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":";;AAiBa,cAAA,mBA8BH,EAAA,SAAA,CAAA,iBAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,mBAAA,EAAA,mBAAA,EAAA,iBAAA,EAAA,kBAAA,EAAA,OAAA,EAAA,YAAA,EAAA,YAAA,EAAA,SAAA,EAAA,SAAA,EAAA,SAAA,EAAA,cAAA,EAAA,cAAA,EAAA,SAAA,EAAA,cAAA,EAAA,aAAA,EAAA,cAAA,EAAA,gBAAA,EAAA,gBAAA,EAAA,uBAAA,EAAA,gBAAA,EAAA,kBAAA,CAAA;AAQV;AAoBA;;;;AAE+B;AAOnB,cA7BC,oBA6BiB,EAAA,SAAgB,CAAA,iBAAA,EAAA,eAAA,EAAA,eAAA,EAAA,aAAA,EAAA,kBAAA,EAAA,aAAA,EAAA,kBAAA,EAAA,6BAAA,EAAA,4BAAA,EAAA,6BAAA,EAAA,kBAAA,CAAA;;KATlC,gBAAA,WACD,uCACA;;;;;;KAOC,eAAA,GAAkB"}
@@ -0,0 +1,52 @@
1
+ //#region src/lib/neon-chat-options.ts
2
+ /** The models.dev `neon` catalog (canonical, unprefixed ids). */
3
+ const NEON_MODELS_DEV_IDS = [
4
+ "claude-opus-4-7",
5
+ "claude-opus-4-6",
6
+ "claude-opus-4-5",
7
+ "claude-opus-4-1",
8
+ "claude-sonnet-4-6",
9
+ "claude-sonnet-4-5",
10
+ "claude-sonnet-4",
11
+ "claude-haiku-4-5",
12
+ "gpt-5",
13
+ "gpt-5-mini",
14
+ "gpt-5-nano",
15
+ "gpt-5-1",
16
+ "gpt-5-2",
17
+ "gpt-5-4",
18
+ "gpt-5-4-mini",
19
+ "gpt-5-4-nano",
20
+ "gpt-5-5",
21
+ "gpt-oss-120b",
22
+ "gpt-oss-20b",
23
+ "gemini-3-pro",
24
+ "gemini-3-flash",
25
+ "gemini-3-1-pro",
26
+ "gemini-3-1-flash-lite",
27
+ "gemini-2-5-pro",
28
+ "gemini-2-5-flash"
29
+ ];
30
+ /**
31
+ * Ids the gateway serves that the models.dev `neon` provider does not list.
32
+ * Verified to resolve against the gateway; retained for autocomplete. If
33
+ * models.dev later lists one of these, the drift check flags it for promotion
34
+ * into `NEON_MODELS_DEV_IDS`.
35
+ */
36
+ const NEON_EXTRA_MODEL_IDS = [
37
+ "claude-opus-4-8",
38
+ "gpt-5-2-codex",
39
+ "gpt-5-3-codex",
40
+ "gpt-5-5-pro",
41
+ "gemini-3-5-flash",
42
+ "gemma-3-12b",
43
+ "llama-4-maverick",
44
+ "meta-llama-3-3-70b-instruct",
45
+ "meta-llama-3-1-8b-instruct",
46
+ "qwen3-next-80b-a3b-instruct",
47
+ "qwen35-122b-a10b"
48
+ ];
49
+ //#endregion
50
+ export { NEON_EXTRA_MODEL_IDS, NEON_MODELS_DEV_IDS };
51
+
52
+ //# sourceMappingURL=neon-chat-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-chat-options.js","names":[],"sources":["../../src/lib/neon-chat-options.ts"],"sourcesContent":["// Models served by the Neon AI Gateway. Anthropic and OpenAI models are routed\n// to their provider-native endpoints; everything else uses the unified MLflow\n// (OpenAI-compatible) endpoint.\n//\n// Ids use the canonical Neon (unprefixed) form, matching the `neon` provider on\n// models.dev. The gateway also accepts the legacy `databricks-` prefixed form\n// (the `databricks` provider on models.dev), which still resolves via the\n// `(string & {})` fallback on `NeonChatModelId`.\n//\n// `NEON_MODELS_DEV_IDS` mirrors the models.dev `neon` catalog exactly — the\n// `neon-catalog-drift.test.ts` maintainer check fails if the two diverge.\n// `NEON_EXTRA_MODEL_IDS` are additional ids the gateway serves that models.dev\n// does not (yet) list; they are kept for autocomplete and verified to resolve\n// against the gateway. The authoritative, always-current catalog is shown in\n// the Neon Console under the branch's \"AI Gateway\" tab.\n\n/** The models.dev `neon` catalog (canonical, unprefixed ids). */\nexport const NEON_MODELS_DEV_IDS = [\n\t// Anthropic (native Messages API)\n\t\"claude-opus-4-7\",\n\t\"claude-opus-4-6\",\n\t\"claude-opus-4-5\",\n\t\"claude-opus-4-1\",\n\t\"claude-sonnet-4-6\",\n\t\"claude-sonnet-4-5\",\n\t\"claude-sonnet-4\",\n\t\"claude-haiku-4-5\",\n\t// OpenAI (native Responses API)\n\t\"gpt-5\",\n\t\"gpt-5-mini\",\n\t\"gpt-5-nano\",\n\t\"gpt-5-1\",\n\t\"gpt-5-2\",\n\t\"gpt-5-4\",\n\t\"gpt-5-4-mini\",\n\t\"gpt-5-4-nano\",\n\t\"gpt-5-5\",\n\t// OpenAI open-weight (unified MLflow endpoint)\n\t\"gpt-oss-120b\",\n\t\"gpt-oss-20b\",\n\t// Google (unified MLflow endpoint)\n\t\"gemini-3-pro\",\n\t\"gemini-3-flash\",\n\t\"gemini-3-1-pro\",\n\t\"gemini-3-1-flash-lite\",\n\t\"gemini-2-5-pro\",\n\t\"gemini-2-5-flash\",\n] as const;\n\n/**\n * Ids the gateway serves that the models.dev `neon` provider does not list.\n * Verified to resolve against the gateway; retained for autocomplete. If\n * models.dev later lists one of these, the drift check flags it for promotion\n * into `NEON_MODELS_DEV_IDS`.\n */\nexport const NEON_EXTRA_MODEL_IDS = [\n\t// Anthropic (native Messages API)\n\t\"claude-opus-4-8\",\n\t// OpenAI (native Responses API) — Codex is served only natively\n\t\"gpt-5-2-codex\",\n\t\"gpt-5-3-codex\",\n\t\"gpt-5-5-pro\",\n\t// Google (unified MLflow endpoint)\n\t\"gemini-3-5-flash\",\n\t\"gemma-3-12b\",\n\t// Meta (unified MLflow endpoint)\n\t\"llama-4-maverick\",\n\t\"meta-llama-3-3-70b-instruct\",\n\t\"meta-llama-3-1-8b-instruct\",\n\t// Alibaba (unified MLflow endpoint)\n\t\"qwen3-next-80b-a3b-instruct\",\n\t\"qwen35-122b-a10b\",\n] as const;\n\n/** A known Neon AI Gateway model id (models.dev catalog + gateway extras). */\nexport type NeonKnownModelId =\n\t| (typeof NEON_MODELS_DEV_IDS)[number]\n\t| (typeof NEON_EXTRA_MODEL_IDS)[number];\n\n/**\n * A Neon AI Gateway model id. Known ids are listed for autocomplete; any other\n * id (e.g. a brand-new model, or the legacy `databricks-` prefixed form) is\n * accepted via the `(string & {})` fallback.\n */\nexport type NeonChatModelId = NeonKnownModelId | (string & {});\n"],"mappings":";;AAiBA,MAAa,sBAAsB;CAElC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;AACD;;;;;;;AAQA,MAAa,uBAAuB;CAEnC;CAEA;CACA;CACA;CAEA;CACA;CAEA;CACA;CACA;CAEA;CACA;AACD"}
@@ -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 optional `databricks-` prefix can\n\t// defeat. So we only handle the temperature/topP restriction here: the\n\t// original gpt-5 / gpt-5-mini / gpt-5-nano require the default temperature and\n\t// reject topP, while gpt-5.1+ (a minor version digit follows) accept them\n\t// again. The regex matches both prefixed and unprefixed ids.\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;CAWD,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"}
@@ -0,0 +1,27 @@
1
+ import { OpenAIResponsesLanguageModel } from "@ai-sdk/openai/internal";
2
+ import { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3GenerateResult, LanguageModelV3StreamResult } from "@ai-sdk/provider";
3
+
4
+ //#region src/lib/neon-responses-language-model.d.ts
5
+
6
+ /**
7
+ * Language model for OpenAI models served via the Neon AI Gateway's native
8
+ * Responses API (`/ai-gateway/openai/v1/responses`). This route is required for
9
+ * models that are only served natively (e.g. Codex) and unlocks native
10
+ * reasoning and the image-generation tool.
11
+ *
12
+ * The shared OpenAI Responses model shapes a request based on whether the model
13
+ * is a reasoning model, but its detection is brittle here: the gateway also
14
+ * accepts the legacy `databricks-` prefix, which defeats the upstream bare-id
15
+ * (`gpt-5`) match. For the GPT-5 reasoning family we set the model's own
16
+ * `forceReasoning` provider option so it applies the correct reasoning behavior
17
+ * for both id forms. Users can still override it.
18
+ */
19
+ declare class NeonResponsesLanguageModel extends OpenAIResponsesLanguageModel implements LanguageModelV3 {
20
+ private get isReasoningFamily();
21
+ private withForcedReasoning;
22
+ doGenerate(options: LanguageModelV3CallOptions): Promise<LanguageModelV3GenerateResult>;
23
+ doStream(options: LanguageModelV3CallOptions): Promise<LanguageModelV3StreamResult>;
24
+ }
25
+ //#endregion
26
+ export { NeonResponsesLanguageModel };
27
+ //# sourceMappingURL=neon-responses-language-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-responses-language-model.d.ts","names":[],"sources":["../../src/lib/neon-responses-language-model.ts"],"mappings":";;;;;;;AAqBA;;;;;;;;;;AAE2B;cAFd,0BAAA,SACJ,4BAAA,YACG;;;sBA2BD,6BACP,QAAQ;oBAKD,6BACP,QAAQ"}
@@ -0,0 +1,45 @@
1
+ import { OpenAIResponsesLanguageModel } from "@ai-sdk/openai/internal";
2
+ //#region src/lib/neon-responses-language-model.ts
3
+ /**
4
+ * Language model for OpenAI models served via the Neon AI Gateway's native
5
+ * Responses API (`/ai-gateway/openai/v1/responses`). This route is required for
6
+ * models that are only served natively (e.g. Codex) and unlocks native
7
+ * reasoning and the image-generation tool.
8
+ *
9
+ * The shared OpenAI Responses model shapes a request based on whether the model
10
+ * is a reasoning model, but its detection is brittle here: the gateway also
11
+ * accepts the legacy `databricks-` prefix, which defeats the upstream bare-id
12
+ * (`gpt-5`) match. For the GPT-5 reasoning family we set the model's own
13
+ * `forceReasoning` provider option so it applies the correct reasoning behavior
14
+ * for both id forms. Users can still override it.
15
+ */
16
+ var NeonResponsesLanguageModel = class extends OpenAIResponsesLanguageModel {
17
+ get isReasoningFamily() {
18
+ return /gpt-5/.test(this.modelId.toLowerCase());
19
+ }
20
+ withForcedReasoning(options) {
21
+ if (!this.isReasoningFamily) return options;
22
+ const openai = options.providerOptions?.openai;
23
+ if (openai != null && "forceReasoning" in openai) return options;
24
+ return {
25
+ ...options,
26
+ providerOptions: {
27
+ ...options.providerOptions,
28
+ openai: {
29
+ ...openai,
30
+ forceReasoning: true
31
+ }
32
+ }
33
+ };
34
+ }
35
+ doGenerate(options) {
36
+ return super.doGenerate(this.withForcedReasoning(options));
37
+ }
38
+ doStream(options) {
39
+ return super.doStream(this.withForcedReasoning(options));
40
+ }
41
+ };
42
+ //#endregion
43
+ export { NeonResponsesLanguageModel };
44
+
45
+ //# sourceMappingURL=neon-responses-language-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"neon-responses-language-model.js","names":[],"sources":["../../src/lib/neon-responses-language-model.ts"],"sourcesContent":["import { OpenAIResponsesLanguageModel } from \"@ai-sdk/openai/internal\";\nimport type {\n\tLanguageModelV3,\n\tLanguageModelV3CallOptions,\n\tLanguageModelV3GenerateResult,\n\tLanguageModelV3StreamResult,\n} from \"@ai-sdk/provider\";\n\n/**\n * Language model for OpenAI models served via the Neon AI Gateway's native\n * Responses API (`/ai-gateway/openai/v1/responses`). This route is required for\n * models that are only served natively (e.g. Codex) and unlocks native\n * reasoning and the image-generation tool.\n *\n * The shared OpenAI Responses model shapes a request based on whether the model\n * is a reasoning model, but its detection is brittle here: the gateway also\n * accepts the legacy `databricks-` prefix, which defeats the upstream bare-id\n * (`gpt-5`) match. For the GPT-5 reasoning family we set the model's own\n * `forceReasoning` provider option so it applies the correct reasoning behavior\n * for both id forms. Users can still override it.\n */\nexport class NeonResponsesLanguageModel\n\textends OpenAIResponsesLanguageModel\n\timplements LanguageModelV3\n{\n\tprivate get isReasoningFamily(): boolean {\n\t\treturn /gpt-5/.test(this.modelId.toLowerCase());\n\t}\n\n\tprivate withForcedReasoning(\n\t\toptions: LanguageModelV3CallOptions,\n\t): LanguageModelV3CallOptions {\n\t\tif (!this.isReasoningFamily) {\n\t\t\treturn options;\n\t\t}\n\t\tconst openai = options.providerOptions?.openai;\n\t\t// Respect an explicit user setting.\n\t\tif (openai != null && \"forceReasoning\" in openai) {\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\topenai: { ...openai, forceReasoning: true },\n\t\t\t},\n\t\t};\n\t}\n\n\toverride doGenerate(\n\t\toptions: LanguageModelV3CallOptions,\n\t): Promise<LanguageModelV3GenerateResult> {\n\t\treturn super.doGenerate(this.withForcedReasoning(options));\n\t}\n\n\toverride doStream(\n\t\toptions: LanguageModelV3CallOptions,\n\t): Promise<LanguageModelV3StreamResult> {\n\t\treturn super.doStream(this.withForcedReasoning(options));\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,IAAa,6BAAb,cACS,6BAET;CACC,IAAY,oBAA6B;EACxC,OAAO,QAAQ,KAAK,KAAK,QAAQ,YAAY,CAAC;CAC/C;CAEA,oBACC,SAC6B;EAC7B,IAAI,CAAC,KAAK,mBACT,OAAO;EAER,MAAM,SAAS,QAAQ,iBAAiB;EAExC,IAAI,UAAU,QAAQ,oBAAoB,QACzC,OAAO;EAER,OAAO;GACN,GAAG;GACH,iBAAiB;IAChB,GAAG,QAAQ;IACX,QAAQ;KAAE,GAAG;KAAQ,gBAAgB;IAAK;GAC3C;EACD;CACD;CAEA,WACC,SACyC;EACzC,OAAO,MAAM,WAAW,KAAK,oBAAoB,OAAO,CAAC;CAC1D;CAEA,SACC,SACuC;EACvC,OAAO,MAAM,SAAS,KAAK,oBAAoB,OAAO,CAAC;CACxD;AACD"}
@@ -0,0 +1,52 @@
1
+ import { NeonChatModelId } from "./neon-chat-options.js";
2
+ import { openai } from "@ai-sdk/openai";
3
+ import { LanguageModelV3, ProviderV3 } from "@ai-sdk/provider";
4
+ import { FetchFunction } from "@ai-sdk/provider-utils";
5
+ import { z } from "zod/v4";
6
+
7
+ //#region src/lib/provider.d.ts
8
+
9
+ declare const neonErrorSchema: z.ZodObject<{
10
+ error: z.ZodObject<{
11
+ message: z.ZodString;
12
+ type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
+ param: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
14
+ code: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
15
+ }, z.core.$strip>;
16
+ }, z.core.$strip>;
17
+ type NeonErrorData = z.infer<typeof neonErrorSchema>;
18
+ interface NeonProviderSettings {
19
+ /**
20
+ * Neon AI Gateway base URL — the branch-scoped host root, e.g.
21
+ * `https://<branch-id>-api.ai.<region>.aws.neon.tech`. The gateway paths are
22
+ * appended internally. Falls back to the `NEON_AI_GATEWAY_BASE_URL` env var.
23
+ */
24
+ baseURL?: string;
25
+ /**
26
+ * Neon AI Gateway platform token (the `nt_live_...` value). Falls back to the
27
+ * `NEON_AI_GATEWAY_TOKEN` env var.
28
+ */
29
+ apiKey?: string;
30
+ /** Custom headers to include in the requests. */
31
+ headers?: Record<string, string>;
32
+ /** Custom fetch implementation (e.g. for testing or middleware). */
33
+ fetch?: FetchFunction;
34
+ }
35
+ interface NeonProvider extends ProviderV3 {
36
+ /** Creates a Neon AI Gateway model for text generation. */
37
+ (modelId: NeonChatModelId): LanguageModelV3;
38
+ /** Creates a Neon AI Gateway model for text generation. */
39
+ languageModel(modelId: NeonChatModelId): LanguageModelV3;
40
+ /** Creates a Neon AI Gateway chat model for text generation. */
41
+ chat(modelId: NeonChatModelId): LanguageModelV3;
42
+ /** OpenAI Responses tools (e.g. `imageGeneration`) for OpenAI-routed models. */
43
+ tools: typeof openai.tools;
44
+ /** @deprecated Use `embeddingModel` instead. */
45
+ textEmbeddingModel(modelId: string): never;
46
+ }
47
+ declare function createNeon(options?: NeonProviderSettings): NeonProvider;
48
+ /** Default Neon provider instance (reads `NEON_AI_GATEWAY_*` env vars). */
49
+ declare const neon: NeonProvider;
50
+ //#endregion
51
+ export { NeonErrorData, NeonProvider, NeonProviderSettings, createNeon, neon };
52
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","names":[],"sources":["../../src/lib/provider.ts"],"mappings":";;;;;;;;cAmCM,iBAAe,CAAA,CAAA;;;;;IAAA,IAAA,eAAA,cAAA,aAAA,CAAA,CAAA;EAAA,CAAA,eAAA,CAAA;AASrB,CAAA,eAAY,CAAA;AAAa,KAAb,aAAA,GAAgB,CAAA,CAAE,KAAL,CAAA,OAAkB,eAAlB,CAAA;AAAkB,UA4C1B,oBAAA,CA5C0B;;AAAR;AA4CnC;;;SAkBS,CAAA,EAAA,MAAA;EAAa;AAGtB;;;QAE6B,CAAA,EAAA,MAAA;;SAGa,CAAA,EAX/B,MAW+B,CAAA,MAAA,EAAA,MAAA,CAAA;;OAGT,CAAA,EAXxB,aAWwB;;AARK,UAArB,YAAA,SAAqB,UAAA,CAAA;EAAU;EAiBhC,CAAA,OAAA,EAfL,eAee,CAAA,EAfG,eAeH;EAAA;eAAU,CAAA,OAAA,EAZZ,eAYY,CAAA,EAZM,eAYN;;EAAwC,IAAA,CAAA,OAAA,EAT7D,eAS6D,CAAA,EAT3C,eAS2C;EA0F/D;gBAhGE,MAAA,CAAe;;;;iBAMd,UAAA,WAAoB,uBAA4B;;cA0FnD,MAAI"}
@@ -0,0 +1,126 @@
1
+ import { NeonAnthropicLanguageModel } from "./neon-anthropic-language-model.js";
2
+ import { getNeonModelRoute } from "./neon-model-capabilities.js";
3
+ import { NeonChatLanguageModel } from "./neon-chat-language-model.js";
4
+ import { NeonResponsesLanguageModel } from "./neon-responses-language-model.js";
5
+ import { VERSION } from "./version.js";
6
+ import { openai } from "@ai-sdk/openai";
7
+ import { NoSuchModelError } from "@ai-sdk/provider";
8
+ import { generateId, loadApiKey, loadSetting, withUserAgentSuffix, withoutTrailingSlash } from "@ai-sdk/provider-utils";
9
+ import { z } from "zod/v4";
10
+ //#region src/lib/provider.ts
11
+ /**
12
+ * Community Vercel AI SDK provider for the Neon AI Gateway.
13
+ *
14
+ * `createNeon()` returns a provider that routes each model to the best gateway
15
+ * endpoint based on its id (Anthropic → native Messages, OpenAI → native
16
+ * Responses incl. Codex, everything else → unified MLflow), so a single
17
+ * `neon('claude-...')` call (same base URL + token) reaches the whole catalog.
18
+ * Ids use the canonical Neon (unprefixed) form; the legacy `databricks-` prefix
19
+ * is also accepted. Configure with the branch-scoped `NEON_AI_GATEWAY_BASE_URL` +
20
+ * `NEON_AI_GATEWAY_TOKEN` emitted by `neonctl env pull` / `neon dev`, or pass
21
+ * `baseURL` / `apiKey` explicitly.
22
+ */
23
+ const neonErrorStructure = {
24
+ errorSchema: z.object({ error: z.object({
25
+ message: z.string(),
26
+ type: z.string().nullish(),
27
+ param: z.unknown().nullish(),
28
+ code: z.unknown().nullish()
29
+ }) }),
30
+ errorToMessage: (data) => data.error.message
31
+ };
32
+ /**
33
+ * Recursively remove the JSON Schema `$schema` marker, which some gateway
34
+ * backends (notably Gemini) reject in tool/structured-output schemas. Other
35
+ * backends ignore its absence, so stripping it everywhere is safe.
36
+ */
37
+ function stripJsonSchemaMarker(value) {
38
+ if (Array.isArray(value)) return value.map(stripJsonSchemaMarker);
39
+ if (value !== null && typeof value === "object") {
40
+ const result = {};
41
+ for (const [key, entry] of Object.entries(value)) {
42
+ if (key === "$schema") continue;
43
+ result[key] = stripJsonSchemaMarker(entry);
44
+ }
45
+ return result;
46
+ }
47
+ return value;
48
+ }
49
+ function transformNeonRequestBody(args) {
50
+ const transformed = { ...args };
51
+ if (transformed.tools != null) transformed.tools = stripJsonSchemaMarker(transformed.tools);
52
+ if (transformed.response_format != null) transformed.response_format = stripJsonSchemaMarker(transformed.response_format);
53
+ return transformed;
54
+ }
55
+ function createNeon(options = {}) {
56
+ const getHost = () => withoutTrailingSlash(loadSetting({
57
+ settingValue: options.baseURL,
58
+ environmentVariableName: "NEON_AI_GATEWAY_BASE_URL",
59
+ settingName: "baseURL",
60
+ description: "Neon AI Gateway base URL"
61
+ }));
62
+ const getHeaders = (extra) => withUserAgentSuffix({
63
+ Authorization: `Bearer ${loadApiKey({
64
+ apiKey: options.apiKey,
65
+ environmentVariableName: "NEON_AI_GATEWAY_TOKEN",
66
+ description: "Neon AI Gateway token"
67
+ })}`,
68
+ ...extra,
69
+ ...options.headers
70
+ }, `neondatabase/ai-sdk-provider/${VERSION}`);
71
+ const createAnthropicModel = (modelId) => new NeonAnthropicLanguageModel(modelId, {
72
+ provider: "neon.anthropic",
73
+ baseURL: `${getHost()}/ai-gateway/anthropic/v1`,
74
+ headers: () => getHeaders({ "anthropic-version": "2023-06-01" }),
75
+ fetch: options.fetch,
76
+ generateId
77
+ });
78
+ const createOpenAIModel = (modelId) => new NeonResponsesLanguageModel(modelId, {
79
+ provider: "neon.openai.responses",
80
+ url: ({ path }) => `${getHost()}/ai-gateway/openai/v1${path}`,
81
+ headers: getHeaders,
82
+ fetch: options.fetch,
83
+ fileIdPrefixes: ["file-"]
84
+ });
85
+ const createChatModel = (modelId) => new NeonChatLanguageModel(modelId, {
86
+ provider: "neon.chat",
87
+ url: ({ path }) => `${getHost()}/ai-gateway/mlflow/v1${path}`,
88
+ headers: getHeaders,
89
+ fetch: options.fetch,
90
+ errorStructure: neonErrorStructure,
91
+ transformRequestBody: transformNeonRequestBody,
92
+ supportsStructuredOutputs: true
93
+ });
94
+ const createLanguageModel = (modelId) => {
95
+ switch (getNeonModelRoute(modelId)) {
96
+ case "anthropic": return createAnthropicModel(modelId);
97
+ case "openai": return createOpenAIModel(modelId);
98
+ default: return createChatModel(modelId);
99
+ }
100
+ };
101
+ const provider = (modelId) => createLanguageModel(modelId);
102
+ provider.specificationVersion = "v3";
103
+ provider.languageModel = createLanguageModel;
104
+ provider.chat = createLanguageModel;
105
+ provider.tools = openai.tools;
106
+ provider.embeddingModel = (modelId) => {
107
+ throw new NoSuchModelError({
108
+ modelId,
109
+ modelType: "embeddingModel"
110
+ });
111
+ };
112
+ provider.textEmbeddingModel = provider.embeddingModel;
113
+ provider.imageModel = (modelId) => {
114
+ throw new NoSuchModelError({
115
+ modelId,
116
+ modelType: "imageModel"
117
+ });
118
+ };
119
+ return provider;
120
+ }
121
+ /** Default Neon provider instance (reads `NEON_AI_GATEWAY_*` env vars). */
122
+ const neon = createNeon();
123
+ //#endregion
124
+ export { createNeon, neon };
125
+
126
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","names":["openaiProvider"],"sources":["../../src/lib/provider.ts"],"sourcesContent":["/**\n * Community Vercel AI SDK provider for the Neon AI Gateway.\n *\n * `createNeon()` returns a provider that routes each model to the best gateway\n * endpoint based on its id (Anthropic → native Messages, OpenAI → native\n * Responses incl. Codex, everything else → unified MLflow), so a single\n * `neon('claude-...')` call (same base URL + token) reaches the whole catalog.\n * Ids use the canonical Neon (unprefixed) form; the legacy `databricks-` prefix\n * is also accepted. Configure with the branch-scoped `NEON_AI_GATEWAY_BASE_URL` +\n * `NEON_AI_GATEWAY_TOKEN` emitted by `neonctl env pull` / `neon dev`, or pass\n * `baseURL` / `apiKey` explicitly.\n */\nimport { openai as openaiProvider } from \"@ai-sdk/openai\";\nimport type { ProviderErrorStructure } from \"@ai-sdk/openai-compatible\";\nimport {\n\ttype LanguageModelV3,\n\tNoSuchModelError,\n\ttype ProviderV3,\n} from \"@ai-sdk/provider\";\nimport {\n\ttype FetchFunction,\n\tgenerateId,\n\tloadApiKey,\n\tloadSetting,\n\twithoutTrailingSlash,\n\twithUserAgentSuffix,\n} from \"@ai-sdk/provider-utils\";\nimport { z } from \"zod/v4\";\nimport { NeonAnthropicLanguageModel } from \"./neon-anthropic-language-model.js\";\nimport { NeonChatLanguageModel } from \"./neon-chat-language-model.js\";\nimport type { NeonChatModelId } from \"./neon-chat-options.js\";\nimport { getNeonModelRoute } from \"./neon-model-capabilities.js\";\nimport { NeonResponsesLanguageModel } from \"./neon-responses-language-model.js\";\nimport { VERSION } from \"./version.js\";\n\nconst neonErrorSchema = z.object({\n\terror: z.object({\n\t\tmessage: z.string(),\n\t\ttype: z.string().nullish(),\n\t\tparam: z.unknown().nullish(),\n\t\tcode: z.unknown().nullish(),\n\t}),\n});\n\nexport type NeonErrorData = z.infer<typeof neonErrorSchema>;\n\nconst neonErrorStructure: ProviderErrorStructure<NeonErrorData> = {\n\terrorSchema: neonErrorSchema,\n\terrorToMessage: (data) => data.error.message,\n};\n\n/**\n * Recursively remove the JSON Schema `$schema` marker, which some gateway\n * backends (notably Gemini) reject in tool/structured-output schemas. Other\n * backends ignore its absence, so stripping it everywhere is safe.\n */\nfunction stripJsonSchemaMarker(value: unknown): unknown {\n\tif (Array.isArray(value)) {\n\t\treturn value.map(stripJsonSchemaMarker);\n\t}\n\tif (value !== null && typeof value === \"object\") {\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const [key, entry] of Object.entries(value)) {\n\t\t\tif (key === \"$schema\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresult[key] = stripJsonSchemaMarker(entry);\n\t\t}\n\t\treturn result;\n\t}\n\treturn value;\n}\n\nfunction transformNeonRequestBody(\n\targs: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst transformed = { ...args };\n\tif (transformed.tools != null) {\n\t\ttransformed.tools = stripJsonSchemaMarker(transformed.tools);\n\t}\n\tif (transformed.response_format != null) {\n\t\ttransformed.response_format = stripJsonSchemaMarker(\n\t\t\ttransformed.response_format,\n\t\t);\n\t}\n\treturn transformed;\n}\n\nexport interface NeonProviderSettings {\n\t/**\n\t * Neon AI Gateway base URL — the branch-scoped host root, e.g.\n\t * `https://<branch-id>-api.ai.<region>.aws.neon.tech`. The gateway paths are\n\t * appended internally. Falls back to the `NEON_AI_GATEWAY_BASE_URL` env var.\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * Neon AI Gateway platform token (the `nt_live_...` value). Falls back to the\n\t * `NEON_AI_GATEWAY_TOKEN` env var.\n\t */\n\tapiKey?: string;\n\n\t/** Custom headers to include in the requests. */\n\theaders?: Record<string, string>;\n\n\t/** Custom fetch implementation (e.g. for testing or middleware). */\n\tfetch?: FetchFunction;\n}\n\nexport interface NeonProvider extends ProviderV3 {\n\t/** Creates a Neon AI Gateway model for text generation. */\n\t(modelId: NeonChatModelId): LanguageModelV3;\n\n\t/** Creates a Neon AI Gateway model for text generation. */\n\tlanguageModel(modelId: NeonChatModelId): LanguageModelV3;\n\n\t/** Creates a Neon AI Gateway chat model for text generation. */\n\tchat(modelId: NeonChatModelId): LanguageModelV3;\n\n\t/** OpenAI Responses tools (e.g. `imageGeneration`) for OpenAI-routed models. */\n\ttools: typeof openaiProvider.tools;\n\n\t/** @deprecated Use `embeddingModel` instead. */\n\ttextEmbeddingModel(modelId: string): never;\n}\n\nexport function createNeon(options: NeonProviderSettings = {}): NeonProvider {\n\t// Resolved lazily so that `createNeon()` and the default `neon` instance do\n\t// not throw at import time when configuration comes from the environment.\n\tconst getHost = () =>\n\t\twithoutTrailingSlash(\n\t\t\tloadSetting({\n\t\t\t\tsettingValue: options.baseURL,\n\t\t\t\tenvironmentVariableName: \"NEON_AI_GATEWAY_BASE_URL\",\n\t\t\t\tsettingName: \"baseURL\",\n\t\t\t\tdescription: \"Neon AI Gateway base URL\",\n\t\t\t}),\n\t\t);\n\n\tconst getHeaders = (extra?: Record<string, string>) =>\n\t\twithUserAgentSuffix(\n\t\t\t{\n\t\t\t\tAuthorization: `Bearer ${loadApiKey({\n\t\t\t\t\tapiKey: options.apiKey,\n\t\t\t\t\tenvironmentVariableName: \"NEON_AI_GATEWAY_TOKEN\",\n\t\t\t\t\tdescription: \"Neon AI Gateway token\",\n\t\t\t\t})}`,\n\t\t\t\t...extra,\n\t\t\t\t...options.headers,\n\t\t\t},\n\t\t\t`neondatabase/ai-sdk-provider/${VERSION}`,\n\t\t);\n\n\t// Anthropic models -> native Messages API.\n\tconst createAnthropicModel = (modelId: NeonChatModelId) =>\n\t\tnew NeonAnthropicLanguageModel(modelId, {\n\t\t\tprovider: \"neon.anthropic\",\n\t\t\tbaseURL: `${getHost()}/ai-gateway/anthropic/v1`,\n\t\t\theaders: () => getHeaders({ \"anthropic-version\": \"2023-06-01\" }),\n\t\t\tfetch: options.fetch,\n\t\t\tgenerateId,\n\t\t});\n\n\t// OpenAI models (incl. Codex, only served natively) -> Responses API.\n\tconst createOpenAIModel = (modelId: NeonChatModelId) =>\n\t\tnew NeonResponsesLanguageModel(modelId, {\n\t\t\tprovider: \"neon.openai.responses\",\n\t\t\turl: ({ path }) => `${getHost()}/ai-gateway/openai/v1${path}`,\n\t\t\theaders: getHeaders,\n\t\t\tfetch: options.fetch,\n\t\t\tfileIdPrefixes: [\"file-\"],\n\t\t});\n\n\t// Everything else (Gemini, Llama, Qwen, gpt-oss, ...) -> unified MLflow\n\t// endpoint. Gemini is here because its native endpoint can't stream.\n\tconst createChatModel = (modelId: NeonChatModelId) =>\n\t\tnew NeonChatLanguageModel(modelId, {\n\t\t\tprovider: \"neon.chat\",\n\t\t\turl: ({ path }) => `${getHost()}/ai-gateway/mlflow/v1${path}`,\n\t\t\theaders: getHeaders,\n\t\t\tfetch: options.fetch,\n\t\t\terrorStructure: neonErrorStructure,\n\t\t\ttransformRequestBody: transformNeonRequestBody,\n\t\t\tsupportsStructuredOutputs: true,\n\t\t});\n\n\tconst createLanguageModel = (modelId: NeonChatModelId): LanguageModelV3 => {\n\t\tswitch (getNeonModelRoute(modelId)) {\n\t\t\tcase \"anthropic\":\n\t\t\t\treturn createAnthropicModel(modelId);\n\t\t\tcase \"openai\":\n\t\t\t\treturn createOpenAIModel(modelId);\n\t\t\tdefault:\n\t\t\t\treturn createChatModel(modelId);\n\t\t}\n\t};\n\n\tconst provider = (modelId: NeonChatModelId) => createLanguageModel(modelId);\n\n\tprovider.specificationVersion = \"v3\" as const;\n\tprovider.languageModel = createLanguageModel;\n\tprovider.chat = createLanguageModel;\n\tprovider.tools = openaiProvider.tools;\n\n\tprovider.embeddingModel = (modelId: string) => {\n\t\tthrow new NoSuchModelError({ modelId, modelType: \"embeddingModel\" });\n\t};\n\tprovider.textEmbeddingModel = provider.embeddingModel;\n\tprovider.imageModel = (modelId: string) => {\n\t\tthrow new NoSuchModelError({ modelId, modelType: \"imageModel\" });\n\t};\n\n\treturn provider;\n}\n\n/** Default Neon provider instance (reads `NEON_AI_GATEWAY_*` env vars). */\nexport const neon = createNeon();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,qBAA4D;CACjE,aAZuB,EAAE,OAAO,EAChC,OAAO,EAAE,OAAO;EACf,SAAS,EAAE,OAAO;EAClB,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ;EACzB,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ;EAC3B,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ;CAC3B,CAAC,EACF,CAK4B;CAC3B,iBAAiB,SAAS,KAAK,MAAM;AACtC;;;;;;AAOA,SAAS,sBAAsB,OAAyB;CACvD,IAAI,MAAM,QAAQ,KAAK,GACtB,OAAO,MAAM,IAAI,qBAAqB;CAEvC,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;EAChD,MAAM,SAAkC,CAAC;EACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAAG;GACjD,IAAI,QAAQ,WACX;GAED,OAAO,OAAO,sBAAsB,KAAK;EAC1C;EACA,OAAO;CACR;CACA,OAAO;AACR;AAEA,SAAS,yBACR,MAC0B;CAC1B,MAAM,cAAc,EAAE,GAAG,KAAK;CAC9B,IAAI,YAAY,SAAS,MACxB,YAAY,QAAQ,sBAAsB,YAAY,KAAK;CAE5D,IAAI,YAAY,mBAAmB,MAClC,YAAY,kBAAkB,sBAC7B,YAAY,eACb;CAED,OAAO;AACR;AAwCA,SAAgB,WAAW,UAAgC,CAAC,GAAiB;CAG5E,MAAM,gBACL,qBACC,YAAY;EACX,cAAc,QAAQ;EACtB,yBAAyB;EACzB,aAAa;EACb,aAAa;CACd,CAAC,CACF;CAED,MAAM,cAAc,UACnB,oBACC;EACC,eAAe,UAAU,WAAW;GACnC,QAAQ,QAAQ;GAChB,yBAAyB;GACzB,aAAa;EACd,CAAC;EACD,GAAG;EACH,GAAG,QAAQ;CACZ,GACA,gCAAgC,SACjC;CAGD,MAAM,wBAAwB,YAC7B,IAAI,2BAA2B,SAAS;EACvC,UAAU;EACV,SAAS,GAAG,QAAQ,EAAE;EACtB,eAAe,WAAW,EAAE,qBAAqB,aAAa,CAAC;EAC/D,OAAO,QAAQ;EACf;CACD,CAAC;CAGF,MAAM,qBAAqB,YAC1B,IAAI,2BAA2B,SAAS;EACvC,UAAU;EACV,MAAM,EAAE,WAAW,GAAG,QAAQ,EAAE,uBAAuB;EACvD,SAAS;EACT,OAAO,QAAQ;EACf,gBAAgB,CAAC,OAAO;CACzB,CAAC;CAIF,MAAM,mBAAmB,YACxB,IAAI,sBAAsB,SAAS;EAClC,UAAU;EACV,MAAM,EAAE,WAAW,GAAG,QAAQ,EAAE,uBAAuB;EACvD,SAAS;EACT,OAAO,QAAQ;EACf,gBAAgB;EAChB,sBAAsB;EACtB,2BAA2B;CAC5B,CAAC;CAEF,MAAM,uBAAuB,YAA8C;EAC1E,QAAQ,kBAAkB,OAAO,GAAjC;GACC,KAAK,aACJ,OAAO,qBAAqB,OAAO;GACpC,KAAK,UACJ,OAAO,kBAAkB,OAAO;GACjC,SACC,OAAO,gBAAgB,OAAO;EAChC;CACD;CAEA,MAAM,YAAY,YAA6B,oBAAoB,OAAO;CAE1E,SAAS,uBAAuB;CAChC,SAAS,gBAAgB;CACzB,SAAS,OAAO;CAChB,SAAS,QAAQA,OAAe;CAEhC,SAAS,kBAAkB,YAAoB;EAC9C,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAiB,CAAC;CACpE;CACA,SAAS,qBAAqB,SAAS;CACvC,SAAS,cAAc,YAAoB;EAC1C,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CAChE;CAEA,OAAO;AACR;;AAGA,MAAa,OAAO,WAAW"}
@@ -0,0 +1,5 @@
1
+ //#region src/lib/version.d.ts
2
+ declare const VERSION: string;
3
+ //#endregion
4
+ export { VERSION };
5
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","names":[],"sources":["../../src/lib/version.ts"],"mappings":";cAIa"}
@@ -0,0 +1,7 @@
1
+ import { version } from "../package.js";
2
+ //#region src/lib/version.ts
3
+ const VERSION = version;
4
+ //#endregion
5
+ export { VERSION };
6
+
7
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","names":["pkg.version"],"sources":["../../src/lib/version.ts"],"sourcesContent":["import pkg from \"../../package.json\" with { type: \"json\" };\n\n// Package version, used in the User-Agent suffix sent to the gateway. Derived\n// from package.json so it stays in sync with the changeset version bump flow.\nexport const VERSION: string = pkg.version;\n"],"mappings":";;AAIA,MAAa,UAAkBA"}
@@ -0,0 +1,6 @@
1
+ //#region package.json
2
+ var version = "0.5.0";
3
+ //#endregion
4
+ export { version };
5
+
6
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
package/package.json CHANGED
@@ -1,30 +1,74 @@
1
1
  {
2
2
  "name": "@neon/ai-sdk-provider",
3
- "version": "0.0.0",
4
- "description": "Neon provider for the AI SDK.",
3
+ "version": "0.5.0",
4
+ "description": "Community Vercel AI SDK provider for the Neon AI Gateway.",
5
+ "keywords": [
6
+ "neon",
7
+ "ai",
8
+ "ai-sdk",
9
+ "vercel-ai-sdk",
10
+ "provider",
11
+ "ai-gateway",
12
+ "llm",
13
+ "platform"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/neondatabase/neon-pkgs.git"
18
+ },
5
19
  "license": "Apache-2.0",
6
20
  "author": {
7
21
  "name": "Neon",
8
22
  "url": "https://neon.com"
9
23
  },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/neondatabase/neon-pkgs.git",
13
- "directory": "packages/ai-sdk-provider"
14
- },
15
- "homepage": "https://github.com/neondatabase/neon-pkgs",
16
- "bugs": {
17
- "url": "https://github.com/neondatabase/neon-pkgs/issues"
24
+ "type": "module",
25
+ "main": "dist/index.js",
26
+ "types": "dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js",
31
+ "default": "./dist/index.js"
32
+ }
18
33
  },
19
- "keywords": [
20
- "neon",
21
- "ai",
22
- "ai-sdk",
23
- "database",
24
- "postgres"
34
+ "files": [
35
+ "README.md",
36
+ "dist/",
37
+ "package.json"
25
38
  ],
39
+ "devDependencies": {
40
+ "@types/node": "^20.19.0",
41
+ "@vitest/coverage-v8": "3.0.9",
42
+ "ai": "6.0.132",
43
+ "console-fail-test": "0.5.0",
44
+ "tsdown": "^0.14.1",
45
+ "typescript": "^5.8.2",
46
+ "vitest": "^3.0.9",
47
+ "zod": "^4.4.3"
48
+ },
49
+ "engines": {
50
+ "node": ">=22"
51
+ },
26
52
  "publishConfig": {
27
- "access": "public",
28
53
  "provenance": false
54
+ },
55
+ "dependencies": {
56
+ "@ai-sdk/anthropic": "^3.0.82",
57
+ "@ai-sdk/openai": "^3.0.69",
58
+ "@ai-sdk/openai-compatible": "^2.0.48",
59
+ "@ai-sdk/provider": "^3.0.10",
60
+ "@ai-sdk/provider-utils": "^4.0.27"
61
+ },
62
+ "peerDependencies": {
63
+ "ai": "^6.0.0",
64
+ "zod": "^3.25.76 || ^4.1.8"
65
+ },
66
+ "scripts": {
67
+ "build": "tsc --noEmit && tsdown",
68
+ "test": "vitest --passWithNoTests",
69
+ "test:ci": "vitest run --passWithNoTests",
70
+ "test:drift": "NEON_DRIFT_CHECK=1 vitest run neon-catalog-drift",
71
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
72
+ "tsc": "tsc"
29
73
  }
30
- }
74
+ }