@ai-sdk/openai-compatible 3.0.59 → 3.0.61
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 +18 -0
- package/dist/index.d.ts +342 -330
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1419 -1834
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +176 -168
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +254 -346
- package/dist/internal/index.js.map +1 -1
- package/docs/index.mdx +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,390 +1,402 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { EmbeddingModelV4, ImageModelV4, LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, LanguageModelV4Usage, ProviderV4, SharedV4ProviderMetadata } from "@ai-sdk/provider";
|
|
2
|
+
import { FetchFunction, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE } from "@ai-sdk/provider-utils";
|
|
3
|
+
import { ZodType, z } from "zod/v4";
|
|
4
|
+
//#region src/openai-compatible-error.d.ts
|
|
6
5
|
declare const openaiCompatibleErrorDataSchema: z.ZodObject<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
error: z.ZodObject<{
|
|
7
|
+
message: z.ZodString;
|
|
8
|
+
type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
|
+
param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
10
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
13
12
|
}, z.core.$strip>;
|
|
14
13
|
type OpenAICompatibleErrorData = z.infer<typeof openaiCompatibleErrorDataSchema>;
|
|
15
14
|
type ProviderErrorStructure<T> = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
errorSchema: ZodType<T>;
|
|
16
|
+
errorToMessage: (error: T) => string;
|
|
17
|
+
isRetryable?: (response: Response, error?: T) => boolean;
|
|
19
18
|
};
|
|
20
|
-
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/chat/openai-compatible-chat-language-model-options.d.ts
|
|
21
21
|
type OpenAICompatibleChatModelId = string;
|
|
22
22
|
declare const openaiCompatibleLanguageModelChatOptions: z.ZodObject<{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
user: z.ZodOptional<z.ZodString>;
|
|
24
|
+
reasoningEffort: z.ZodOptional<z.ZodString>;
|
|
25
|
+
textVerbosity: z.ZodOptional<z.ZodString>;
|
|
26
|
+
strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
|
|
27
27
|
}, z.core.$strip>;
|
|
28
28
|
type OpenAICompatibleLanguageModelChatOptions = z.infer<typeof openaiCompatibleLanguageModelChatOptions>;
|
|
29
|
-
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/chat/openai-compatible-metadata-extractor.d.ts
|
|
30
31
|
/**
|
|
31
32
|
* Extracts provider-specific metadata from API responses.
|
|
32
33
|
* Used to standardize metadata handling across different LLM providers while allowing
|
|
33
34
|
* provider-specific metadata to be captured.
|
|
34
35
|
*/
|
|
35
36
|
type MetadataExtractor = {
|
|
37
|
+
/**
|
|
38
|
+
* Extracts provider metadata from a complete, non-streaming response.
|
|
39
|
+
*
|
|
40
|
+
* @param parsedBody - The parsed response JSON body from the provider's API.
|
|
41
|
+
*
|
|
42
|
+
* @returns Provider-specific metadata or undefined if no metadata is available.
|
|
43
|
+
* The metadata should be under a key indicating the provider id.
|
|
44
|
+
*/
|
|
45
|
+
extractMetadata: ({ parsedBody }: {
|
|
46
|
+
parsedBody: unknown;
|
|
47
|
+
}) => Promise<SharedV4ProviderMetadata | undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* Creates an extractor for handling streaming responses. The returned object provides
|
|
50
|
+
* methods to process individual chunks and build the final metadata from the accumulated
|
|
51
|
+
* stream data.
|
|
52
|
+
*
|
|
53
|
+
* @returns An object with methods to process chunks and build metadata from a stream
|
|
54
|
+
*/
|
|
55
|
+
createStreamExtractor: () => {
|
|
36
56
|
/**
|
|
37
|
-
*
|
|
57
|
+
* Process an individual chunk from the stream. Called for each chunk in the response stream
|
|
58
|
+
* to accumulate metadata throughout the streaming process.
|
|
38
59
|
*
|
|
39
|
-
* @param
|
|
40
|
-
*
|
|
41
|
-
* @returns Provider-specific metadata or undefined if no metadata is available.
|
|
42
|
-
* The metadata should be under a key indicating the provider id.
|
|
60
|
+
* @param parsedChunk - The parsed JSON response chunk from the provider's API
|
|
43
61
|
*/
|
|
44
|
-
|
|
45
|
-
parsedBody: unknown;
|
|
46
|
-
}) => Promise<SharedV4ProviderMetadata | undefined>;
|
|
62
|
+
processChunk(parsedChunk: unknown): void;
|
|
47
63
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* stream data.
|
|
64
|
+
* Builds the metadata object after all chunks have been processed.
|
|
65
|
+
* Called at the end of the stream to generate the complete provider metadata.
|
|
51
66
|
*
|
|
52
|
-
* @returns
|
|
67
|
+
* @returns Provider-specific metadata or undefined if no metadata is available.
|
|
68
|
+
* The metadata should be under a key indicating the provider id.
|
|
53
69
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
* Process an individual chunk from the stream. Called for each chunk in the response stream
|
|
57
|
-
* to accumulate metadata throughout the streaming process.
|
|
58
|
-
*
|
|
59
|
-
* @param parsedChunk - The parsed JSON response chunk from the provider's API
|
|
60
|
-
*/
|
|
61
|
-
processChunk(parsedChunk: unknown): void;
|
|
62
|
-
/**
|
|
63
|
-
* Builds the metadata object after all chunks have been processed.
|
|
64
|
-
* Called at the end of the stream to generate the complete provider metadata.
|
|
65
|
-
*
|
|
66
|
-
* @returns Provider-specific metadata or undefined if no metadata is available.
|
|
67
|
-
* The metadata should be under a key indicating the provider id.
|
|
68
|
-
*/
|
|
69
|
-
buildMetadata(): SharedV4ProviderMetadata | undefined;
|
|
70
|
-
};
|
|
70
|
+
buildMetadata(): SharedV4ProviderMetadata | undefined;
|
|
71
|
+
};
|
|
71
72
|
};
|
|
72
|
-
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/chat/openai-compatible-chat-language-model.d.ts
|
|
73
75
|
type OpenAICompatibleChatConfig = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
76
|
+
provider: string;
|
|
77
|
+
headers?: () => Record<string, string | undefined>;
|
|
78
|
+
url: (options: {
|
|
79
|
+
modelId: string;
|
|
80
|
+
path: string;
|
|
81
|
+
}) => string;
|
|
82
|
+
fetch?: FetchFunction;
|
|
83
|
+
includeUsage?: boolean;
|
|
84
|
+
errorStructure?: ProviderErrorStructure<any>;
|
|
85
|
+
metadataExtractor?: MetadataExtractor;
|
|
86
|
+
/**
|
|
87
|
+
* Whether the model supports structured outputs.
|
|
88
|
+
*/
|
|
89
|
+
supportsStructuredOutputs?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The supported URLs for the model.
|
|
92
|
+
*/
|
|
93
|
+
supportedUrls?: () => LanguageModelV4['supportedUrls'];
|
|
94
|
+
/**
|
|
95
|
+
* Optional function to transform the request body before sending it to the API.
|
|
96
|
+
* This is useful for proxy providers that may require a different request format
|
|
97
|
+
* than the official OpenAI API.
|
|
98
|
+
*/
|
|
99
|
+
transformRequestBody?: (args: Record<string, any>) => Record<string, any>;
|
|
100
|
+
/**
|
|
101
|
+
* Optional usage converter for OpenAI-compatible providers with different
|
|
102
|
+
* token accounting semantics.
|
|
103
|
+
*/
|
|
104
|
+
convertUsage?: (usage: z.infer<typeof openaiCompatibleTokenUsageSchema>) => LanguageModelV4Usage;
|
|
103
105
|
};
|
|
104
|
-
declare class OpenAICompatibleChatLanguageModel implements LanguageModelV4 {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
106
|
+
export declare class OpenAICompatibleChatLanguageModel implements LanguageModelV4 {
|
|
107
|
+
readonly specificationVersion = "v4";
|
|
108
|
+
readonly supportsStructuredOutputs: boolean;
|
|
109
|
+
readonly modelId: OpenAICompatibleChatModelId;
|
|
110
|
+
protected readonly config: OpenAICompatibleChatConfig;
|
|
111
|
+
private readonly failedResponseHandler;
|
|
112
|
+
private readonly chunkSchema;
|
|
113
|
+
static [WORKFLOW_SERIALIZE](model: OpenAICompatibleChatLanguageModel): {
|
|
114
|
+
modelId: string;
|
|
115
|
+
config: import("@ai-sdk/provider").JSONObject;
|
|
116
|
+
};
|
|
117
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
118
|
+
modelId: string;
|
|
119
|
+
config: OpenAICompatibleChatConfig;
|
|
120
|
+
}): OpenAICompatibleChatLanguageModel;
|
|
121
|
+
constructor(modelId: OpenAICompatibleChatModelId, config: OpenAICompatibleChatConfig);
|
|
122
|
+
get provider(): string;
|
|
123
|
+
private get providerOptionsName();
|
|
124
|
+
get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
|
|
125
|
+
private transformRequestBody;
|
|
126
|
+
private convertUsage;
|
|
127
|
+
private getArgs;
|
|
128
|
+
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
129
|
+
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
128
130
|
}
|
|
129
131
|
declare const openaiCompatibleTokenUsageSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
132
|
+
prompt_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
133
|
+
completion_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
134
|
+
total_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
135
|
+
prompt_tokens_details: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
136
|
+
cached_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
137
|
+
}, z.core.$loose>>>;
|
|
138
|
+
completion_tokens_details: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
139
|
+
reasoning_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
140
|
+
accepted_prediction_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
141
|
+
rejected_prediction_tokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
142
|
+
}, z.core.$loose>>>;
|
|
141
143
|
}, z.core.$loose>>>;
|
|
142
|
-
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/completion/openai-compatible-completion-language-model-options.d.ts
|
|
143
146
|
type OpenAICompatibleCompletionModelId = string;
|
|
144
147
|
declare const openaiCompatibleLanguageModelCompletionOptions: z.ZodObject<{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
echo: z.ZodOptional<z.ZodBoolean>;
|
|
149
|
+
logitBias: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
150
|
+
suffix: z.ZodOptional<z.ZodString>;
|
|
151
|
+
user: z.ZodOptional<z.ZodString>;
|
|
149
152
|
}, z.core.$strip>;
|
|
150
153
|
type OpenAICompatibleLanguageModelCompletionOptions = z.infer<typeof openaiCompatibleLanguageModelCompletionOptions>;
|
|
151
|
-
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/completion/openai-compatible-completion-language-model.d.ts
|
|
152
156
|
type OpenAICompatibleCompletionConfig = {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
157
|
+
provider: string;
|
|
158
|
+
includeUsage?: boolean;
|
|
159
|
+
headers?: () => Record<string, string | undefined>;
|
|
160
|
+
url: (options: {
|
|
161
|
+
modelId: string;
|
|
162
|
+
path: string;
|
|
163
|
+
}) => string;
|
|
164
|
+
fetch?: FetchFunction;
|
|
165
|
+
errorStructure?: ProviderErrorStructure<any>;
|
|
166
|
+
/**
|
|
167
|
+
* The supported URLs for the model.
|
|
168
|
+
*/
|
|
169
|
+
supportedUrls?: () => LanguageModelV4['supportedUrls'];
|
|
166
170
|
};
|
|
167
|
-
declare class OpenAICompatibleCompletionLanguageModel implements LanguageModelV4 {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
171
|
+
export declare class OpenAICompatibleCompletionLanguageModel implements LanguageModelV4 {
|
|
172
|
+
readonly specificationVersion = "v4";
|
|
173
|
+
readonly modelId: OpenAICompatibleCompletionModelId;
|
|
174
|
+
private readonly config;
|
|
175
|
+
private readonly failedResponseHandler;
|
|
176
|
+
private readonly chunkSchema;
|
|
177
|
+
static [WORKFLOW_SERIALIZE](model: OpenAICompatibleCompletionLanguageModel): {
|
|
178
|
+
modelId: string;
|
|
179
|
+
config: import("@ai-sdk/provider").JSONObject;
|
|
180
|
+
};
|
|
181
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
182
|
+
modelId: string;
|
|
183
|
+
config: OpenAICompatibleCompletionConfig;
|
|
184
|
+
}): OpenAICompatibleCompletionLanguageModel;
|
|
185
|
+
constructor(modelId: OpenAICompatibleCompletionModelId, config: OpenAICompatibleCompletionConfig);
|
|
186
|
+
get provider(): string;
|
|
187
|
+
private get providerOptionsName();
|
|
188
|
+
get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
|
|
189
|
+
private getArgs;
|
|
190
|
+
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
191
|
+
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
188
192
|
}
|
|
189
|
-
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/embedding/openai-compatible-embedding-model-options.d.ts
|
|
190
195
|
type OpenAICompatibleEmbeddingModelId = string;
|
|
191
196
|
declare const openaiCompatibleEmbeddingModelOptions: z.ZodObject<{
|
|
192
|
-
|
|
193
|
-
|
|
197
|
+
dimensions: z.ZodOptional<z.ZodNumber>;
|
|
198
|
+
user: z.ZodOptional<z.ZodString>;
|
|
194
199
|
}, z.core.$strip>;
|
|
195
200
|
type OpenAICompatibleEmbeddingModelOptions = z.infer<typeof openaiCompatibleEmbeddingModelOptions>;
|
|
196
|
-
|
|
201
|
+
//#endregion
|
|
202
|
+
//#region src/embedding/openai-compatible-embedding-model.d.ts
|
|
197
203
|
type OpenAICompatibleEmbeddingConfig = {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Override the maximum number of embeddings per call.
|
|
206
|
+
*/
|
|
207
|
+
maxEmbeddingsPerCall?: number;
|
|
208
|
+
/**
|
|
209
|
+
* Override the parallelism of embedding calls.
|
|
210
|
+
*/
|
|
211
|
+
supportsParallelCalls?: boolean;
|
|
212
|
+
provider: string;
|
|
213
|
+
url: (options: {
|
|
214
|
+
modelId: string;
|
|
215
|
+
path: string;
|
|
216
|
+
}) => string;
|
|
217
|
+
headers?: () => Record<string, string | undefined>;
|
|
218
|
+
fetch?: FetchFunction;
|
|
219
|
+
errorStructure?: ProviderErrorStructure<any>;
|
|
214
220
|
};
|
|
215
|
-
declare class OpenAICompatibleEmbeddingModel implements EmbeddingModelV4 {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
221
|
+
export declare class OpenAICompatibleEmbeddingModel implements EmbeddingModelV4 {
|
|
222
|
+
readonly specificationVersion = "v4";
|
|
223
|
+
readonly modelId: OpenAICompatibleEmbeddingModelId;
|
|
224
|
+
private readonly config;
|
|
225
|
+
get provider(): string;
|
|
226
|
+
get maxEmbeddingsPerCall(): number;
|
|
227
|
+
get supportsParallelCalls(): boolean;
|
|
228
|
+
static [WORKFLOW_SERIALIZE](model: OpenAICompatibleEmbeddingModel): {
|
|
229
|
+
modelId: string;
|
|
230
|
+
config: import("@ai-sdk/provider").JSONObject;
|
|
231
|
+
};
|
|
232
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
233
|
+
modelId: string;
|
|
234
|
+
config: OpenAICompatibleEmbeddingConfig;
|
|
235
|
+
}): OpenAICompatibleEmbeddingModel;
|
|
236
|
+
constructor(modelId: OpenAICompatibleEmbeddingModelId, config: OpenAICompatibleEmbeddingConfig);
|
|
237
|
+
private get providerOptionsName();
|
|
238
|
+
doEmbed({ values, headers, abortSignal, providerOptions }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>>;
|
|
233
239
|
}
|
|
234
|
-
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/image/openai-compatible-image-settings.d.ts
|
|
235
242
|
type OpenAICompatibleImageModelId = string;
|
|
236
|
-
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/image/openai-compatible-image-model.d.ts
|
|
237
245
|
type OpenAICompatibleImageModelConfig = {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
246
|
+
provider: string;
|
|
247
|
+
headers?: () => Record<string, string | undefined>;
|
|
248
|
+
url: (options: {
|
|
249
|
+
modelId: string;
|
|
250
|
+
path: string;
|
|
251
|
+
}) => string;
|
|
252
|
+
fetch?: FetchFunction;
|
|
253
|
+
errorStructure?: ProviderErrorStructure<any>;
|
|
254
|
+
_internal?: {
|
|
255
|
+
currentDate?: () => Date;
|
|
256
|
+
};
|
|
249
257
|
};
|
|
250
|
-
declare class OpenAICompatibleImageModel implements ImageModelV4 {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
258
|
+
export declare class OpenAICompatibleImageModel implements ImageModelV4 {
|
|
259
|
+
readonly modelId: OpenAICompatibleImageModelId;
|
|
260
|
+
private readonly config;
|
|
261
|
+
readonly specificationVersion = "v4";
|
|
262
|
+
readonly maxImagesPerCall = 10;
|
|
263
|
+
readonly supportsFileInputs: undefined;
|
|
264
|
+
readonly supportsMaskInputs: undefined;
|
|
265
|
+
get provider(): string;
|
|
266
|
+
/**
|
|
267
|
+
* The provider options key used to extract provider-specific options.
|
|
268
|
+
*/
|
|
269
|
+
private get providerOptionsKey();
|
|
270
|
+
static [WORKFLOW_SERIALIZE](model: OpenAICompatibleImageModel): {
|
|
271
|
+
modelId: string;
|
|
272
|
+
config: import("@ai-sdk/provider").JSONObject;
|
|
273
|
+
};
|
|
274
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
275
|
+
modelId: string;
|
|
276
|
+
config: OpenAICompatibleImageModelConfig;
|
|
277
|
+
}): OpenAICompatibleImageModel;
|
|
278
|
+
constructor(modelId: OpenAICompatibleImageModelId, config: OpenAICompatibleImageModelConfig);
|
|
279
|
+
private getArgs;
|
|
280
|
+
doGenerate({ prompt, n, size, aspectRatio, seed, providerOptions, headers, abortSignal, files, mask }: Parameters<ImageModelV4['doGenerate']>[0]): Promise<Awaited<ReturnType<ImageModelV4['doGenerate']>>>;
|
|
273
281
|
}
|
|
274
|
-
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/image/openai-compatible-image-model-options.d.ts
|
|
275
284
|
/**
|
|
276
285
|
* Common provider options for OpenAI-compatible image models.
|
|
277
286
|
*
|
|
278
287
|
* Additional provider-specific options are passed through to the API.
|
|
279
288
|
*/
|
|
280
289
|
declare const openaiCompatibleImageModelOptions: z.ZodObject<{
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
290
|
+
/**
|
|
291
|
+
* Dimensions of the generated image.
|
|
292
|
+
*
|
|
293
|
+
* Supported values depend on the provider and model.
|
|
294
|
+
*/
|
|
295
|
+
size: z.ZodOptional<z.ZodString>;
|
|
296
|
+
/**
|
|
297
|
+
* Quality of the generated image.
|
|
298
|
+
*
|
|
299
|
+
* Supported values depend on the provider and model.
|
|
300
|
+
*/
|
|
301
|
+
quality: z.ZodOptional<z.ZodString>;
|
|
302
|
+
/**
|
|
303
|
+
* File format of the generated image.
|
|
304
|
+
*
|
|
305
|
+
* Supported values depend on the provider and model.
|
|
306
|
+
*/
|
|
307
|
+
output_format: z.ZodOptional<z.ZodString>;
|
|
308
|
+
/**
|
|
309
|
+
* Compression level for JPEG and WebP images.
|
|
310
|
+
*/
|
|
311
|
+
output_compression: z.ZodOptional<z.ZodNumber>;
|
|
312
|
+
/**
|
|
313
|
+
* Background behavior for the generated image.
|
|
314
|
+
*
|
|
315
|
+
* Supported values depend on the provider and model.
|
|
316
|
+
*/
|
|
317
|
+
background: z.ZodOptional<z.ZodString>;
|
|
309
318
|
}, z.core.$loose>;
|
|
310
319
|
type OpenAICompatibleImageModelOptions = z.infer<typeof openaiCompatibleImageModelOptions>;
|
|
311
|
-
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/openai-compatible-provider.d.ts
|
|
312
322
|
interface OpenAICompatibleProvider<CHAT_MODEL_IDS extends string = string, COMPLETION_MODEL_IDS extends string = string, EMBEDDING_MODEL_IDS extends string = string, IMAGE_MODEL_IDS extends string = string> extends ProviderV4 {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
+
(modelId: CHAT_MODEL_IDS): LanguageModelV4;
|
|
324
|
+
languageModel(modelId: CHAT_MODEL_IDS, config?: Partial<OpenAICompatibleChatConfig>): LanguageModelV4;
|
|
325
|
+
chatModel(modelId: CHAT_MODEL_IDS): LanguageModelV4;
|
|
326
|
+
completionModel(modelId: COMPLETION_MODEL_IDS): LanguageModelV4;
|
|
327
|
+
embeddingModel(modelId: EMBEDDING_MODEL_IDS): EmbeddingModelV4;
|
|
328
|
+
/**
|
|
329
|
+
* @deprecated Use `embeddingModel` instead.
|
|
330
|
+
*/
|
|
331
|
+
textEmbeddingModel(modelId: EMBEDDING_MODEL_IDS): EmbeddingModelV4;
|
|
332
|
+
imageModel(modelId: IMAGE_MODEL_IDS): ImageModelV4;
|
|
323
333
|
}
|
|
324
334
|
interface OpenAICompatibleProviderSettings {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
335
|
+
/**
|
|
336
|
+
* Base URL for the API calls.
|
|
337
|
+
*/
|
|
338
|
+
baseURL: string;
|
|
339
|
+
/**
|
|
340
|
+
* Provider name.
|
|
341
|
+
*/
|
|
342
|
+
name: string;
|
|
343
|
+
/**
|
|
344
|
+
* API key for authenticating requests. If specified, adds an `Authorization`
|
|
345
|
+
* header to request headers with the value `Bearer <apiKey>`. This will be added
|
|
346
|
+
* before any headers potentially specified in the `headers` option.
|
|
347
|
+
*/
|
|
348
|
+
apiKey?: string;
|
|
349
|
+
/**
|
|
350
|
+
* Optional custom headers to include in requests. These will be added to request headers
|
|
351
|
+
* after any headers potentially added by use of the `apiKey` option.
|
|
352
|
+
*/
|
|
353
|
+
headers?: Record<string, string>;
|
|
354
|
+
/**
|
|
355
|
+
* Optional custom url query parameters to include in request urls.
|
|
356
|
+
*/
|
|
357
|
+
queryParams?: Record<string, string>;
|
|
358
|
+
/**
|
|
359
|
+
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
360
|
+
* or to provide a custom fetch implementation for e.g. testing.
|
|
361
|
+
*/
|
|
362
|
+
fetch?: FetchFunction;
|
|
363
|
+
/**
|
|
364
|
+
* Include usage information in streaming responses.
|
|
365
|
+
*/
|
|
366
|
+
includeUsage?: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Whether the provider supports structured outputs in chat models.
|
|
369
|
+
*/
|
|
370
|
+
supportsStructuredOutputs?: boolean;
|
|
371
|
+
/**
|
|
372
|
+
* Optional function to transform the request body before sending it to the API.
|
|
373
|
+
* This is useful for proxy providers that may require a different request format
|
|
374
|
+
* than the official OpenAI API.
|
|
375
|
+
*/
|
|
376
|
+
transformRequestBody?: (args: Record<string, any>) => Record<string, any>;
|
|
377
|
+
/**
|
|
378
|
+
* Optional metadata extractor to capture provider-specific metadata from API responses.
|
|
379
|
+
* This is useful for extracting non-standard fields, experimental features,
|
|
380
|
+
* or provider-specific metrics from both streaming and non-streaming responses.
|
|
381
|
+
*/
|
|
382
|
+
metadataExtractor?: MetadataExtractor;
|
|
383
|
+
/**
|
|
384
|
+
* The supported URLs for chat models.
|
|
385
|
+
*/
|
|
386
|
+
supportedUrls?: OpenAICompatibleChatConfig['supportedUrls'];
|
|
387
|
+
/**
|
|
388
|
+
* Optional usage converter for providers with token accounting semantics that
|
|
389
|
+
* differ from the default OpenAI-compatible shape.
|
|
390
|
+
*/
|
|
391
|
+
convertUsage?: OpenAICompatibleChatConfig['convertUsage'];
|
|
382
392
|
}
|
|
383
393
|
/**
|
|
384
394
|
* Create an OpenAICompatible provider instance.
|
|
385
395
|
*/
|
|
386
|
-
declare function createOpenAICompatible<CHAT_MODEL_IDS extends string, COMPLETION_MODEL_IDS extends string, EMBEDDING_MODEL_IDS extends string, IMAGE_MODEL_IDS extends string>(options: OpenAICompatibleProviderSettings): OpenAICompatibleProvider<CHAT_MODEL_IDS, COMPLETION_MODEL_IDS, EMBEDDING_MODEL_IDS, IMAGE_MODEL_IDS>;
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
396
|
+
export declare function createOpenAICompatible<CHAT_MODEL_IDS extends string, COMPLETION_MODEL_IDS extends string, EMBEDDING_MODEL_IDS extends string, IMAGE_MODEL_IDS extends string>(options: OpenAICompatibleProviderSettings): OpenAICompatibleProvider<CHAT_MODEL_IDS, COMPLETION_MODEL_IDS, EMBEDDING_MODEL_IDS, IMAGE_MODEL_IDS>;
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/version.d.ts
|
|
399
|
+
export declare const VERSION: string;
|
|
400
|
+
//#endregion
|
|
401
|
+
export type { MetadataExtractor, OpenAICompatibleChatModelId, OpenAICompatibleCompletionModelId, OpenAICompatibleLanguageModelCompletionOptions as OpenAICompatibleCompletionProviderOptions, OpenAICompatibleLanguageModelCompletionOptions, OpenAICompatibleEmbeddingModelId, OpenAICompatibleEmbeddingModelOptions, OpenAICompatibleEmbeddingModelOptions as OpenAICompatibleEmbeddingProviderOptions, OpenAICompatibleErrorData, OpenAICompatibleImageModelOptions, OpenAICompatibleLanguageModelChatOptions, OpenAICompatibleLanguageModelChatOptions as OpenAICompatibleProviderOptions, OpenAICompatibleProvider, OpenAICompatibleProviderSettings, ProviderErrorStructure };
|
|
402
|
+
//# sourceMappingURL=index.d.ts.map
|