@ai-sdk/prodia 1.0.7 → 1.0.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @ai-sdk/prodia
2
2
 
3
+ ## 1.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 3988c08: docs: fix incorrect and outdated provider docs
8
+
9
+ ## 1.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [462ad00]
14
+ - @ai-sdk/provider-utils@4.0.10
15
+
3
16
  ## 1.0.7
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -376,7 +376,7 @@ var prodiaFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
376
376
  });
377
377
 
378
378
  // src/version.ts
379
- var VERSION = true ? "1.0.7" : "0.0.0-test";
379
+ var VERSION = true ? "1.0.9" : "0.0.0-test";
380
380
 
381
381
  // src/prodia-provider.ts
382
382
  var defaultBaseURL = "https://inference.prodia.com/v2";
package/dist/index.mjs CHANGED
@@ -362,7 +362,7 @@ var prodiaFailedResponseHandler = createJsonErrorResponseHandler({
362
362
  });
363
363
 
364
364
  // src/version.ts
365
- var VERSION = true ? "1.0.7" : "0.0.0-test";
365
+ var VERSION = true ? "1.0.9" : "0.0.0-test";
366
366
 
367
367
  // src/prodia-provider.ts
368
368
  var defaultBaseURL = "https://inference.prodia.com/v2";
@@ -0,0 +1,197 @@
1
+ ---
2
+ title: Prodia
3
+ description: Learn how to use Prodia models with the AI SDK.
4
+ ---
5
+
6
+ # Prodia Provider
7
+
8
+ [Prodia](https://prodia.com/) is a fast inference platform for generative AI, offering high-speed image generation with FLUX and Stable Diffusion models.
9
+
10
+ ## Setup
11
+
12
+ The Prodia provider is available via the `@ai-sdk/prodia` module. You can install it with
13
+
14
+ <Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>
15
+ <Tab>
16
+ <Snippet text="pnpm add @ai-sdk/prodia" dark />
17
+ </Tab>
18
+ <Tab>
19
+ <Snippet text="npm install @ai-sdk/prodia" dark />
20
+ </Tab>
21
+ <Tab>
22
+ <Snippet text="yarn add @ai-sdk/prodia" dark />
23
+ </Tab>
24
+
25
+ <Tab>
26
+ <Snippet text="bun add @ai-sdk/prodia" dark />
27
+ </Tab>
28
+ </Tabs>
29
+
30
+ ## Provider Instance
31
+
32
+ You can import the default provider instance `prodia` from `@ai-sdk/prodia`:
33
+
34
+ ```ts
35
+ import { prodia } from '@ai-sdk/prodia';
36
+ ```
37
+
38
+ If you need a customized setup, you can import `createProdia` and create a provider instance with your settings:
39
+
40
+ ```ts
41
+ import { createProdia } from '@ai-sdk/prodia';
42
+
43
+ const prodia = createProdia({
44
+ apiKey: 'your-api-key', // optional, defaults to PRODIA_TOKEN environment variable
45
+ baseURL: 'custom-url', // optional
46
+ headers: {
47
+ /* custom headers */
48
+ }, // optional
49
+ });
50
+ ```
51
+
52
+ You can use the following optional settings to customize the Prodia provider instance:
53
+
54
+ - **baseURL** _string_
55
+
56
+ Use a different URL prefix for API calls.
57
+ The default prefix is `https://inference.prodia.com/v2`.
58
+
59
+ - **apiKey** _string_
60
+
61
+ API key that is being sent using the `Authorization` header as a Bearer token.
62
+ It defaults to the `PRODIA_TOKEN` environment variable.
63
+
64
+ - **headers** _Record&lt;string,string&gt;_
65
+
66
+ Custom headers to include in the requests.
67
+
68
+ - **fetch** _(input: RequestInfo, init?: RequestInit) => Promise&lt;Response&gt;_
69
+
70
+ Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
71
+ You can use it as a middleware to intercept requests,
72
+ or to provide a custom fetch implementation for e.g. testing.
73
+
74
+ ## Image Models
75
+
76
+ You can create Prodia image models using the `.image()` factory method.
77
+ For more on image generation with the AI SDK see [generateImage()](/docs/reference/ai-sdk-core/generate-image).
78
+
79
+ ### Basic Usage
80
+
81
+ ```ts
82
+ import { writeFileSync } from 'node:fs';
83
+ import { prodia } from '@ai-sdk/prodia';
84
+ import { generateImage } from 'ai';
85
+
86
+ const { image } = await generateImage({
87
+ model: prodia.image('inference.flux-fast.schnell.txt2img.v2'),
88
+ prompt: 'A cat wearing an intricate robe',
89
+ });
90
+
91
+ const filename = `image-${Date.now()}.png`;
92
+ writeFileSync(filename, image.uint8Array);
93
+ console.log(`Image saved to ${filename}`);
94
+ ```
95
+
96
+ ### Model Capabilities
97
+
98
+ Prodia offers fast inference for various image generation models. Here are the supported model types:
99
+
100
+ | Model | Description |
101
+ | ---------------------------------------- | ---------------------------------------------------- |
102
+ | `inference.flux-fast.schnell.txt2img.v2` | Fast FLUX Schnell model for text-to-image generation |
103
+ | `inference.flux.schnell.txt2img.v2` | FLUX Schnell model for text-to-image generation |
104
+
105
+ <Note>
106
+ Prodia supports additional model IDs. Check the [Prodia
107
+ documentation](https://docs.prodia.com/) for the full list of available
108
+ models.
109
+ </Note>
110
+
111
+ ### Image Size
112
+
113
+ You can specify the image size using the `size` parameter in `WIDTHxHEIGHT` format:
114
+
115
+ ```ts
116
+ import { prodia } from '@ai-sdk/prodia';
117
+ import { generateImage } from 'ai';
118
+
119
+ const { image } = await generateImage({
120
+ model: prodia.image('inference.flux-fast.schnell.txt2img.v2'),
121
+ prompt: 'A serene mountain landscape at sunset',
122
+ size: '1024x768',
123
+ });
124
+ ```
125
+
126
+ ### Provider Options
127
+
128
+ Prodia image models support additional options through the `providerOptions.prodia` object:
129
+
130
+ ```ts
131
+ import { prodia, type ProdiaImageProviderOptions } from '@ai-sdk/prodia';
132
+ import { generateImage } from 'ai';
133
+
134
+ const { image } = await generateImage({
135
+ model: prodia.image('inference.flux-fast.schnell.txt2img.v2'),
136
+ prompt: 'A cat wearing an intricate robe',
137
+ providerOptions: {
138
+ prodia: {
139
+ width: 1024,
140
+ height: 768,
141
+ steps: 4,
142
+ stylePreset: 'cinematic',
143
+ } satisfies ProdiaImageProviderOptions,
144
+ },
145
+ });
146
+ ```
147
+
148
+ The following provider options are supported:
149
+
150
+ - **width** _number_ - Output width in pixels (256–1920). When set, this overrides any width derived from `size`.
151
+ - **height** _number_ - Output height in pixels (256–1920). When set, this overrides any height derived from `size`.
152
+ - **steps** _number_ - Number of computational iterations (1–4). More steps typically produce higher quality results.
153
+ - **stylePreset** _string_ - Apply a visual theme to the output image. Supported presets: `3d-model`, `analog-film`, `anime`, `cinematic`, `comic-book`, `digital-art`, `enhance`, `fantasy-art`, `isometric`, `line-art`, `low-poly`, `neon-punk`, `origami`, `photographic`, `pixel-art`, `texture`, `craft-clay`.
154
+ - **loras** _string[]_ - Augment the output with up to 3 LoRA models.
155
+ - **progressive** _boolean_ - When using JPEG output, return a progressive JPEG.
156
+
157
+ ### Seed
158
+
159
+ You can use the `seed` parameter to get reproducible results:
160
+
161
+ ```ts
162
+ import { prodia } from '@ai-sdk/prodia';
163
+ import { generateImage } from 'ai';
164
+
165
+ const { image } = await generateImage({
166
+ model: prodia.image('inference.flux-fast.schnell.txt2img.v2'),
167
+ prompt: 'A serene mountain landscape at sunset',
168
+ seed: 12345,
169
+ });
170
+ ```
171
+
172
+ ### Provider Metadata
173
+
174
+ The `generateImage` response includes provider-specific metadata in `providerMetadata.prodia.images[]`. Each image object may contain the following properties:
175
+
176
+ - **jobId** _string_ - The unique identifier for the generation job.
177
+ - **seed** _number_ - The seed used for generation. Useful for reproducing results.
178
+ - **elapsed** _number_ - Generation time in seconds.
179
+ - **iterationsPerSecond** _number_ - Processing speed metric.
180
+ - **createdAt** _string_ - Timestamp when the job was created.
181
+ - **updatedAt** _string_ - Timestamp when the job was last updated.
182
+
183
+ ```ts
184
+ import { prodia } from '@ai-sdk/prodia';
185
+ import { generateImage } from 'ai';
186
+
187
+ const { image, providerMetadata } = await generateImage({
188
+ model: prodia.image('inference.flux-fast.schnell.txt2img.v2'),
189
+ prompt: 'A serene mountain landscape at sunset',
190
+ });
191
+
192
+ // Access provider metadata
193
+ const metadata = providerMetadata?.prodia?.images?.[0];
194
+ console.log('Job ID:', metadata?.jobId);
195
+ console.log('Seed:', metadata?.seed);
196
+ console.log('Elapsed:', metadata?.elapsed);
197
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/prodia",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -8,6 +8,7 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
10
  "dist/**/*",
11
+ "docs/**/*",
11
12
  "src",
12
13
  "!src/**/*.test.ts",
13
14
  "!src/**/*.test-d.ts",
@@ -15,6 +16,9 @@
15
16
  "!src/**/__fixtures__",
16
17
  "CHANGELOG.md"
17
18
  ],
19
+ "directories": {
20
+ "doc": "./docs"
21
+ },
18
22
  "exports": {
19
23
  "./package.json": "./package.json",
20
24
  ".": {
@@ -25,7 +29,7 @@
25
29
  },
26
30
  "dependencies": {
27
31
  "@ai-sdk/provider": "3.0.5",
28
- "@ai-sdk/provider-utils": "4.0.9"
32
+ "@ai-sdk/provider-utils": "4.0.10"
29
33
  },
30
34
  "devDependencies": {
31
35
  "@types/node": "20.17.24",
@@ -58,7 +62,7 @@
58
62
  "scripts": {
59
63
  "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
60
64
  "build:watch": "pnpm clean && tsup --watch",
61
- "clean": "del-cli dist *.tsbuildinfo",
65
+ "clean": "del-cli dist docs *.tsbuildinfo",
62
66
  "lint": "eslint \"./**/*.ts*\"",
63
67
  "type-check": "tsc --build",
64
68
  "prettier-check": "prettier --check \"./**/*.ts*\"",