@neon/ai-sdk-provider 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -183,6 +183,8 @@ for await (const part of result.fullStream) {
|
|
|
183
183
|
}
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
+
The image model defaults to `gpt-image-2`. Pass `model` to pick another one. `gpt-image-1` throws `UnsupportedFunctionalityError`, because OpenAI has deprecated it.
|
|
187
|
+
|
|
186
188
|
### Edit a generated image
|
|
187
189
|
|
|
188
190
|
The gateway does not support stored Responses API items (`store: true`, `previousResponseId`, or `conversation`), which the Responses API uses to reuse tool results across turns. For image edits, pass the returned bytes back as image input; otherwise the model does not receive the original image and generates a new one.
|
|
@@ -9,6 +9,7 @@ type NeonImageGenerationArgs = {
|
|
|
9
9
|
fileId?: string;
|
|
10
10
|
imageUrl?: string;
|
|
11
11
|
};
|
|
12
|
+
/** Image model. Defaults to `gpt-image-2`; `gpt-image-1` is rejected. */
|
|
12
13
|
model?: string;
|
|
13
14
|
moderation?: "auto";
|
|
14
15
|
outputCompression?: number;
|
|
@@ -29,13 +30,13 @@ declare function imageGeneration(args?: NeonImageGenerationArgs): {
|
|
|
29
30
|
type: "provider";
|
|
30
31
|
id: "openai.image_generation";
|
|
31
32
|
args: {
|
|
33
|
+
model: string;
|
|
32
34
|
background?: "auto" | "opaque" | "transparent";
|
|
33
35
|
inputFidelity?: "low" | "high";
|
|
34
36
|
inputImageMask?: {
|
|
35
37
|
fileId?: string;
|
|
36
38
|
imageUrl?: string;
|
|
37
39
|
};
|
|
38
|
-
model?: string;
|
|
39
40
|
moderation?: "auto";
|
|
40
41
|
outputCompression?: number;
|
|
41
42
|
outputFormat?: "png" | "jpeg" | "webp";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-openai-tools.d.ts","names":["openai","openaiProvider","z","NeonImageGenerationArgs","imageGeneration","core","$strip","ZodObject","ZodString","NeonOpenAITools","tools","Omit","neonOpenAITools","openaiProvider","z","openai","NeonImageGenerationArgs","background","inputFidelity","inputImageMask","fileId","imageUrl","model","moderation","outputCompression","outputFormat","partialImages","quality","size","imageGeneration","args","type","id","inputSchema","ZodObject","core","$strip","outputSchema","result","ZodString","isProviderExecuted","NeonOpenAITools","Omit","tools","neonOpenAITools"],"sources":["../../src/lib/neon-openai-tools.ts"],"mappings":";;;;A,
|
|
1
|
+
{"version":3,"file":"neon-openai-tools.d.ts","names":["openai","openaiProvider","z","NeonImageGenerationArgs","imageGeneration","core","$strip","ZodObject","ZodString","NeonOpenAITools","tools","Omit","neonOpenAITools","openaiProvider","z","openai","NeonImageGenerationArgs","background","inputFidelity","inputImageMask","fileId","imageUrl","model","moderation","outputCompression","outputFormat","partialImages","quality","size","imageGeneration","args","type","id","inputSchema","ZodObject","core","$strip","outputSchema","result","ZodString","isProviderExecuted","NeonOpenAITools","Omit","tools","neonOpenAITools"],"sources":["../../src/lib/neon-openai-tools.ts"],"mappings":";;;;A,KAIYG,uBAAAA,G;;EAAAA,aAAAA,CAAAA,EAAAA,KAAAA,GAAAA,MAAuB;EA8BnBC,cAAAA,CAAAA,EAAAA;IAAegB,MAAA,CAAA,EAAA,MAAA;IAAOjB,QAAAA,CAAAA,EAAAA,MAAAA;;;;;;;EAyB1BM,aAAAA,CAAAA,EAAAA,MAAe;EAAAkB,OAAA,CAAA,EAAA,MAAA,GAAA,KAAA,GAAA,QAAA,GAAA,MAAA;EACnB1B,IAAAA,CAAAA,EAAAA,MAAeS,GAAAA,WAAAA,GAAAA,WAAAA,GAAAA,WAAAA;AADOC,CAAAA;AAILP;AAAe;AAGxC;;;;;;A,iBAhCgBA,eAAAA,C,OAAsBD,uB;;;;;;;;;;;;;;;;;;;;;;;;A,KAyB1BM,eAAAA,GAAkBE,I,QACtBV,MAAAA,CAAeS,K;E,wBAGEN,e;;A,cAGZQ,e,EAAiBH,e"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { UnsupportedFunctionalityError } from "@ai-sdk/provider";
|
|
1
2
|
import { z } from "zod/v4";
|
|
2
3
|
import { openai } from "@ai-sdk/openai";
|
|
3
4
|
//#region src/lib/neon-openai-tools.ts
|
|
5
|
+
const DEFAULT_IMAGE_MODEL = "gpt-image-2";
|
|
4
6
|
const imageGenerationInputSchema = z.object({});
|
|
5
7
|
const imageGenerationOutputSchema = z.object({ result: z.string() });
|
|
6
8
|
/**
|
|
@@ -12,13 +14,20 @@ const imageGenerationOutputSchema = z.object({ result: z.string() });
|
|
|
12
14
|
* interface accepted by both SDK versions.
|
|
13
15
|
*/
|
|
14
16
|
function imageGeneration(args = {}) {
|
|
17
|
+
if (args.model === "gpt-image-1") throw new UnsupportedFunctionalityError({
|
|
18
|
+
functionality: "image generation with gpt-image-1",
|
|
19
|
+
message: "OpenAI has deprecated `gpt-image-1`, so image generation with it fails on the Neon AI Gateway. Use `gpt-image-2`, which `neon.tools.imageGeneration()` uses when `model` is omitted."
|
|
20
|
+
});
|
|
15
21
|
const type = "provider";
|
|
16
22
|
const id = "openai.image_generation";
|
|
17
23
|
const isProviderExecuted = true;
|
|
18
24
|
return {
|
|
19
25
|
type,
|
|
20
26
|
id,
|
|
21
|
-
args: {
|
|
27
|
+
args: {
|
|
28
|
+
...args,
|
|
29
|
+
model: args.model ?? DEFAULT_IMAGE_MODEL
|
|
30
|
+
},
|
|
22
31
|
inputSchema: imageGenerationInputSchema,
|
|
23
32
|
outputSchema: imageGenerationOutputSchema,
|
|
24
33
|
isProviderExecuted
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon-openai-tools.js","names":["openaiProvider"],"sources":["../../src/lib/neon-openai-tools.ts"],"sourcesContent":["import { openai as openaiProvider } from \"@ai-sdk/openai\";\nimport { z } from \"zod/v4\";\n\nexport type NeonImageGenerationArgs = {\n\tbackground?: \"auto\" | \"opaque\" | \"transparent\";\n\tinputFidelity?: \"low\" | \"high\";\n\tinputImageMask?: {\n\t\tfileId?: string;\n\t\timageUrl?: string;\n\t};\n\tmodel?: string;\n\tmoderation?: \"auto\";\n\toutputCompression?: number;\n\toutputFormat?: \"png\" | \"jpeg\" | \"webp\";\n\tpartialImages?: number;\n\tquality?: \"auto\" | \"low\" | \"medium\" | \"high\";\n\tsize?: \"auto\" | \"1024x1024\" | \"1024x1536\" | \"1536x1024\";\n};\n\nconst imageGenerationInputSchema = z.object({});\nconst imageGenerationOutputSchema = z.object({ result: z.string() });\n\n/**\n * OpenAI image generation tool with a schema shape shared by AI SDK 6 and 7.\n *\n * AI SDK 6's official factory wraps schemas in its version-specific `Schema`\n * type. AI SDK 7 can execute the resulting object, but rejects that type at\n * compile time. Raw Zod 4 schemas implement the shared Standard Schema\n * interface accepted by both SDK versions.\n */\nexport function imageGeneration(args: NeonImageGenerationArgs = {}) {\n\tconst type: \"provider\" = \"provider\";\n\tconst id: \"openai.image_generation\" = \"openai.image_generation\";\n\tconst isProviderExecuted: true = true;\n\n\treturn {\n\t\ttype,\n\t\tid,\n\t\targs: { ...args },\n\t\tinputSchema: imageGenerationInputSchema,\n\t\toutputSchema: imageGenerationOutputSchema,\n\t\tisProviderExecuted,\n\t};\n}\n\nexport type NeonOpenAITools = Omit<\n\ttypeof openaiProvider.tools,\n\t\"imageGeneration\"\n> & {\n\timageGeneration: typeof imageGeneration;\n};\n\nexport const neonOpenAITools: NeonOpenAITools = {\n\t...openaiProvider.tools,\n\timageGeneration,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"neon-openai-tools.js","names":["openaiProvider"],"sources":["../../src/lib/neon-openai-tools.ts"],"sourcesContent":["import { openai as openaiProvider } from \"@ai-sdk/openai\";\nimport { UnsupportedFunctionalityError } from \"@ai-sdk/provider\";\nimport { z } from \"zod/v4\";\n\nexport type NeonImageGenerationArgs = {\n\tbackground?: \"auto\" | \"opaque\" | \"transparent\";\n\tinputFidelity?: \"low\" | \"high\";\n\tinputImageMask?: {\n\t\tfileId?: string;\n\t\timageUrl?: string;\n\t};\n\t/** Image model. Defaults to `gpt-image-2`; `gpt-image-1` is rejected. */\n\tmodel?: string;\n\tmoderation?: \"auto\";\n\toutputCompression?: number;\n\toutputFormat?: \"png\" | \"jpeg\" | \"webp\";\n\tpartialImages?: number;\n\tquality?: \"auto\" | \"low\" | \"medium\" | \"high\";\n\tsize?: \"auto\" | \"1024x1024\" | \"1024x1536\" | \"1536x1024\";\n};\n\nconst DEFAULT_IMAGE_MODEL = \"gpt-image-2\";\n\nconst imageGenerationInputSchema = z.object({});\nconst imageGenerationOutputSchema = z.object({ result: z.string() });\n\n/**\n * OpenAI image generation tool with a schema shape shared by AI SDK 6 and 7.\n *\n * AI SDK 6's official factory wraps schemas in its version-specific `Schema`\n * type. AI SDK 7 can execute the resulting object, but rejects that type at\n * compile time. Raw Zod 4 schemas implement the shared Standard Schema\n * interface accepted by both SDK versions.\n */\nexport function imageGeneration(args: NeonImageGenerationArgs = {}) {\n\tif (args.model === \"gpt-image-1\") {\n\t\tthrow new UnsupportedFunctionalityError({\n\t\t\tfunctionality: \"image generation with gpt-image-1\",\n\t\t\tmessage:\n\t\t\t\t\"OpenAI has deprecated `gpt-image-1`, so image generation with it \" +\n\t\t\t\t\"fails on the Neon AI Gateway. Use `gpt-image-2`, which \" +\n\t\t\t\t\"`neon.tools.imageGeneration()` uses when `model` is omitted.\",\n\t\t});\n\t}\n\n\tconst type: \"provider\" = \"provider\";\n\tconst id: \"openai.image_generation\" = \"openai.image_generation\";\n\tconst isProviderExecuted: true = true;\n\n\treturn {\n\t\ttype,\n\t\tid,\n\t\targs: { ...args, model: args.model ?? DEFAULT_IMAGE_MODEL },\n\t\tinputSchema: imageGenerationInputSchema,\n\t\toutputSchema: imageGenerationOutputSchema,\n\t\tisProviderExecuted,\n\t};\n}\n\nexport type NeonOpenAITools = Omit<\n\ttypeof openaiProvider.tools,\n\t\"imageGeneration\"\n> & {\n\timageGeneration: typeof imageGeneration;\n};\n\nexport const neonOpenAITools: NeonOpenAITools = {\n\t...openaiProvider.tools,\n\timageGeneration,\n};\n"],"mappings":";;;;AAqBA,MAAM,sBAAsB;AAE5B,MAAM,6BAA6B,EAAE,OAAO,CAAC,CAAC;AAC9C,MAAM,8BAA8B,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;;;;;;;;;AAUnE,SAAgB,gBAAgB,OAAgC,CAAC,GAAG;CACnE,IAAI,KAAK,UAAU,eAClB,MAAM,IAAI,8BAA8B;EACvC,eAAe;EACf,SACC;CAGF,CAAC;CAGF,MAAM,OAAmB;CACzB,MAAM,KAAgC;CACtC,MAAM,qBAA2B;CAEjC,OAAO;EACN;EACA;EACA,MAAM;GAAE,GAAG;GAAM,OAAO,KAAK,SAAS;EAAoB;EAC1D,aAAa;EACb,cAAc;EACd;CACD;AACD;AASA,MAAa,kBAAmC;CAC/C,GAAGA,OAAe;CAClB;AACD"}
|
package/dist/package.js
CHANGED