@llmgateway/ai-sdk-provider 1.0.3 → 2.0.0
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/README.md +1 -1
- package/dist/index.d.mts +96 -64
- package/dist/index.d.ts +96 -64
- package/dist/index.js +1571 -673
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1532 -662
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +50 -22
- package/dist/internal/index.d.ts +50 -22
- package/dist/internal/index.js +1517 -660
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1479 -650
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +6 -8
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ import { llmgateway, createLLMGateway } from '@llmgateway/ai-sdk-provider';
|
|
|
32
32
|
import { generateText } from 'ai';
|
|
33
33
|
|
|
34
34
|
const llmgateway = createLLMGateway({
|
|
35
|
-
apiKey: process.env.
|
|
35
|
+
apiKey: process.env.LLM_GATEWAY_API_KEY,
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
const { text } = await generateText({
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2ResponseMetadata, SharedV2Headers, LanguageModelV2StreamPart } from '@ai-sdk/provider';
|
|
2
|
+
export { LanguageModelV2, LanguageModelV2Prompt } from '@ai-sdk/provider';
|
|
3
|
+
|
|
4
|
+
type LLMGatewayChatModelId = string;
|
|
5
|
+
type LLMGatewayChatSettings = {
|
|
6
|
+
/**
|
|
7
|
+
Modify the likelihood of specified tokens appearing in the completion.
|
|
8
|
+
|
|
9
|
+
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
10
|
+
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
11
|
+
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
12
|
+
the bias is added to the logits generated by the model prior to sampling.
|
|
13
|
+
The exact effect will vary per model, but values between -1 and 1 should
|
|
14
|
+
decrease or increase likelihood of selection; values like -100 or 100
|
|
15
|
+
should result in a ban or exclusive selection of the relevant token.
|
|
16
|
+
|
|
17
|
+
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
18
|
+
token from being generated.
|
|
19
|
+
*/
|
|
20
|
+
logitBias?: Record<number, number>;
|
|
21
|
+
/**
|
|
22
|
+
Return the log probabilities of the tokens. Including logprobs will increase
|
|
23
|
+
the response size and can slow down response times. However, it can
|
|
24
|
+
be useful to understand better how the model is behaving.
|
|
25
|
+
|
|
26
|
+
Setting to true will return the log probabilities of the tokens that
|
|
27
|
+
were generated.
|
|
28
|
+
|
|
29
|
+
Setting to a number will return the log probabilities of the top n
|
|
30
|
+
tokens that were generated.
|
|
31
|
+
*/
|
|
32
|
+
logprobs?: boolean | number;
|
|
33
|
+
/**
|
|
34
|
+
Whether to enable parallel function calling during tool use. Default to true.
|
|
35
|
+
*/
|
|
36
|
+
parallelToolCalls?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
A unique identifier representing your end-user, which can help LLMGateway to
|
|
39
|
+
monitor and detect abuse. Learn more.
|
|
40
|
+
*/
|
|
41
|
+
user?: string;
|
|
42
|
+
} & LLMGatewaySharedSettings;
|
|
3
43
|
|
|
4
|
-
type LLMGatewayLanguageModel = LanguageModelV1;
|
|
5
44
|
type LLMGatewayProviderOptions = {
|
|
6
45
|
models?: string[];
|
|
7
46
|
/**
|
|
8
|
-
*
|
|
47
|
+
* Reasoning configuration for supported models.
|
|
9
48
|
* One of `max_tokens` or `effort` is required.
|
|
10
49
|
* If `exclude` is true, reasoning will be removed from the response. Default is false.
|
|
11
50
|
*/
|
|
12
51
|
reasoning?: {
|
|
52
|
+
enabled?: boolean;
|
|
13
53
|
exclude?: boolean;
|
|
14
54
|
} & ({
|
|
15
55
|
max_tokens: number;
|
|
@@ -30,7 +70,6 @@ type LLMGatewaySharedSettings = LLMGatewayProviderOptions & {
|
|
|
30
70
|
extraBody?: Record<string, unknown>;
|
|
31
71
|
/**
|
|
32
72
|
* Enable usage accounting to get detailed token usage information.
|
|
33
|
-
* https://llmgateway.io/docs/use-cases/usage-accounting
|
|
34
73
|
*/
|
|
35
74
|
usage?: {
|
|
36
75
|
/**
|
|
@@ -41,7 +80,6 @@ type LLMGatewaySharedSettings = LLMGatewayProviderOptions & {
|
|
|
41
80
|
};
|
|
42
81
|
/**
|
|
43
82
|
* Usage accounting response
|
|
44
|
-
* @see https://llmgateway.io/docs/use-cases/usage-accounting
|
|
45
83
|
*/
|
|
46
84
|
type LLMGatewayUsageAccounting = {
|
|
47
85
|
promptTokens: number;
|
|
@@ -54,6 +92,9 @@ type LLMGatewayUsageAccounting = {
|
|
|
54
92
|
};
|
|
55
93
|
totalTokens: number;
|
|
56
94
|
cost?: number;
|
|
95
|
+
costDetails: {
|
|
96
|
+
upstreamInferenceCost: number;
|
|
97
|
+
};
|
|
57
98
|
};
|
|
58
99
|
|
|
59
100
|
type LLMGatewayCompletionModelId = string;
|
|
@@ -91,46 +132,6 @@ type LLMGatewayCompletionSettings = {
|
|
|
91
132
|
suffix?: string;
|
|
92
133
|
} & LLMGatewaySharedSettings;
|
|
93
134
|
|
|
94
|
-
type LLMGatewayChatModelId = string;
|
|
95
|
-
type LLMGatewayChatSettings = {
|
|
96
|
-
/**
|
|
97
|
-
Modify the likelihood of specified tokens appearing in the completion.
|
|
98
|
-
|
|
99
|
-
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
100
|
-
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
101
|
-
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
102
|
-
the bias is added to the logits generated by the model prior to sampling.
|
|
103
|
-
The exact effect will vary per model, but values between -1 and 1 should
|
|
104
|
-
decrease or increase likelihood of selection; values like -100 or 100
|
|
105
|
-
should result in a ban or exclusive selection of the relevant token.
|
|
106
|
-
|
|
107
|
-
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
108
|
-
token from being generated.
|
|
109
|
-
*/
|
|
110
|
-
logitBias?: Record<number, number>;
|
|
111
|
-
/**
|
|
112
|
-
Return the log probabilities of the tokens. Including logprobs will increase
|
|
113
|
-
the response size and can slow down response times. However, it can
|
|
114
|
-
be useful to better understand how the model is behaving.
|
|
115
|
-
|
|
116
|
-
Setting to true will return the log probabilities of the tokens that
|
|
117
|
-
were generated.
|
|
118
|
-
|
|
119
|
-
Setting to a number will return the log probabilities of the top n
|
|
120
|
-
tokens that were generated.
|
|
121
|
-
*/
|
|
122
|
-
logprobs?: boolean | number;
|
|
123
|
-
/**
|
|
124
|
-
Whether to enable parallel function calling during tool use. Default to true.
|
|
125
|
-
*/
|
|
126
|
-
parallelToolCalls?: boolean;
|
|
127
|
-
/**
|
|
128
|
-
A unique identifier representing your end-user, which can help LLMGateway to
|
|
129
|
-
monitor and detect abuse. Learn more.
|
|
130
|
-
*/
|
|
131
|
-
user?: string;
|
|
132
|
-
} & LLMGatewaySharedSettings;
|
|
133
|
-
|
|
134
135
|
type LLMGatewayChatConfig = {
|
|
135
136
|
provider: string;
|
|
136
137
|
compatibility: 'strict' | 'compatible';
|
|
@@ -142,19 +143,45 @@ type LLMGatewayChatConfig = {
|
|
|
142
143
|
fetch?: typeof fetch;
|
|
143
144
|
extraBody?: Record<string, unknown>;
|
|
144
145
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
readonly
|
|
149
|
-
readonly defaultObjectGenerationMode = "tool";
|
|
146
|
+
declare class LLMGatewayChatLanguageModel implements LanguageModelV2 {
|
|
147
|
+
readonly specificationVersion: "v2";
|
|
148
|
+
readonly provider = "llmgateway";
|
|
149
|
+
readonly defaultObjectGenerationMode: "tool";
|
|
150
150
|
readonly modelId: LLMGatewayChatModelId;
|
|
151
|
+
readonly supportedUrls: Record<string, RegExp[]>;
|
|
151
152
|
readonly settings: LLMGatewayChatSettings;
|
|
152
153
|
private readonly config;
|
|
153
154
|
constructor(modelId: LLMGatewayChatModelId, settings: LLMGatewayChatSettings, config: LLMGatewayChatConfig);
|
|
154
|
-
get provider(): string;
|
|
155
155
|
private getArgs;
|
|
156
|
-
doGenerate(options:
|
|
157
|
-
|
|
156
|
+
doGenerate(options: LanguageModelV2CallOptions): Promise<{
|
|
157
|
+
content: Array<LanguageModelV2Content>;
|
|
158
|
+
finishReason: LanguageModelV2FinishReason;
|
|
159
|
+
usage: LanguageModelV2Usage;
|
|
160
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
161
|
+
providerMetadata?: {
|
|
162
|
+
llmgateway: {
|
|
163
|
+
usage: LLMGatewayUsageAccounting;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
request?: {
|
|
167
|
+
body?: unknown;
|
|
168
|
+
};
|
|
169
|
+
response?: LanguageModelV2ResponseMetadata & {
|
|
170
|
+
headers?: SharedV2Headers;
|
|
171
|
+
body?: unknown;
|
|
172
|
+
};
|
|
173
|
+
}>;
|
|
174
|
+
doStream(options: LanguageModelV2CallOptions): Promise<{
|
|
175
|
+
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
176
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
177
|
+
request?: {
|
|
178
|
+
body?: unknown;
|
|
179
|
+
};
|
|
180
|
+
response?: LanguageModelV2ResponseMetadata & {
|
|
181
|
+
headers?: SharedV2Headers;
|
|
182
|
+
body?: unknown;
|
|
183
|
+
};
|
|
184
|
+
}>;
|
|
158
185
|
}
|
|
159
186
|
|
|
160
187
|
type LLMGatewayCompletionConfig = {
|
|
@@ -168,20 +195,21 @@ type LLMGatewayCompletionConfig = {
|
|
|
168
195
|
fetch?: typeof fetch;
|
|
169
196
|
extraBody?: Record<string, unknown>;
|
|
170
197
|
};
|
|
171
|
-
declare class LLMGatewayCompletionLanguageModel implements
|
|
172
|
-
readonly specificationVersion
|
|
173
|
-
readonly
|
|
198
|
+
declare class LLMGatewayCompletionLanguageModel implements LanguageModelV2 {
|
|
199
|
+
readonly specificationVersion: "v2";
|
|
200
|
+
readonly provider = "llmgateway";
|
|
174
201
|
readonly modelId: LLMGatewayCompletionModelId;
|
|
202
|
+
readonly supportedUrls: Record<string, RegExp[]>;
|
|
203
|
+
readonly defaultObjectGenerationMode: undefined;
|
|
175
204
|
readonly settings: LLMGatewayCompletionSettings;
|
|
176
205
|
private readonly config;
|
|
177
206
|
constructor(modelId: LLMGatewayCompletionModelId, settings: LLMGatewayCompletionSettings, config: LLMGatewayCompletionConfig);
|
|
178
|
-
get provider(): string;
|
|
179
207
|
private getArgs;
|
|
180
|
-
doGenerate(options:
|
|
181
|
-
doStream(options:
|
|
208
|
+
doGenerate(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
|
209
|
+
doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
182
210
|
}
|
|
183
211
|
|
|
184
|
-
interface LLMGatewayProvider {
|
|
212
|
+
interface LLMGatewayProvider extends LanguageModelV2 {
|
|
185
213
|
(modelId: LLMGatewayChatModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
|
|
186
214
|
(modelId: LLMGatewayChatModelId, settings?: LLMGatewayChatSettings): LLMGatewayChatLanguageModel;
|
|
187
215
|
languageModel(modelId: LLMGatewayChatModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
|
|
@@ -201,6 +229,10 @@ interface LLMGatewayProviderSettings {
|
|
|
201
229
|
*/
|
|
202
230
|
baseURL?: string;
|
|
203
231
|
/**
|
|
232
|
+
@deprecated Use `baseURL` instead.
|
|
233
|
+
*/
|
|
234
|
+
baseUrl?: string;
|
|
235
|
+
/**
|
|
204
236
|
API key for authenticating requests.
|
|
205
237
|
*/
|
|
206
238
|
apiKey?: string;
|
|
@@ -243,8 +275,8 @@ declare class LLMGateway {
|
|
|
243
275
|
*/
|
|
244
276
|
readonly baseURL: string;
|
|
245
277
|
/**
|
|
246
|
-
API key that is being
|
|
247
|
-
It defaults to the `
|
|
278
|
+
API key that is being sent using the `Authorization` header.
|
|
279
|
+
It defaults to the `LLM_GATEWAY_API_KEY` environment variable.
|
|
248
280
|
*/
|
|
249
281
|
readonly apiKey?: string;
|
|
250
282
|
/**
|
|
@@ -260,4 +292,4 @@ declare class LLMGateway {
|
|
|
260
292
|
completion(modelId: LLMGatewayCompletionModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
|
|
261
293
|
}
|
|
262
294
|
|
|
263
|
-
export { LLMGateway, type LLMGatewayCompletionSettings, type
|
|
295
|
+
export { LLMGateway, type LLMGatewayCompletionSettings, type LLMGatewayProvider, type LLMGatewayProviderOptions, type LLMGatewayProviderSettings, type LLMGatewaySharedSettings, type LLMGatewayUsageAccounting, createLLMGateway, llmgateway };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2ResponseMetadata, SharedV2Headers, LanguageModelV2StreamPart } from '@ai-sdk/provider';
|
|
2
|
+
export { LanguageModelV2, LanguageModelV2Prompt } from '@ai-sdk/provider';
|
|
3
|
+
|
|
4
|
+
type LLMGatewayChatModelId = string;
|
|
5
|
+
type LLMGatewayChatSettings = {
|
|
6
|
+
/**
|
|
7
|
+
Modify the likelihood of specified tokens appearing in the completion.
|
|
8
|
+
|
|
9
|
+
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
10
|
+
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
11
|
+
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
12
|
+
the bias is added to the logits generated by the model prior to sampling.
|
|
13
|
+
The exact effect will vary per model, but values between -1 and 1 should
|
|
14
|
+
decrease or increase likelihood of selection; values like -100 or 100
|
|
15
|
+
should result in a ban or exclusive selection of the relevant token.
|
|
16
|
+
|
|
17
|
+
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
18
|
+
token from being generated.
|
|
19
|
+
*/
|
|
20
|
+
logitBias?: Record<number, number>;
|
|
21
|
+
/**
|
|
22
|
+
Return the log probabilities of the tokens. Including logprobs will increase
|
|
23
|
+
the response size and can slow down response times. However, it can
|
|
24
|
+
be useful to understand better how the model is behaving.
|
|
25
|
+
|
|
26
|
+
Setting to true will return the log probabilities of the tokens that
|
|
27
|
+
were generated.
|
|
28
|
+
|
|
29
|
+
Setting to a number will return the log probabilities of the top n
|
|
30
|
+
tokens that were generated.
|
|
31
|
+
*/
|
|
32
|
+
logprobs?: boolean | number;
|
|
33
|
+
/**
|
|
34
|
+
Whether to enable parallel function calling during tool use. Default to true.
|
|
35
|
+
*/
|
|
36
|
+
parallelToolCalls?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
A unique identifier representing your end-user, which can help LLMGateway to
|
|
39
|
+
monitor and detect abuse. Learn more.
|
|
40
|
+
*/
|
|
41
|
+
user?: string;
|
|
42
|
+
} & LLMGatewaySharedSettings;
|
|
3
43
|
|
|
4
|
-
type LLMGatewayLanguageModel = LanguageModelV1;
|
|
5
44
|
type LLMGatewayProviderOptions = {
|
|
6
45
|
models?: string[];
|
|
7
46
|
/**
|
|
8
|
-
*
|
|
47
|
+
* Reasoning configuration for supported models.
|
|
9
48
|
* One of `max_tokens` or `effort` is required.
|
|
10
49
|
* If `exclude` is true, reasoning will be removed from the response. Default is false.
|
|
11
50
|
*/
|
|
12
51
|
reasoning?: {
|
|
52
|
+
enabled?: boolean;
|
|
13
53
|
exclude?: boolean;
|
|
14
54
|
} & ({
|
|
15
55
|
max_tokens: number;
|
|
@@ -30,7 +70,6 @@ type LLMGatewaySharedSettings = LLMGatewayProviderOptions & {
|
|
|
30
70
|
extraBody?: Record<string, unknown>;
|
|
31
71
|
/**
|
|
32
72
|
* Enable usage accounting to get detailed token usage information.
|
|
33
|
-
* https://llmgateway.io/docs/use-cases/usage-accounting
|
|
34
73
|
*/
|
|
35
74
|
usage?: {
|
|
36
75
|
/**
|
|
@@ -41,7 +80,6 @@ type LLMGatewaySharedSettings = LLMGatewayProviderOptions & {
|
|
|
41
80
|
};
|
|
42
81
|
/**
|
|
43
82
|
* Usage accounting response
|
|
44
|
-
* @see https://llmgateway.io/docs/use-cases/usage-accounting
|
|
45
83
|
*/
|
|
46
84
|
type LLMGatewayUsageAccounting = {
|
|
47
85
|
promptTokens: number;
|
|
@@ -54,6 +92,9 @@ type LLMGatewayUsageAccounting = {
|
|
|
54
92
|
};
|
|
55
93
|
totalTokens: number;
|
|
56
94
|
cost?: number;
|
|
95
|
+
costDetails: {
|
|
96
|
+
upstreamInferenceCost: number;
|
|
97
|
+
};
|
|
57
98
|
};
|
|
58
99
|
|
|
59
100
|
type LLMGatewayCompletionModelId = string;
|
|
@@ -91,46 +132,6 @@ type LLMGatewayCompletionSettings = {
|
|
|
91
132
|
suffix?: string;
|
|
92
133
|
} & LLMGatewaySharedSettings;
|
|
93
134
|
|
|
94
|
-
type LLMGatewayChatModelId = string;
|
|
95
|
-
type LLMGatewayChatSettings = {
|
|
96
|
-
/**
|
|
97
|
-
Modify the likelihood of specified tokens appearing in the completion.
|
|
98
|
-
|
|
99
|
-
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
100
|
-
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
101
|
-
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
102
|
-
the bias is added to the logits generated by the model prior to sampling.
|
|
103
|
-
The exact effect will vary per model, but values between -1 and 1 should
|
|
104
|
-
decrease or increase likelihood of selection; values like -100 or 100
|
|
105
|
-
should result in a ban or exclusive selection of the relevant token.
|
|
106
|
-
|
|
107
|
-
As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
|
|
108
|
-
token from being generated.
|
|
109
|
-
*/
|
|
110
|
-
logitBias?: Record<number, number>;
|
|
111
|
-
/**
|
|
112
|
-
Return the log probabilities of the tokens. Including logprobs will increase
|
|
113
|
-
the response size and can slow down response times. However, it can
|
|
114
|
-
be useful to better understand how the model is behaving.
|
|
115
|
-
|
|
116
|
-
Setting to true will return the log probabilities of the tokens that
|
|
117
|
-
were generated.
|
|
118
|
-
|
|
119
|
-
Setting to a number will return the log probabilities of the top n
|
|
120
|
-
tokens that were generated.
|
|
121
|
-
*/
|
|
122
|
-
logprobs?: boolean | number;
|
|
123
|
-
/**
|
|
124
|
-
Whether to enable parallel function calling during tool use. Default to true.
|
|
125
|
-
*/
|
|
126
|
-
parallelToolCalls?: boolean;
|
|
127
|
-
/**
|
|
128
|
-
A unique identifier representing your end-user, which can help LLMGateway to
|
|
129
|
-
monitor and detect abuse. Learn more.
|
|
130
|
-
*/
|
|
131
|
-
user?: string;
|
|
132
|
-
} & LLMGatewaySharedSettings;
|
|
133
|
-
|
|
134
135
|
type LLMGatewayChatConfig = {
|
|
135
136
|
provider: string;
|
|
136
137
|
compatibility: 'strict' | 'compatible';
|
|
@@ -142,19 +143,45 @@ type LLMGatewayChatConfig = {
|
|
|
142
143
|
fetch?: typeof fetch;
|
|
143
144
|
extraBody?: Record<string, unknown>;
|
|
144
145
|
};
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
readonly
|
|
149
|
-
readonly defaultObjectGenerationMode = "tool";
|
|
146
|
+
declare class LLMGatewayChatLanguageModel implements LanguageModelV2 {
|
|
147
|
+
readonly specificationVersion: "v2";
|
|
148
|
+
readonly provider = "llmgateway";
|
|
149
|
+
readonly defaultObjectGenerationMode: "tool";
|
|
150
150
|
readonly modelId: LLMGatewayChatModelId;
|
|
151
|
+
readonly supportedUrls: Record<string, RegExp[]>;
|
|
151
152
|
readonly settings: LLMGatewayChatSettings;
|
|
152
153
|
private readonly config;
|
|
153
154
|
constructor(modelId: LLMGatewayChatModelId, settings: LLMGatewayChatSettings, config: LLMGatewayChatConfig);
|
|
154
|
-
get provider(): string;
|
|
155
155
|
private getArgs;
|
|
156
|
-
doGenerate(options:
|
|
157
|
-
|
|
156
|
+
doGenerate(options: LanguageModelV2CallOptions): Promise<{
|
|
157
|
+
content: Array<LanguageModelV2Content>;
|
|
158
|
+
finishReason: LanguageModelV2FinishReason;
|
|
159
|
+
usage: LanguageModelV2Usage;
|
|
160
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
161
|
+
providerMetadata?: {
|
|
162
|
+
llmgateway: {
|
|
163
|
+
usage: LLMGatewayUsageAccounting;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
request?: {
|
|
167
|
+
body?: unknown;
|
|
168
|
+
};
|
|
169
|
+
response?: LanguageModelV2ResponseMetadata & {
|
|
170
|
+
headers?: SharedV2Headers;
|
|
171
|
+
body?: unknown;
|
|
172
|
+
};
|
|
173
|
+
}>;
|
|
174
|
+
doStream(options: LanguageModelV2CallOptions): Promise<{
|
|
175
|
+
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
176
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
177
|
+
request?: {
|
|
178
|
+
body?: unknown;
|
|
179
|
+
};
|
|
180
|
+
response?: LanguageModelV2ResponseMetadata & {
|
|
181
|
+
headers?: SharedV2Headers;
|
|
182
|
+
body?: unknown;
|
|
183
|
+
};
|
|
184
|
+
}>;
|
|
158
185
|
}
|
|
159
186
|
|
|
160
187
|
type LLMGatewayCompletionConfig = {
|
|
@@ -168,20 +195,21 @@ type LLMGatewayCompletionConfig = {
|
|
|
168
195
|
fetch?: typeof fetch;
|
|
169
196
|
extraBody?: Record<string, unknown>;
|
|
170
197
|
};
|
|
171
|
-
declare class LLMGatewayCompletionLanguageModel implements
|
|
172
|
-
readonly specificationVersion
|
|
173
|
-
readonly
|
|
198
|
+
declare class LLMGatewayCompletionLanguageModel implements LanguageModelV2 {
|
|
199
|
+
readonly specificationVersion: "v2";
|
|
200
|
+
readonly provider = "llmgateway";
|
|
174
201
|
readonly modelId: LLMGatewayCompletionModelId;
|
|
202
|
+
readonly supportedUrls: Record<string, RegExp[]>;
|
|
203
|
+
readonly defaultObjectGenerationMode: undefined;
|
|
175
204
|
readonly settings: LLMGatewayCompletionSettings;
|
|
176
205
|
private readonly config;
|
|
177
206
|
constructor(modelId: LLMGatewayCompletionModelId, settings: LLMGatewayCompletionSettings, config: LLMGatewayCompletionConfig);
|
|
178
|
-
get provider(): string;
|
|
179
207
|
private getArgs;
|
|
180
|
-
doGenerate(options:
|
|
181
|
-
doStream(options:
|
|
208
|
+
doGenerate(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
|
209
|
+
doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
182
210
|
}
|
|
183
211
|
|
|
184
|
-
interface LLMGatewayProvider {
|
|
212
|
+
interface LLMGatewayProvider extends LanguageModelV2 {
|
|
185
213
|
(modelId: LLMGatewayChatModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
|
|
186
214
|
(modelId: LLMGatewayChatModelId, settings?: LLMGatewayChatSettings): LLMGatewayChatLanguageModel;
|
|
187
215
|
languageModel(modelId: LLMGatewayChatModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
|
|
@@ -201,6 +229,10 @@ interface LLMGatewayProviderSettings {
|
|
|
201
229
|
*/
|
|
202
230
|
baseURL?: string;
|
|
203
231
|
/**
|
|
232
|
+
@deprecated Use `baseURL` instead.
|
|
233
|
+
*/
|
|
234
|
+
baseUrl?: string;
|
|
235
|
+
/**
|
|
204
236
|
API key for authenticating requests.
|
|
205
237
|
*/
|
|
206
238
|
apiKey?: string;
|
|
@@ -243,8 +275,8 @@ declare class LLMGateway {
|
|
|
243
275
|
*/
|
|
244
276
|
readonly baseURL: string;
|
|
245
277
|
/**
|
|
246
|
-
API key that is being
|
|
247
|
-
It defaults to the `
|
|
278
|
+
API key that is being sent using the `Authorization` header.
|
|
279
|
+
It defaults to the `LLM_GATEWAY_API_KEY` environment variable.
|
|
248
280
|
*/
|
|
249
281
|
readonly apiKey?: string;
|
|
250
282
|
/**
|
|
@@ -260,4 +292,4 @@ declare class LLMGateway {
|
|
|
260
292
|
completion(modelId: LLMGatewayCompletionModelId, settings?: LLMGatewayCompletionSettings): LLMGatewayCompletionLanguageModel;
|
|
261
293
|
}
|
|
262
294
|
|
|
263
|
-
export { LLMGateway, type LLMGatewayCompletionSettings, type
|
|
295
|
+
export { LLMGateway, type LLMGatewayCompletionSettings, type LLMGatewayProvider, type LLMGatewayProviderOptions, type LLMGatewayProviderSettings, type LLMGatewaySharedSettings, type LLMGatewayUsageAccounting, createLLMGateway, llmgateway };
|