@ai-sdk/deepinfra 2.0.17 → 2.0.18

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,11 @@
1
1
  # @ai-sdk/deepinfra
2
2
 
3
+ ## 2.0.18
4
+
5
+ ### Patch Changes
6
+
7
+ - 2b8369d: chore: add docs to package dist
8
+
3
9
  ## 2.0.17
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -161,7 +161,7 @@ async function fileToBlob(file) {
161
161
  }
162
162
 
163
163
  // src/version.ts
164
- var VERSION = true ? "2.0.17" : "0.0.0-test";
164
+ var VERSION = true ? "2.0.18" : "0.0.0-test";
165
165
 
166
166
  // src/deepinfra-provider.ts
167
167
  function createDeepInfra(options = {}) {
package/dist/index.mjs CHANGED
@@ -150,7 +150,7 @@ async function fileToBlob(file) {
150
150
  }
151
151
 
152
152
  // src/version.ts
153
- var VERSION = true ? "2.0.17" : "0.0.0-test";
153
+ var VERSION = true ? "2.0.18" : "0.0.0-test";
154
154
 
155
155
  // src/deepinfra-provider.ts
156
156
  function createDeepInfra(options = {}) {
@@ -0,0 +1,292 @@
1
+ ---
2
+ title: DeepInfra
3
+ description: Learn how to use DeepInfra's models with the AI SDK.
4
+ ---
5
+
6
+ # DeepInfra Provider
7
+
8
+ The [DeepInfra](https://deepinfra.com) provider contains support for state-of-the-art models through the DeepInfra API, including Llama 3, Mixtral, Qwen, and many other popular open-source models.
9
+
10
+ ## Setup
11
+
12
+ The DeepInfra provider is available via the `@ai-sdk/deepinfra` module. You can install it with:
13
+
14
+ <Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>
15
+ <Tab>
16
+ <Snippet text="pnpm add @ai-sdk/deepinfra" dark />
17
+ </Tab>
18
+ <Tab>
19
+ <Snippet text="npm install @ai-sdk/deepinfra" dark />
20
+ </Tab>
21
+ <Tab>
22
+ <Snippet text="yarn add @ai-sdk/deepinfra" dark />
23
+ </Tab>
24
+
25
+ <Tab>
26
+ <Snippet text="bun add @ai-sdk/deepinfra" dark />
27
+ </Tab>
28
+ </Tabs>
29
+
30
+ ## Provider Instance
31
+
32
+ You can import the default provider instance `deepinfra` from `@ai-sdk/deepinfra`:
33
+
34
+ ```ts
35
+ import { deepinfra } from '@ai-sdk/deepinfra';
36
+ ```
37
+
38
+ If you need a customized setup, you can import `createDeepInfra` from `@ai-sdk/deepinfra` and create a provider instance with your settings:
39
+
40
+ ```ts
41
+ import { createDeepInfra } from '@ai-sdk/deepinfra';
42
+
43
+ const deepinfra = createDeepInfra({
44
+ apiKey: process.env.DEEPINFRA_API_KEY ?? '',
45
+ });
46
+ ```
47
+
48
+ You can use the following optional settings to customize the DeepInfra provider instance:
49
+
50
+ - **baseURL** _string_
51
+
52
+ Use a different URL prefix for API calls, e.g. to use proxy servers.
53
+ The default prefix is `https://api.deepinfra.com/v1`.
54
+
55
+ Note: Language models and embeddings use OpenAI-compatible endpoints at `{baseURL}/openai`,
56
+ while image models use `{baseURL}/inference`.
57
+
58
+ - **apiKey** _string_
59
+
60
+ API key that is being sent using the `Authorization` header. It defaults to
61
+ the `DEEPINFRA_API_KEY` environment variable.
62
+
63
+ - **headers** _Record&lt;string,string&gt;_
64
+
65
+ Custom headers to include in the requests.
66
+
67
+ - **fetch** _(input: RequestInfo, init?: RequestInit) => Promise&lt;Response&gt;_
68
+
69
+ Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
70
+ Defaults to the global `fetch` function.
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
+ ## Language Models
75
+
76
+ You can create language models using a provider instance. The first argument is the model ID, for example:
77
+
78
+ ```ts
79
+ import { deepinfra } from '@ai-sdk/deepinfra';
80
+ import { generateText } from 'ai';
81
+
82
+ const { text } = await generateText({
83
+ model: deepinfra('meta-llama/Meta-Llama-3.1-70B-Instruct'),
84
+ prompt: 'Write a vegetarian lasagna recipe for 4 people.',
85
+ });
86
+ ```
87
+
88
+ DeepInfra language models can also be used in the `streamText` function (see [AI SDK Core](/docs/ai-sdk-core)).
89
+
90
+ ## Model Capabilities
91
+
92
+ | Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
93
+ | --------------------------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
94
+ | `meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8` | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
95
+ | `meta-llama/Llama-4-Scout-17B-16E-Instruct` | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
96
+ | `meta-llama/Llama-3.3-70B-Instruct-Turbo` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
97
+ | `meta-llama/Llama-3.3-70B-Instruct` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
98
+ | `meta-llama/Meta-Llama-3.1-405B-Instruct` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
99
+ | `meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
100
+ | `meta-llama/Meta-Llama-3.1-70B-Instruct` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
101
+ | `meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
102
+ | `meta-llama/Meta-Llama-3.1-8B-Instruct` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
103
+ | `meta-llama/Llama-3.2-11B-Vision-Instruct` | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
104
+ | `meta-llama/Llama-3.2-90B-Vision-Instruct` | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
105
+ | `mistralai/Mixtral-8x7B-Instruct-v0.1` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
106
+ | `deepseek-ai/DeepSeek-V3` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
107
+ | `deepseek-ai/DeepSeek-R1` | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
108
+ | `deepseek-ai/DeepSeek-R1-Distill-Llama-70B` | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
109
+ | `deepseek-ai/DeepSeek-R1-Turbo` | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
110
+ | `nvidia/Llama-3.1-Nemotron-70B-Instruct` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
111
+ | `Qwen/Qwen2-7B-Instruct` | <Cross size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
112
+ | `Qwen/Qwen2.5-72B-Instruct` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
113
+ | `Qwen/Qwen2.5-Coder-32B-Instruct` | <Cross size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
114
+ | `Qwen/QwQ-32B-Preview` | <Cross size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
115
+ | `google/codegemma-7b-it` | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
116
+ | `google/gemma-2-9b-it` | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
117
+ | `microsoft/WizardLM-2-8x22B` | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
118
+
119
+ <Note>
120
+ The table above lists popular models. Please see the [DeepInfra
121
+ docs](https://deepinfra.com) for a full list of available models. You can also
122
+ pass any available provider model ID as a string if needed.
123
+ </Note>
124
+
125
+ ## Image Models
126
+
127
+ You can create DeepInfra image models using the `.image()` factory method.
128
+ For more on image generation with the AI SDK see [generateImage()](/docs/reference/ai-sdk-core/generate-image).
129
+
130
+ ```ts
131
+ import { deepinfra } from '@ai-sdk/deepinfra';
132
+ import { generateImage } from 'ai';
133
+
134
+ const { image } = await generateImage({
135
+ model: deepinfra.image('stabilityai/sd3.5'),
136
+ prompt: 'A futuristic cityscape at sunset',
137
+ aspectRatio: '16:9',
138
+ });
139
+ ```
140
+
141
+ <Note>
142
+ Model support for `size` and `aspectRatio` parameters varies by model. Please
143
+ check the individual model documentation on [DeepInfra's models
144
+ page](https://deepinfra.com/models/text-to-image) for supported options and
145
+ additional parameters.
146
+ </Note>
147
+
148
+ ### Model-specific options
149
+
150
+ You can pass model-specific parameters using the `providerOptions.deepinfra` field:
151
+
152
+ ```ts
153
+ import { deepinfra } from '@ai-sdk/deepinfra';
154
+ import { generateImage } from 'ai';
155
+
156
+ const { image } = await generateImage({
157
+ model: deepinfra.image('stabilityai/sd3.5'),
158
+ prompt: 'A futuristic cityscape at sunset',
159
+ aspectRatio: '16:9',
160
+ providerOptions: {
161
+ deepinfra: {
162
+ num_inference_steps: 30, // Control the number of denoising steps (1-50)
163
+ },
164
+ },
165
+ });
166
+ ```
167
+
168
+ ### Image Editing
169
+
170
+ DeepInfra supports image editing through models like `Qwen/Qwen-Image-Edit`. Pass input images via `prompt.images` to transform or edit existing images.
171
+
172
+ #### Basic Image Editing
173
+
174
+ Transform an existing image using text prompts:
175
+
176
+ ```ts
177
+ const imageBuffer = readFileSync('./input-image.png');
178
+
179
+ const { images } = await generateImage({
180
+ model: deepinfra.image('Qwen/Qwen-Image-Edit'),
181
+ prompt: {
182
+ text: 'Turn the cat into a golden retriever dog',
183
+ images: [imageBuffer],
184
+ },
185
+ size: '1024x1024',
186
+ });
187
+ ```
188
+
189
+ #### Inpainting with Mask
190
+
191
+ Edit specific parts of an image using a mask. Transparent areas in the mask indicate where the image should be edited:
192
+
193
+ ```ts
194
+ const image = readFileSync('./input-image.png');
195
+ const mask = readFileSync('./mask.png');
196
+
197
+ const { images } = await generateImage({
198
+ model: deepinfra.image('Qwen/Qwen-Image-Edit'),
199
+ prompt: {
200
+ text: 'A sunlit indoor lounge area with a pool containing a flamingo',
201
+ images: [image],
202
+ mask: mask,
203
+ },
204
+ });
205
+ ```
206
+
207
+ #### Multi-Image Combining
208
+
209
+ Combine multiple reference images into a single output:
210
+
211
+ ```ts
212
+ const cat = readFileSync('./cat.png');
213
+ const dog = readFileSync('./dog.png');
214
+
215
+ const { images } = await generateImage({
216
+ model: deepinfra.image('Qwen/Qwen-Image-Edit'),
217
+ prompt: {
218
+ text: 'Create a scene with both animals together, playing as friends',
219
+ images: [cat, dog],
220
+ },
221
+ });
222
+ ```
223
+
224
+ <Note>
225
+ Input images can be provided as `Buffer`, `ArrayBuffer`, `Uint8Array`, or
226
+ base64-encoded strings. DeepInfra uses an OpenAI-compatible image editing API
227
+ at `https://api.deepinfra.com/v1/openai/images/edits`.
228
+ </Note>
229
+
230
+ ### Model Capabilities
231
+
232
+ For models supporting aspect ratios, the following ratios are typically supported:
233
+ `1:1 (default), 16:9, 1:9, 3:2, 2:3, 4:5, 5:4, 9:16, 9:21`
234
+
235
+ For models supporting size parameters, dimensions must typically be:
236
+
237
+ - Multiples of 32
238
+ - Width and height between 256 and 1440 pixels
239
+ - Default size is 1024x1024
240
+
241
+ | Model | Dimensions Specification | Notes |
242
+ | ---------------------------------- | ------------------------ | -------------------------------------------------------- |
243
+ | `stabilityai/sd3.5` | Aspect Ratio | Premium quality base model, 8B parameters |
244
+ | `black-forest-labs/FLUX-1.1-pro` | Size | Latest state-of-art model with superior prompt following |
245
+ | `black-forest-labs/FLUX-1-schnell` | Size | Fast generation in 1-4 steps |
246
+ | `black-forest-labs/FLUX-1-dev` | Size | Optimized for anatomical accuracy |
247
+ | `black-forest-labs/FLUX-pro` | Size | Flagship Flux model |
248
+ | `stabilityai/sd3.5-medium` | Aspect Ratio | Balanced 2.5B parameter model |
249
+ | `stabilityai/sdxl-turbo` | Aspect Ratio | Optimized for fast generation |
250
+
251
+ For more details and pricing information, see the [DeepInfra text-to-image models page](https://deepinfra.com/models/text-to-image).
252
+
253
+ ## Embedding Models
254
+
255
+ You can create DeepInfra embedding models using the `.embedding()` factory method.
256
+ For more on embedding models with the AI SDK see [embed()](/docs/reference/ai-sdk-core/embed).
257
+
258
+ ```ts
259
+ import { deepinfra } from '@ai-sdk/deepinfra';
260
+ import { embed } from 'ai';
261
+
262
+ const { embedding } = await embed({
263
+ model: deepinfra.embedding('BAAI/bge-large-en-v1.5'),
264
+ value: 'sunny day at the beach',
265
+ });
266
+ ```
267
+
268
+ ### Model Capabilities
269
+
270
+ | Model | Dimensions | Max Tokens |
271
+ | ----------------------------------------------------- | ---------- | ---------- |
272
+ | `BAAI/bge-base-en-v1.5` | 768 | 512 |
273
+ | `BAAI/bge-large-en-v1.5` | 1024 | 512 |
274
+ | `BAAI/bge-m3` | 1024 | 8192 |
275
+ | `intfloat/e5-base-v2` | 768 | 512 |
276
+ | `intfloat/e5-large-v2` | 1024 | 512 |
277
+ | `intfloat/multilingual-e5-large` | 1024 | 512 |
278
+ | `sentence-transformers/all-MiniLM-L12-v2` | 384 | 256 |
279
+ | `sentence-transformers/all-MiniLM-L6-v2` | 384 | 256 |
280
+ | `sentence-transformers/all-mpnet-base-v2` | 768 | 384 |
281
+ | `sentence-transformers/clip-ViT-B-32` | 512 | 77 |
282
+ | `sentence-transformers/clip-ViT-B-32-multilingual-v1` | 512 | 77 |
283
+ | `sentence-transformers/multi-qa-mpnet-base-dot-v1` | 768 | 512 |
284
+ | `sentence-transformers/paraphrase-MiniLM-L6-v2` | 384 | 128 |
285
+ | `shibing624/text2vec-base-chinese` | 768 | 512 |
286
+ | `thenlper/gte-base` | 768 | 512 |
287
+ | `thenlper/gte-large` | 1024 | 512 |
288
+
289
+ <Note>
290
+ For a complete list of available embedding models, see the [DeepInfra
291
+ embeddings page](https://deepinfra.com/models/embeddings).
292
+ </Note>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/deepinfra",
3
- "version": "2.0.17",
3
+ "version": "2.0.18",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -8,10 +8,14 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
10
  "dist/**/*",
11
+ "docs/**/*",
11
12
  "src",
12
13
  "CHANGELOG.md",
13
14
  "README.md"
14
15
  ],
16
+ "directories": {
17
+ "doc": "./docs"
18
+ },
15
19
  "exports": {
16
20
  "./package.json": "./package.json",
17
21
  ".": {
@@ -56,7 +60,7 @@
56
60
  "scripts": {
57
61
  "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
58
62
  "build:watch": "pnpm clean && tsup --watch",
59
- "clean": "del-cli dist *.tsbuildinfo",
63
+ "clean": "del-cli dist docs *.tsbuildinfo",
60
64
  "lint": "eslint \"./**/*.ts*\"",
61
65
  "type-check": "tsc --build",
62
66
  "prettier-check": "prettier --check \"./**/*.ts*\"",