@ai-sdk/deepinfra 3.0.0-beta.9 → 3.0.0-canary.37

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.
@@ -29,10 +29,10 @@ The DeepInfra provider is available via the `@ai-sdk/deepinfra` module. You can
29
29
 
30
30
  ## Provider Instance
31
31
 
32
- You can import the default provider instance `deepinfra` from `@ai-sdk/deepinfra`:
32
+ You can import the default provider instance `deepInfra` from `@ai-sdk/deepinfra`:
33
33
 
34
34
  ```ts
35
- import { deepinfra } from '@ai-sdk/deepinfra';
35
+ import { deepInfra } from '@ai-sdk/deepinfra';
36
36
  ```
37
37
 
38
38
  If you need a customized setup, you can import `createDeepInfra` from `@ai-sdk/deepinfra` and create a provider instance with your settings:
@@ -40,7 +40,7 @@ If you need a customized setup, you can import `createDeepInfra` from `@ai-sdk/d
40
40
  ```ts
41
41
  import { createDeepInfra } from '@ai-sdk/deepinfra';
42
42
 
43
- const deepinfra = createDeepInfra({
43
+ const deepInfra = createDeepInfra({
44
44
  apiKey: process.env.DEEPINFRA_API_KEY ?? '',
45
45
  });
46
46
  ```
@@ -76,11 +76,11 @@ You can use the following optional settings to customize the DeepInfra provider
76
76
  You can create language models using a provider instance. The first argument is the model ID, for example:
77
77
 
78
78
  ```ts
79
- import { deepinfra } from '@ai-sdk/deepinfra';
79
+ import { deepInfra } from '@ai-sdk/deepinfra';
80
80
  import { generateText } from 'ai';
81
81
 
82
82
  const { text } = await generateText({
83
- model: deepinfra('meta-llama/Meta-Llama-3.1-70B-Instruct'),
83
+ model: deepInfra('meta-llama/Meta-Llama-3.1-70B-Instruct'),
84
84
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
85
85
  });
86
86
  ```
@@ -128,11 +128,11 @@ You can create DeepInfra image models using the `.image()` factory method.
128
128
  For more on image generation with the AI SDK see [generateImage()](/docs/reference/ai-sdk-core/generate-image).
129
129
 
130
130
  ```ts
131
- import { deepinfra } from '@ai-sdk/deepinfra';
131
+ import { deepInfra } from '@ai-sdk/deepinfra';
132
132
  import { generateImage } from 'ai';
133
133
 
134
134
  const { image } = await generateImage({
135
- model: deepinfra.image('stabilityai/sd3.5'),
135
+ model: deepInfra.image('stabilityai/sd3.5'),
136
136
  prompt: 'A futuristic cityscape at sunset',
137
137
  aspectRatio: '16:9',
138
138
  });
@@ -150,11 +150,11 @@ const { image } = await generateImage({
150
150
  You can pass model-specific parameters using the `providerOptions.deepinfra` field:
151
151
 
152
152
  ```ts
153
- import { deepinfra } from '@ai-sdk/deepinfra';
153
+ import { deepInfra } from '@ai-sdk/deepinfra';
154
154
  import { generateImage } from 'ai';
155
155
 
156
156
  const { image } = await generateImage({
157
- model: deepinfra.image('stabilityai/sd3.5'),
157
+ model: deepInfra.image('stabilityai/sd3.5'),
158
158
  prompt: 'A futuristic cityscape at sunset',
159
159
  aspectRatio: '16:9',
160
160
  providerOptions: {
@@ -177,7 +177,7 @@ Transform an existing image using text prompts:
177
177
  const imageBuffer = readFileSync('./input-image.png');
178
178
 
179
179
  const { images } = await generateImage({
180
- model: deepinfra.image('Qwen/Qwen-Image-Edit'),
180
+ model: deepInfra.image('Qwen/Qwen-Image-Edit'),
181
181
  prompt: {
182
182
  text: 'Turn the cat into a golden retriever dog',
183
183
  images: [imageBuffer],
@@ -195,7 +195,7 @@ const image = readFileSync('./input-image.png');
195
195
  const mask = readFileSync('./mask.png');
196
196
 
197
197
  const { images } = await generateImage({
198
- model: deepinfra.image('Qwen/Qwen-Image-Edit'),
198
+ model: deepInfra.image('Qwen/Qwen-Image-Edit'),
199
199
  prompt: {
200
200
  text: 'A sunlit indoor lounge area with a pool containing a flamingo',
201
201
  images: [image],
@@ -213,7 +213,7 @@ const cat = readFileSync('./cat.png');
213
213
  const dog = readFileSync('./dog.png');
214
214
 
215
215
  const { images } = await generateImage({
216
- model: deepinfra.image('Qwen/Qwen-Image-Edit'),
216
+ model: deepInfra.image('Qwen/Qwen-Image-Edit'),
217
217
  prompt: {
218
218
  text: 'Create a scene with both animals together, playing as friends',
219
219
  images: [cat, dog],
@@ -258,11 +258,11 @@ You can create DeepInfra embedding models using the `.embeddingModel()` factory
258
258
  For more on embedding models with the AI SDK see [embed()](/docs/reference/ai-sdk-core/embed).
259
259
 
260
260
  ```ts
261
- import { deepinfra } from '@ai-sdk/deepinfra';
261
+ import { deepInfra } from '@ai-sdk/deepinfra';
262
262
  import { embed } from 'ai';
263
263
 
264
264
  const { embedding } = await embed({
265
- model: deepinfra.embeddingModel('BAAI/bge-large-en-v1.5'),
265
+ model: deepInfra.embeddingModel('BAAI/bge-large-en-v1.5'),
266
266
  value: 'sunny day at the beach',
267
267
  });
268
268
  ```
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@ai-sdk/deepinfra",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0-canary.37",
4
+ "type": "module",
4
5
  "license": "Apache-2.0",
5
6
  "sideEffects": false,
6
7
  "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
8
8
  "types": "./dist/index.d.ts",
9
9
  "files": [
10
10
  "dist/**/*",
@@ -24,21 +24,21 @@
24
24
  "./package.json": "./package.json",
25
25
  ".": {
26
26
  "types": "./dist/index.d.ts",
27
- "import": "./dist/index.mjs",
28
- "require": "./dist/index.js"
27
+ "import": "./dist/index.js",
28
+ "default": "./dist/index.js"
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/openai-compatible": "3.0.0-beta.9",
33
- "@ai-sdk/provider": "4.0.0-beta.4",
34
- "@ai-sdk/provider-utils": "5.0.0-beta.6"
32
+ "@ai-sdk/openai-compatible": "3.0.0-canary.37",
33
+ "@ai-sdk/provider": "4.0.0-canary.15",
34
+ "@ai-sdk/provider-utils": "5.0.0-canary.31"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "20.17.24",
38
38
  "tsup": "^8",
39
39
  "typescript": "5.8.3",
40
40
  "zod": "3.25.76",
41
- "@ai-sdk/test-server": "2.0.0-beta.0",
41
+ "@ai-sdk/test-server": "2.0.0-canary.4",
42
42
  "@vercel/ai-tsconfig": "0.0.0"
43
43
  },
44
44
  "peerDependencies": {
@@ -48,12 +48,14 @@
48
48
  "node": ">=18"
49
49
  },
50
50
  "publishConfig": {
51
- "access": "public"
51
+ "access": "public",
52
+ "provenance": true
52
53
  },
53
54
  "homepage": "https://ai-sdk.dev/docs",
54
55
  "repository": {
55
56
  "type": "git",
56
- "url": "git+https://github.com/vercel/ai.git"
57
+ "url": "https://github.com/vercel/ai",
58
+ "directory": "packages/deepinfra"
57
59
  },
58
60
  "bugs": {
59
61
  "url": "https://github.com/vercel/ai/issues"
@@ -1,19 +1,37 @@
1
- import {
1
+ import type {
2
2
  LanguageModelV4CallOptions,
3
3
  LanguageModelV4GenerateResult,
4
4
  LanguageModelV4StreamResult,
5
5
  } from '@ai-sdk/provider';
6
6
  import { OpenAICompatibleChatLanguageModel } from '@ai-sdk/openai-compatible';
7
- import { FetchFunction } from '@ai-sdk/provider-utils';
8
-
7
+ import {
8
+ serializeModelOptions,
9
+ WORKFLOW_SERIALIZE,
10
+ WORKFLOW_DESERIALIZE,
11
+ type FetchFunction,
12
+ } from '@ai-sdk/provider-utils';
9
13
  type DeepInfraChatConfig = {
10
14
  provider: string;
11
15
  url: (options: { path: string; modelId?: string }) => string;
12
- headers: () => Record<string, string | undefined>;
16
+ headers?: () => Record<string, string | undefined>;
13
17
  fetch?: FetchFunction;
14
18
  };
15
19
 
16
20
  export class DeepInfraChatLanguageModel extends OpenAICompatibleChatLanguageModel {
21
+ static [WORKFLOW_SERIALIZE](model: DeepInfraChatLanguageModel) {
22
+ return serializeModelOptions({
23
+ modelId: model.modelId,
24
+ config: model.config,
25
+ });
26
+ }
27
+
28
+ static [WORKFLOW_DESERIALIZE](options: {
29
+ modelId: string;
30
+ config: DeepInfraChatConfig;
31
+ }) {
32
+ return new DeepInfraChatLanguageModel(options.modelId, options.config);
33
+ }
34
+
17
35
  constructor(modelId: string, config: DeepInfraChatConfig) {
18
36
  super(modelId, config);
19
37
  }
@@ -1,4 +1,4 @@
1
- import { DeepInfraChatModelId } from './deepinfra-chat-options';
1
+ import type { DeepInfraChatModelId } from './deepinfra-chat-options';
2
2
 
3
3
  // Use the same model IDs as chat
4
4
  export type DeepInfraCompletionModelId = DeepInfraChatModelId;
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  ImageModelV4,
3
3
  ImageModelV4File,
4
4
  SharedV4Warning,
@@ -10,17 +10,20 @@ import {
10
10
  createJsonErrorResponseHandler,
11
11
  createJsonResponseHandler,
12
12
  downloadBlob,
13
- FetchFunction,
14
13
  postFormDataToApi,
15
14
  postJsonToApi,
15
+ serializeModelOptions,
16
+ WORKFLOW_SERIALIZE,
17
+ WORKFLOW_DESERIALIZE,
18
+ type FetchFunction,
16
19
  } from '@ai-sdk/provider-utils';
17
- import { DeepInfraImageModelId } from './deepinfra-image-settings';
20
+ import type { DeepInfraImageModelId } from './deepinfra-image-settings';
18
21
  import { z } from 'zod/v4';
19
22
 
20
23
  interface DeepInfraImageModelConfig {
21
24
  provider: string;
22
25
  baseURL: string;
23
- headers: () => Record<string, string>;
26
+ headers?: () => Record<string, string>;
24
27
  fetch?: FetchFunction;
25
28
  _internal?: {
26
29
  currentDate?: () => Date;
@@ -35,6 +38,20 @@ export class DeepInfraImageModel implements ImageModelV4 {
35
38
  return this.config.provider;
36
39
  }
37
40
 
41
+ static [WORKFLOW_SERIALIZE](model: DeepInfraImageModel) {
42
+ return serializeModelOptions({
43
+ modelId: model.modelId,
44
+ config: model.config,
45
+ });
46
+ }
47
+
48
+ static [WORKFLOW_DESERIALIZE](options: {
49
+ modelId: DeepInfraImageModelId;
50
+ config: DeepInfraImageModelConfig;
51
+ }) {
52
+ return new DeepInfraImageModel(options.modelId, options.config);
53
+ }
54
+
38
55
  constructor(
39
56
  readonly modelId: DeepInfraImageModelId,
40
57
  private config: DeepInfraImageModelConfig,
@@ -61,7 +78,7 @@ export class DeepInfraImageModel implements ImageModelV4 {
61
78
  if (files != null && files.length > 0) {
62
79
  const { value: response, responseHeaders } = await postFormDataToApi({
63
80
  url: this.getEditUrl(),
64
- headers: combineHeaders(this.config.headers(), headers),
81
+ headers: combineHeaders(this.config.headers?.(), headers),
65
82
  formData: convertToFormData<DeepInfraFormDataInput>(
66
83
  {
67
84
  model: this.modelId,
@@ -102,7 +119,7 @@ export class DeepInfraImageModel implements ImageModelV4 {
102
119
  const splitSize = size?.split('x');
103
120
  const { value: response, responseHeaders } = await postJsonToApi({
104
121
  url: `${this.config.baseURL}/${this.modelId}`,
105
- headers: combineHeaders(this.config.headers(), headers),
122
+ headers: combineHeaders(this.config.headers?.(), headers),
106
123
  body: {
107
124
  prompt,
108
125
  num_images: n,
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  LanguageModelV4,
3
3
  EmbeddingModelV4,
4
4
  ProviderV4,
@@ -9,15 +9,15 @@ import {
9
9
  OpenAICompatibleEmbeddingModel,
10
10
  } from '@ai-sdk/openai-compatible';
11
11
  import {
12
- FetchFunction,
13
12
  loadApiKey,
14
13
  withoutTrailingSlash,
15
14
  withUserAgentSuffix,
15
+ type FetchFunction,
16
16
  } from '@ai-sdk/provider-utils';
17
- import { DeepInfraChatModelId } from './deepinfra-chat-options';
18
- import { DeepInfraEmbeddingModelId } from './deepinfra-embedding-options';
19
- import { DeepInfraCompletionModelId } from './deepinfra-completion-options';
20
- import { DeepInfraImageModelId } from './deepinfra-image-settings';
17
+ import type { DeepInfraChatModelId } from './deepinfra-chat-options';
18
+ import type { DeepInfraEmbeddingModelId } from './deepinfra-embedding-options';
19
+ import type { DeepInfraCompletionModelId } from './deepinfra-completion-options';
20
+ import type { DeepInfraImageModelId } from './deepinfra-image-settings';
21
21
  import { DeepInfraImageModel } from './deepinfra-image-model';
22
22
  import { DeepInfraChatLanguageModel } from './deepinfra-chat-language-model';
23
23
  import { VERSION } from './version';
@@ -158,4 +158,4 @@ export function createDeepInfra(
158
158
  return provider;
159
159
  }
160
160
 
161
- export const deepinfra = createDeepInfra();
161
+ export const deepInfra = createDeepInfra();
package/src/index.ts CHANGED
@@ -1,4 +1,9 @@
1
- export { createDeepInfra, deepinfra } from './deepinfra-provider';
1
+ export {
2
+ createDeepInfra,
3
+ deepInfra,
4
+ /** @deprecated Use `deepInfra` instead. */
5
+ deepInfra as deepinfra,
6
+ } from './deepinfra-provider';
2
7
  export type {
3
8
  DeepInfraProvider,
4
9
  DeepInfraProviderSettings,
package/dist/index.d.mts DELETED
@@ -1,71 +0,0 @@
1
- import { ProviderV4, LanguageModelV4, ImageModelV4, EmbeddingModelV4 } from '@ai-sdk/provider';
2
- import { FetchFunction } from '@ai-sdk/provider-utils';
3
- export { OpenAICompatibleErrorData as DeepInfraErrorData } from '@ai-sdk/openai-compatible';
4
-
5
- type DeepInfraChatModelId = '01-ai/Yi-34B-Chat' | 'Austism/chronos-hermes-13b-v2' | 'bigcode/starcoder2-15b-instruct-v0.1' | 'bigcode/starcoder2-15b' | 'codellama/CodeLlama-34b-Instruct-hf' | 'codellama/CodeLlama-70b-Instruct-hf' | 'cognitivecomputations/dolphin-2.6-mixtral-8x7b' | 'cognitivecomputations/dolphin-2.9.1-llama-3-70b' | 'databricks/dbrx-instruct' | 'deepinfra/airoboros-70b' | 'deepseek-ai/DeepSeek-V3' | 'google/codegemma-7b-it' | 'google/gemma-1.1-7b-it' | 'google/gemma-2-27b-it' | 'google/gemma-2-9b-it' | 'Gryphe/MythoMax-L2-13b-turbo' | 'Gryphe/MythoMax-L2-13b' | 'HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1' | 'KoboldAI/LLaMA2-13B-Tiefighter' | 'lizpreciatior/lzlv_70b_fp16_hf' | 'mattshumer/Reflection-Llama-3.1-70B' | 'meta-llama/Llama-2-13b-chat-hf' | 'meta-llama/Llama-2-70b-chat-hf' | 'meta-llama/Llama-2-7b-chat-hf' | 'meta-llama/Llama-3.2-11B-Vision-Instruct' | 'meta-llama/Llama-3.2-1B-Instruct' | 'meta-llama/Llama-3.2-3B-Instruct' | 'meta-llama/Llama-3.2-90B-Vision-Instruct' | 'meta-llama/Llama-3.3-70B-Instruct-Turbo' | 'meta-llama/Llama-3.3-70B-Instruct' | 'meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8' | 'meta-llama/Llama-4-Scout-17B-16E-Instruct' | 'meta-llama/Meta-Llama-3-70B-Instruct' | 'meta-llama/Meta-Llama-3-8B-Instruct' | 'meta-llama/Meta-Llama-3.1-405B-Instruct' | 'meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo' | 'meta-llama/Meta-Llama-3.1-70B-Instruct' | 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo' | 'meta-llama/Meta-Llama-3.1-8B-Instruct' | 'microsoft/Phi-3-medium-4k-instruct' | 'microsoft/WizardLM-2-7B' | 'microsoft/WizardLM-2-8x22B' | 'mistralai/Mistral-7B-Instruct-v0.1' | 'mistralai/Mistral-7B-Instruct-v0.2' | 'mistralai/Mistral-7B-Instruct-v0.3' | 'mistralai/Mistral-Nemo-Instruct-2407' | 'mistralai/Mixtral-8x22B-Instruct-v0.1' | 'mistralai/Mixtral-8x22B-v0.1' | 'mistralai/Mixtral-8x7B-Instruct-v0.1' | 'NousResearch/Hermes-3-Llama-3.1-405B' | 'nvidia/Llama-3.1-Nemotron-70B-Instruct' | 'nvidia/Nemotron-4-340B-Instruct' | 'openbmb/MiniCPM-Llama3-V-2_5' | 'openchat/openchat_3.5' | 'openchat/openchat-3.6-8b' | 'Phind/Phind-CodeLlama-34B-v2' | 'Qwen/Qwen2-72B-Instruct' | 'Qwen/Qwen2-7B-Instruct' | 'Qwen/Qwen2.5-72B-Instruct' | 'Qwen/Qwen2.5-7B-Instruct' | 'Qwen/Qwen2.5-Coder-32B-Instruct' | 'Qwen/Qwen2.5-Coder-7B' | 'Qwen/QwQ-32B-Preview' | 'Sao10K/L3-70B-Euryale-v2.1' | 'Sao10K/L3-8B-Lunaris-v1' | 'Sao10K/L3.1-70B-Euryale-v2.2' | (string & {});
6
-
7
- type DeepInfraEmbeddingModelId = 'BAAI/bge-base-en-v1.5' | 'BAAI/bge-large-en-v1.5' | 'BAAI/bge-m3' | 'intfloat/e5-base-v2' | 'intfloat/e5-large-v2' | 'intfloat/multilingual-e5-large' | 'sentence-transformers/all-MiniLM-L12-v2' | 'sentence-transformers/all-MiniLM-L6-v2' | 'sentence-transformers/all-mpnet-base-v2' | 'sentence-transformers/clip-ViT-B-32' | 'sentence-transformers/clip-ViT-B-32-multilingual-v1' | 'sentence-transformers/multi-qa-mpnet-base-dot-v1' | 'sentence-transformers/paraphrase-MiniLM-L6-v2' | 'shibing624/text2vec-base-chinese' | 'thenlper/gte-base' | 'thenlper/gte-large' | (string & {});
8
-
9
- type DeepInfraCompletionModelId = DeepInfraChatModelId;
10
-
11
- type DeepInfraImageModelId = 'stabilityai/sd3.5' | 'black-forest-labs/FLUX-1.1-pro' | 'black-forest-labs/FLUX-1-schnell' | 'black-forest-labs/FLUX-1-dev' | 'black-forest-labs/FLUX-pro' | 'black-forest-labs/FLUX.1-Kontext-dev' | 'black-forest-labs/FLUX.1-Kontext-pro' | 'stabilityai/sd3.5-medium' | 'stabilityai/sdxl-turbo' | (string & {});
12
-
13
- interface DeepInfraProviderSettings {
14
- /**
15
- * DeepInfra API key.
16
- */
17
- apiKey?: string;
18
- /**
19
- * Base URL for the API calls.
20
- */
21
- baseURL?: string;
22
- /**
23
- * Custom headers to include in the requests.
24
- */
25
- headers?: Record<string, string>;
26
- /**
27
- * Custom fetch implementation. You can use it as a middleware to intercept requests,
28
- * or to provide a custom fetch implementation for e.g. testing.
29
- */
30
- fetch?: FetchFunction;
31
- }
32
- interface DeepInfraProvider extends ProviderV4 {
33
- /**
34
- * Creates a model for text generation.
35
- */
36
- (modelId: DeepInfraChatModelId): LanguageModelV4;
37
- /**
38
- * Creates a chat model for text generation.
39
- */
40
- chatModel(modelId: DeepInfraChatModelId): LanguageModelV4;
41
- /**
42
- * Creates a model for image generation.
43
- */
44
- image(modelId: DeepInfraImageModelId): ImageModelV4;
45
- /**
46
- * Creates a model for image generation.
47
- */
48
- imageModel(modelId: DeepInfraImageModelId): ImageModelV4;
49
- /**
50
- * Creates a chat model for text generation.
51
- */
52
- languageModel(modelId: DeepInfraChatModelId): LanguageModelV4;
53
- /**
54
- * Creates a completion model for text generation.
55
- */
56
- completionModel(modelId: DeepInfraCompletionModelId): LanguageModelV4;
57
- /**
58
- * Creates a embedding model for text generation.
59
- */
60
- embeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV4;
61
- /**
62
- * @deprecated Use `embeddingModel` instead.
63
- */
64
- textEmbeddingModel(modelId: DeepInfraEmbeddingModelId): EmbeddingModelV4;
65
- }
66
- declare function createDeepInfra(options?: DeepInfraProviderSettings): DeepInfraProvider;
67
- declare const deepinfra: DeepInfraProvider;
68
-
69
- declare const VERSION: string;
70
-
71
- export { type DeepInfraProvider, type DeepInfraProviderSettings, VERSION, createDeepInfra, deepinfra };