@runpod/ai-sdk-provider 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +275 -198
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @runpod/ai-sdk-provider
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - eb1b7f8: improved docs
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -1,198 +1,275 @@
1
- # Runpod AI SDK Provider
2
-
3
- The **Runpod provider** for the [AI SDK](https://ai-sdk.dev/docs) contains language model and image generation support for [Runpod's](https://runpod.io) public endpoints.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- # npm
9
- npm install @runpod/ai-sdk-provider
10
-
11
- # pnpm
12
- pnpm add @runpod/ai-sdk-provider
13
-
14
- # yarn
15
- yarn add @runpod/ai-sdk-provider
16
- ```
17
-
18
- ## Setup
19
-
20
- The Runpod provider requires a Runpod API key. You can obtain one from the [Runpod console](https://console.runpod.io/user/settings) under "API Keys".
21
-
22
- ### Environment Variable
23
-
24
- Set your API key as an environment variable:
25
-
26
- ```bash
27
- export RUNPOD_API_KEY="your-api-key-here"
28
- ```
29
-
30
- ### Provider Instance
31
-
32
- Import the provider:
33
-
34
- ```ts
35
- import { runpod } from '@runpod/ai-sdk-provider';
36
- ```
37
-
38
- ## Supported Models
39
-
40
- ### Language Models
41
-
42
- | Model ID | Description |
43
- | -------------------------------------- | ------------------------------------------------------------------- |
44
- | `deep-cogito/deep-cogito-v2-llama-70b` | 70B parameter general-purpose LLM with advanced reasoning |
45
- | `qwen/qwen3-32b-awq` | 32B parameter multilingual model with strong reasoning capabilities |
46
-
47
- ### Image Models
48
-
49
- | Model ID | Description | Supported Aspect Ratios |
50
- | -------------------------------------- | ------------------------------- | ----------------------- |
51
- | `qwen/qwen-image` | Text-to-image generation | 1:1, 4:3, 3:4 |
52
- | `bytedance/seedream-3.0` | Advanced text-to-image model | 1:1, 4:3, 3:4 |
53
- | `black-forest-labs/flux-1-kontext-dev` | Context-aware image generation | 1:1, 4:3, 3:4 |
54
- | `black-forest-labs/flux-1-schnell` | Fast image generation (4 steps) | 1:1, 4:3, 3:4 |
55
- | `black-forest-labs/flux-1-dev` | High-quality image generation | 1:1, 4:3, 3:4 |
56
-
57
- ## Usage Examples
58
-
59
- ### Basic Text Generation
60
-
61
- ```ts
62
- import { runpod } from '@runpod/ai-sdk-provider';
63
- import { generateText } from 'ai';
64
-
65
- const { text } = await generateText({
66
- model: runpod('deep-cogito/deep-cogito-v2-llama-70b'),
67
- prompt: 'Write a Python function that sorts a list:',
68
- });
69
-
70
- console.log(text);
71
- ```
72
-
73
- ### Streaming
74
-
75
- **Note**: Streaming is not yet supported by Runpod's public endpoints. The team is working on implementing this feature.
76
-
77
- ### Chat Conversations
78
-
79
- ```ts
80
- import { runpod } from '@runpod/ai-sdk-provider';
81
- import { generateText } from 'ai';
82
-
83
- const { text } = await generateText({
84
- model: runpod('deep-cogito/deep-cogito-v2-llama-70b'),
85
- messages: [
86
- { role: 'system', content: 'You are a helpful assistant.' },
87
- { role: 'user', content: 'What is the capital of France?' },
88
- ],
89
- });
90
- ```
91
-
92
- ### Function Calling
93
-
94
- ```ts
95
- import { runpod } from '@runpod/ai-sdk-provider';
96
- import { generateText, tool } from 'ai';
97
- import { z } from 'zod';
98
-
99
- const { text, toolCalls } = await generateText({
100
- model: runpod('deep-cogito/deep-cogito-v2-llama-70b'),
101
- prompt: 'What is the weather like in San Francisco?',
102
- tools: {
103
- getWeather: tool({
104
- description: 'Get weather information for a city',
105
- parameters: z.object({
106
- city: z.string().describe('The city name'),
107
- }),
108
- execute: async ({ city }) => {
109
- // Your weather API call here
110
- return `The weather in ${city} is sunny.`;
111
- },
112
- }),
113
- },
114
- });
115
- ```
116
-
117
- ### Structured Output
118
-
119
- ```ts
120
- import { runpod } from '@runpod/ai-sdk-provider';
121
- import { generateObject } from 'ai';
122
- import { z } from 'zod';
123
-
124
- const { object } = await generateObject({
125
- model: runpod('qwen/qwen3-32b-awq'),
126
- schema: z.object({
127
- recipe: z.object({
128
- name: z.string(),
129
- ingredients: z.array(z.string()),
130
- steps: z.array(z.string()),
131
- }),
132
- }),
133
- prompt: 'Generate a recipe for chocolate chip cookies.',
134
- });
135
-
136
- console.log(object.recipe);
137
- ```
138
-
139
- ### Image Generation
140
-
141
- ```ts
142
- import { runpod } from '@runpod/ai-sdk-provider';
143
- import { experimental_generateImage as generateImage } from 'ai';
144
-
145
- const { image } = await generateImage({
146
- model: runpod.imageModel('qwen/qwen-image'),
147
- prompt: 'A fashion-forward woman in Paris wearing a trench coat',
148
- aspectRatio: '4:3',
149
- });
150
-
151
- // With additional parameters
152
- const { image } = await generateImage({
153
- model: runpod.imageModel('qwen/qwen-image'),
154
- prompt: 'A sunset over mountains',
155
- size: '1328x1328',
156
- seed: 42,
157
- providerOptions: {
158
- runpod: {
159
- negative_prompt: 'blurry, low quality',
160
- enable_safety_checker: true,
161
- },
162
- },
163
- });
164
- ```
165
-
166
- #### Provider Options
167
-
168
- The Runpod provider supports additional options via `providerOptions.runpod`:
169
-
170
- | Option | Type | Default | Description |
171
- | ----------------------- | --------- | ------- | --------------------------------------------------- |
172
- | `negative_prompt` | `string` | - | Text describing what you don't want in the image |
173
- | `enable_safety_checker` | `boolean` | `true` | Enable content safety filtering |
174
- | `image` | `string` | - | Input image URL (required for Flux Kontext models) |
175
- | `maxPollAttempts` | `number` | `60` | Maximum polling attempts for async image generation |
176
- | `pollIntervalMillis` | `number` | `5000` | Polling interval in milliseconds (5 seconds) |
177
-
178
- **Notes**:
179
-
180
- - The provider uses strict validation for image parameters. Unsupported aspect ratios (like `16:9`, `9:16`, `3:2`, `2:3`) will throw an `InvalidArgumentError` with a clear message about supported alternatives.
181
- - Model availability may vary. Some models might be temporarily unavailable or require specific parameters.
182
- - **Verified working models**: All models tested and confirmed working
183
- - `qwen/qwen-image` - Original model (60s, JPEG)
184
- - `bytedance/seedream-3.0` - Fast model (17s, JPEG)
185
- - `black-forest-labs/flux-1-schnell` - Very fast (2s, PNG)
186
- - `black-forest-labs/flux-1-dev` - High quality (6s, PNG)
187
- - `black-forest-labs/flux-1-kontext-dev` - Context-aware with input images (38s, PNG)
188
- - The provider automatically handles different parameter formats:
189
- - **Qwen/Seedream**: `size` parameter, `result` response field
190
- - **Flux standard**: `width/height` parameters, `image_url` response field
191
- - **Flux Kontext**: `size` parameter + `image` input, `image_url` response field
192
-
193
- ## Links
194
-
195
- - [Runpod](https://runpod.io) - Cloud platform for AI compute
196
- - [Runpod Public Endpoints Documentation](https://docs.runpod.io/hub/public-endpoints)
197
- - [AI SDK Documentation](https://ai-sdk.dev/docs)
198
- - [GitHub Repository](https://github.com/runpod/ai-sdk-provider)
1
+ # Runpod AI SDK Provider
2
+
3
+ The **Runpod provider** for the [AI SDK](https://ai-sdk.dev/docs) contains language model and image generation support for [Runpod's](https://runpod.io) public endpoints.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # npm
9
+ npm install @runpod/ai-sdk-provider
10
+
11
+ # pnpm
12
+ pnpm add @runpod/ai-sdk-provider
13
+
14
+ # yarn
15
+ yarn add @runpod/ai-sdk-provider
16
+ ```
17
+
18
+ ## Setup
19
+
20
+ The Runpod provider requires a Runpod API key. You can obtain one from the [Runpod console](https://console.runpod.io/user/settings) under "API Keys".
21
+
22
+ ### Environment Variable
23
+
24
+ Set your API key as an environment variable:
25
+
26
+ ```bash
27
+ export RUNPOD_API_KEY="your-api-key-here"
28
+ ```
29
+
30
+ ### Provider Instance
31
+
32
+ Import the provider:
33
+
34
+ ```ts
35
+ import { runpod } from '@runpod/ai-sdk-provider';
36
+ ```
37
+
38
+ ## Supported Models
39
+
40
+ ### Language Models
41
+
42
+ | Model ID | Description |
43
+ | -------------------------------------- | ------------------------------------------------------------------- |
44
+ | `deep-cogito/deep-cogito-v2-llama-70b` | 70B parameter general-purpose LLM with advanced reasoning |
45
+ | `qwen/qwen3-32b-awq` | 32B parameter multilingual model with strong reasoning capabilities |
46
+
47
+ ### Image Models
48
+
49
+ | Model ID | Description | Supported Aspect Ratios |
50
+ | -------------------------------------- | ------------------------------- | ----------------------- |
51
+ | `qwen/qwen-image` | Text-to-image generation | 1:1, 4:3, 3:4 |
52
+ | `bytedance/seedream-3.0` | Advanced text-to-image model | 1:1, 4:3, 3:4 |
53
+ | `black-forest-labs/flux-1-kontext-dev` | Context-aware image generation | 1:1, 4:3, 3:4 |
54
+ | `black-forest-labs/flux-1-schnell` | Fast image generation (4 steps) | 1:1, 4:3, 3:4 |
55
+ | `black-forest-labs/flux-1-dev` | High-quality image generation | 1:1, 4:3, 3:4 |
56
+
57
+ ## Text Generation
58
+
59
+ ### Basic Usage
60
+
61
+ ```ts
62
+ import { runpod } from '@runpod/ai-sdk-provider';
63
+ import { generateText } from 'ai';
64
+
65
+ const { text } = await generateText({
66
+ model: runpod('deep-cogito/deep-cogito-v2-llama-70b'),
67
+ prompt: 'Write a Python function that sorts a list:',
68
+ });
69
+ ```
70
+
71
+ **Returns:**
72
+
73
+ - `text` - Generated text string
74
+ - `finishReason` - Why generation stopped ('stop', 'length', etc.)
75
+ - `usage` - Token usage information (prompt, completion, total tokens)
76
+
77
+ ### Chat Conversations
78
+
79
+ ```ts
80
+ const { text } = await generateText({
81
+ model: runpod('deep-cogito/deep-cogito-v2-llama-70b'),
82
+ messages: [
83
+ { role: 'system', content: 'You are a helpful assistant.' },
84
+ { role: 'user', content: 'What is the capital of France?' },
85
+ ],
86
+ });
87
+ ```
88
+
89
+ ### Function Calling
90
+
91
+ ```ts
92
+ import { generateText, tool } from 'ai';
93
+ import { z } from 'zod';
94
+
95
+ const { text, toolCalls } = await generateText({
96
+ model: runpod('deep-cogito/deep-cogito-v2-llama-70b'),
97
+ prompt: 'What is the weather like in San Francisco?',
98
+ tools: {
99
+ getWeather: tool({
100
+ description: 'Get weather information for a city',
101
+ parameters: z.object({
102
+ city: z.string().describe('The city name'),
103
+ }),
104
+ execute: async ({ city }) => {
105
+ return `The weather in ${city} is sunny.`;
106
+ },
107
+ }),
108
+ },
109
+ });
110
+ ```
111
+
112
+ **Additional Returns:**
113
+
114
+ - `toolCalls` - Array of tool calls made by the model
115
+ - `toolResults` - Results from executed tools
116
+
117
+ ### Structured Output
118
+
119
+ ```ts
120
+ import { generateObject } from 'ai';
121
+ import { z } from 'zod';
122
+
123
+ const { object } = await generateObject({
124
+ model: runpod('qwen/qwen3-32b-awq'),
125
+ schema: z.object({
126
+ recipe: z.object({
127
+ name: z.string(),
128
+ ingredients: z.array(z.string()),
129
+ steps: z.array(z.string()),
130
+ }),
131
+ }),
132
+ prompt: 'Generate a recipe for chocolate chip cookies.',
133
+ });
134
+ ```
135
+
136
+ **Returns:**
137
+
138
+ - `object` - Parsed object matching your schema
139
+ - `usage` - Token usage information
140
+
141
+ ### Streaming
142
+
143
+ **Note**: Streaming is not yet supported by Runpod's public endpoints. The team is working on implementing this feature.
144
+
145
+ ## Image Generation
146
+
147
+ ### Basic Usage
148
+
149
+ ```ts
150
+ import { runpod } from '@runpod/ai-sdk-provider';
151
+ import { experimental_generateImage as generateImage } from 'ai';
152
+
153
+ const { image } = await generateImage({
154
+ model: runpod.imageModel('qwen/qwen-image'),
155
+ prompt: 'A fashion-forward woman in Paris wearing a trench coat',
156
+ aspectRatio: '4:3',
157
+ });
158
+ ```
159
+
160
+ **Returns:**
161
+
162
+ - `image.uint8Array` - Binary image data (efficient for processing/saving)
163
+ - `image.base64` - Base64 encoded string (for web display)
164
+ - `image.mediaType` - MIME type ('image/jpeg' or 'image/png')
165
+ - `warnings` - Array of any warnings about unsupported parameters
166
+
167
+ ### Advanced Parameters
168
+
169
+ ```ts
170
+ const { image } = await generateImage({
171
+ model: runpod.imageModel('bytedance/seedream-3.0'),
172
+ prompt: 'A sunset over mountains',
173
+ size: '1328x1328',
174
+ seed: 42,
175
+ providerOptions: {
176
+ runpod: {
177
+ negative_prompt: 'blurry, low quality',
178
+ enable_safety_checker: true,
179
+ },
180
+ },
181
+ });
182
+
183
+ // Save to filesystem
184
+ import { writeFileSync } from 'fs';
185
+ writeFileSync('generated-image.jpg', image.uint8Array);
186
+ ```
187
+
188
+ ### Context-Aware Generation (Flux Kontext)
189
+
190
+ ```ts
191
+ const { image } = await generateImage({
192
+ model: runpod.imageModel('black-forest-labs/flux-1-kontext-dev'),
193
+ prompt: 'Transform this into a cyberpunk style with neon lights',
194
+ aspectRatio: '1:1',
195
+ providerOptions: {
196
+ runpod: {
197
+ image: 'https://example.com/input-image.jpg', // Image URL
198
+ negative_prompt: 'blurry, distorted',
199
+ },
200
+ },
201
+ });
202
+
203
+ // Alternative: Using base64 encoded image
204
+ const { image } = await generateImage({
205
+ model: runpod.imageModel('black-forest-labs/flux-1-kontext-dev'),
206
+ prompt: 'Make this image look like a painting',
207
+ aspectRatio: '4:3',
208
+ providerOptions: {
209
+ runpod: {
210
+ image: 'data:image/png;base64,iVBORw0KGgoAAAANS...', // Base64 data URI
211
+ negative_prompt: 'blurry, distorted',
212
+ },
213
+ },
214
+ });
215
+ ```
216
+
217
+ ### Advanced Configuration
218
+
219
+ ```ts
220
+ // Full control over generation parameters
221
+ const { image } = await generateImage({
222
+ model: runpod.imageModel('black-forest-labs/flux-1-dev'),
223
+ prompt: 'A majestic dragon breathing fire in a medieval castle',
224
+ size: '1328x1328',
225
+ seed: 42, // For reproducible results
226
+ providerOptions: {
227
+ runpod: {
228
+ negative_prompt: 'blurry, low quality, distorted, ugly, bad anatomy',
229
+ enable_safety_checker: true,
230
+ num_inference_steps: 50, // Higher quality (default: 28)
231
+ guidance: 3.5, // Stronger prompt adherence (default: 2)
232
+ output_format: 'png', // High quality format
233
+ // Polling settings for long generations
234
+ maxPollAttempts: 30,
235
+ pollIntervalMillis: 4000,
236
+ },
237
+ },
238
+ });
239
+
240
+ // Fast generation with minimal steps
241
+ const { image } = await generateImage({
242
+ model: runpod.imageModel('black-forest-labs/flux-1-schnell'),
243
+ prompt: 'A simple red apple',
244
+ aspectRatio: '1:1',
245
+ providerOptions: {
246
+ runpod: {
247
+ num_inference_steps: 2, // Even faster (default: 4)
248
+ guidance: 10, // Higher guidance for simple prompts
249
+ output_format: 'jpg', // Smaller file size
250
+ },
251
+ },
252
+ });
253
+ ```
254
+
255
+ ### Provider Options
256
+
257
+ | Option | Type | Default | Description |
258
+ | ----------------------- | --------- | ------- | ----------------------------------------------------------------------- |
259
+ | `negative_prompt` | `string` | `""` | Text describing what you don't want in the image |
260
+ | `enable_safety_checker` | `boolean` | `true` | Enable content safety filtering |
261
+ | `image` | `string` | - | Input image: URL or base64 data URI (required for Flux Kontext models) |
262
+ | `num_inference_steps` | `number` | Auto | Number of denoising steps (Flux: 4 for schnell, 28 for others) |
263
+ | `guidance` | `number` | Auto | Guidance scale for prompt adherence (Flux: 7 for schnell, 2 for others) |
264
+ | `output_format` | `string` | `"png"` | Output image format ("png" or "jpg") |
265
+ | `maxPollAttempts` | `number` | `60` | Maximum polling attempts for async generation |
266
+ | `pollIntervalMillis` | `number` | `5000` | Polling interval in milliseconds (5 seconds) |
267
+
268
+ **Note**: The provider uses strict validation for image parameters. Unsupported aspect ratios (like `16:9`, `9:16`, `3:2`, `2:3`) will throw an `InvalidArgumentError` with a clear message about supported alternatives.
269
+
270
+ ## Links
271
+
272
+ - [Runpod](https://runpod.io) - Cloud platform for AI compute
273
+ - [Runpod Public Endpoints Documentation](https://docs.runpod.io/hub/public-endpoints)
274
+ - [AI SDK Documentation](https://ai-sdk.dev/docs)
275
+ - [GitHub Repository](https://github.com/runpod/ai-sdk-provider)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runpod/ai-sdk-provider",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",