@llmgateway/ai-sdk-provider 1.1.0 → 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 +1576 -694
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1537 -683
- 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
|
@@ -1,15 +1,15 @@
|
|
|
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
3
|
|
|
4
|
-
type LLMGatewayLanguageModel = LanguageModelV1;
|
|
5
4
|
type LLMGatewayProviderOptions = {
|
|
6
5
|
models?: string[];
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Reasoning configuration for supported models.
|
|
9
8
|
* One of `max_tokens` or `effort` is required.
|
|
10
9
|
* If `exclude` is true, reasoning will be removed from the response. Default is false.
|
|
11
10
|
*/
|
|
12
11
|
reasoning?: {
|
|
12
|
+
enabled?: boolean;
|
|
13
13
|
exclude?: boolean;
|
|
14
14
|
} & ({
|
|
15
15
|
max_tokens: number;
|
|
@@ -30,7 +30,6 @@ type LLMGatewaySharedSettings = LLMGatewayProviderOptions & {
|
|
|
30
30
|
extraBody?: Record<string, unknown>;
|
|
31
31
|
/**
|
|
32
32
|
* Enable usage accounting to get detailed token usage information.
|
|
33
|
-
* https://llmgateway.io/docs/use-cases/usage-accounting
|
|
34
33
|
*/
|
|
35
34
|
usage?: {
|
|
36
35
|
/**
|
|
@@ -41,7 +40,6 @@ type LLMGatewaySharedSettings = LLMGatewayProviderOptions & {
|
|
|
41
40
|
};
|
|
42
41
|
/**
|
|
43
42
|
* Usage accounting response
|
|
44
|
-
* @see https://llmgateway.io/docs/use-cases/usage-accounting
|
|
45
43
|
*/
|
|
46
44
|
type LLMGatewayUsageAccounting = {
|
|
47
45
|
promptTokens: number;
|
|
@@ -54,6 +52,9 @@ type LLMGatewayUsageAccounting = {
|
|
|
54
52
|
};
|
|
55
53
|
totalTokens: number;
|
|
56
54
|
cost?: number;
|
|
55
|
+
costDetails: {
|
|
56
|
+
upstreamInferenceCost: number;
|
|
57
|
+
};
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
type LLMGatewayCompletionModelId = string;
|
|
@@ -102,17 +103,18 @@ type LLMGatewayCompletionConfig = {
|
|
|
102
103
|
fetch?: typeof fetch;
|
|
103
104
|
extraBody?: Record<string, unknown>;
|
|
104
105
|
};
|
|
105
|
-
declare class LLMGatewayCompletionLanguageModel implements
|
|
106
|
-
readonly specificationVersion
|
|
107
|
-
readonly
|
|
106
|
+
declare class LLMGatewayCompletionLanguageModel implements LanguageModelV2 {
|
|
107
|
+
readonly specificationVersion: "v2";
|
|
108
|
+
readonly provider = "llmgateway";
|
|
108
109
|
readonly modelId: LLMGatewayCompletionModelId;
|
|
110
|
+
readonly supportedUrls: Record<string, RegExp[]>;
|
|
111
|
+
readonly defaultObjectGenerationMode: undefined;
|
|
109
112
|
readonly settings: LLMGatewayCompletionSettings;
|
|
110
113
|
private readonly config;
|
|
111
114
|
constructor(modelId: LLMGatewayCompletionModelId, settings: LLMGatewayCompletionSettings, config: LLMGatewayCompletionConfig);
|
|
112
|
-
get provider(): string;
|
|
113
115
|
private getArgs;
|
|
114
|
-
doGenerate(options:
|
|
115
|
-
doStream(options:
|
|
116
|
+
doGenerate(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
|
117
|
+
doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
type LLMGatewayChatModelId = string;
|
|
@@ -135,7 +137,7 @@ type LLMGatewayChatSettings = {
|
|
|
135
137
|
/**
|
|
136
138
|
Return the log probabilities of the tokens. Including logprobs will increase
|
|
137
139
|
the response size and can slow down response times. However, it can
|
|
138
|
-
be useful to better
|
|
140
|
+
be useful to understand better how the model is behaving.
|
|
139
141
|
|
|
140
142
|
Setting to true will return the log probabilities of the tokens that
|
|
141
143
|
were generated.
|
|
@@ -166,19 +168,45 @@ type LLMGatewayChatConfig = {
|
|
|
166
168
|
fetch?: typeof fetch;
|
|
167
169
|
extraBody?: Record<string, unknown>;
|
|
168
170
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
readonly
|
|
173
|
-
readonly defaultObjectGenerationMode = "tool";
|
|
171
|
+
declare class LLMGatewayChatLanguageModel implements LanguageModelV2 {
|
|
172
|
+
readonly specificationVersion: "v2";
|
|
173
|
+
readonly provider = "llmgateway";
|
|
174
|
+
readonly defaultObjectGenerationMode: "tool";
|
|
174
175
|
readonly modelId: LLMGatewayChatModelId;
|
|
176
|
+
readonly supportedUrls: Record<string, RegExp[]>;
|
|
175
177
|
readonly settings: LLMGatewayChatSettings;
|
|
176
178
|
private readonly config;
|
|
177
179
|
constructor(modelId: LLMGatewayChatModelId, settings: LLMGatewayChatSettings, config: LLMGatewayChatConfig);
|
|
178
|
-
get provider(): string;
|
|
179
180
|
private getArgs;
|
|
180
|
-
doGenerate(options:
|
|
181
|
-
|
|
181
|
+
doGenerate(options: LanguageModelV2CallOptions): Promise<{
|
|
182
|
+
content: Array<LanguageModelV2Content>;
|
|
183
|
+
finishReason: LanguageModelV2FinishReason;
|
|
184
|
+
usage: LanguageModelV2Usage;
|
|
185
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
186
|
+
providerMetadata?: {
|
|
187
|
+
llmgateway: {
|
|
188
|
+
usage: LLMGatewayUsageAccounting;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
request?: {
|
|
192
|
+
body?: unknown;
|
|
193
|
+
};
|
|
194
|
+
response?: LanguageModelV2ResponseMetadata & {
|
|
195
|
+
headers?: SharedV2Headers;
|
|
196
|
+
body?: unknown;
|
|
197
|
+
};
|
|
198
|
+
}>;
|
|
199
|
+
doStream(options: LanguageModelV2CallOptions): Promise<{
|
|
200
|
+
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
201
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
202
|
+
request?: {
|
|
203
|
+
body?: unknown;
|
|
204
|
+
};
|
|
205
|
+
response?: LanguageModelV2ResponseMetadata & {
|
|
206
|
+
headers?: SharedV2Headers;
|
|
207
|
+
body?: unknown;
|
|
208
|
+
};
|
|
209
|
+
}>;
|
|
182
210
|
}
|
|
183
211
|
|
|
184
|
-
export { LLMGatewayChatLanguageModel, type LLMGatewayChatModelId, type LLMGatewayChatSettings, LLMGatewayCompletionLanguageModel, type LLMGatewayCompletionModelId, type LLMGatewayCompletionSettings, type
|
|
212
|
+
export { LLMGatewayChatLanguageModel, type LLMGatewayChatModelId, type LLMGatewayChatSettings, LLMGatewayCompletionLanguageModel, type LLMGatewayCompletionModelId, type LLMGatewayCompletionSettings, type LLMGatewayProviderOptions, type LLMGatewaySharedSettings, type LLMGatewayUsageAccounting };
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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
3
|
|
|
4
|
-
type LLMGatewayLanguageModel = LanguageModelV1;
|
|
5
4
|
type LLMGatewayProviderOptions = {
|
|
6
5
|
models?: string[];
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Reasoning configuration for supported models.
|
|
9
8
|
* One of `max_tokens` or `effort` is required.
|
|
10
9
|
* If `exclude` is true, reasoning will be removed from the response. Default is false.
|
|
11
10
|
*/
|
|
12
11
|
reasoning?: {
|
|
12
|
+
enabled?: boolean;
|
|
13
13
|
exclude?: boolean;
|
|
14
14
|
} & ({
|
|
15
15
|
max_tokens: number;
|
|
@@ -30,7 +30,6 @@ type LLMGatewaySharedSettings = LLMGatewayProviderOptions & {
|
|
|
30
30
|
extraBody?: Record<string, unknown>;
|
|
31
31
|
/**
|
|
32
32
|
* Enable usage accounting to get detailed token usage information.
|
|
33
|
-
* https://llmgateway.io/docs/use-cases/usage-accounting
|
|
34
33
|
*/
|
|
35
34
|
usage?: {
|
|
36
35
|
/**
|
|
@@ -41,7 +40,6 @@ type LLMGatewaySharedSettings = LLMGatewayProviderOptions & {
|
|
|
41
40
|
};
|
|
42
41
|
/**
|
|
43
42
|
* Usage accounting response
|
|
44
|
-
* @see https://llmgateway.io/docs/use-cases/usage-accounting
|
|
45
43
|
*/
|
|
46
44
|
type LLMGatewayUsageAccounting = {
|
|
47
45
|
promptTokens: number;
|
|
@@ -54,6 +52,9 @@ type LLMGatewayUsageAccounting = {
|
|
|
54
52
|
};
|
|
55
53
|
totalTokens: number;
|
|
56
54
|
cost?: number;
|
|
55
|
+
costDetails: {
|
|
56
|
+
upstreamInferenceCost: number;
|
|
57
|
+
};
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
type LLMGatewayCompletionModelId = string;
|
|
@@ -102,17 +103,18 @@ type LLMGatewayCompletionConfig = {
|
|
|
102
103
|
fetch?: typeof fetch;
|
|
103
104
|
extraBody?: Record<string, unknown>;
|
|
104
105
|
};
|
|
105
|
-
declare class LLMGatewayCompletionLanguageModel implements
|
|
106
|
-
readonly specificationVersion
|
|
107
|
-
readonly
|
|
106
|
+
declare class LLMGatewayCompletionLanguageModel implements LanguageModelV2 {
|
|
107
|
+
readonly specificationVersion: "v2";
|
|
108
|
+
readonly provider = "llmgateway";
|
|
108
109
|
readonly modelId: LLMGatewayCompletionModelId;
|
|
110
|
+
readonly supportedUrls: Record<string, RegExp[]>;
|
|
111
|
+
readonly defaultObjectGenerationMode: undefined;
|
|
109
112
|
readonly settings: LLMGatewayCompletionSettings;
|
|
110
113
|
private readonly config;
|
|
111
114
|
constructor(modelId: LLMGatewayCompletionModelId, settings: LLMGatewayCompletionSettings, config: LLMGatewayCompletionConfig);
|
|
112
|
-
get provider(): string;
|
|
113
115
|
private getArgs;
|
|
114
|
-
doGenerate(options:
|
|
115
|
-
doStream(options:
|
|
116
|
+
doGenerate(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
|
|
117
|
+
doStream(options: LanguageModelV2CallOptions): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
type LLMGatewayChatModelId = string;
|
|
@@ -135,7 +137,7 @@ type LLMGatewayChatSettings = {
|
|
|
135
137
|
/**
|
|
136
138
|
Return the log probabilities of the tokens. Including logprobs will increase
|
|
137
139
|
the response size and can slow down response times. However, it can
|
|
138
|
-
be useful to better
|
|
140
|
+
be useful to understand better how the model is behaving.
|
|
139
141
|
|
|
140
142
|
Setting to true will return the log probabilities of the tokens that
|
|
141
143
|
were generated.
|
|
@@ -166,19 +168,45 @@ type LLMGatewayChatConfig = {
|
|
|
166
168
|
fetch?: typeof fetch;
|
|
167
169
|
extraBody?: Record<string, unknown>;
|
|
168
170
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
readonly
|
|
173
|
-
readonly defaultObjectGenerationMode = "tool";
|
|
171
|
+
declare class LLMGatewayChatLanguageModel implements LanguageModelV2 {
|
|
172
|
+
readonly specificationVersion: "v2";
|
|
173
|
+
readonly provider = "llmgateway";
|
|
174
|
+
readonly defaultObjectGenerationMode: "tool";
|
|
174
175
|
readonly modelId: LLMGatewayChatModelId;
|
|
176
|
+
readonly supportedUrls: Record<string, RegExp[]>;
|
|
175
177
|
readonly settings: LLMGatewayChatSettings;
|
|
176
178
|
private readonly config;
|
|
177
179
|
constructor(modelId: LLMGatewayChatModelId, settings: LLMGatewayChatSettings, config: LLMGatewayChatConfig);
|
|
178
|
-
get provider(): string;
|
|
179
180
|
private getArgs;
|
|
180
|
-
doGenerate(options:
|
|
181
|
-
|
|
181
|
+
doGenerate(options: LanguageModelV2CallOptions): Promise<{
|
|
182
|
+
content: Array<LanguageModelV2Content>;
|
|
183
|
+
finishReason: LanguageModelV2FinishReason;
|
|
184
|
+
usage: LanguageModelV2Usage;
|
|
185
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
186
|
+
providerMetadata?: {
|
|
187
|
+
llmgateway: {
|
|
188
|
+
usage: LLMGatewayUsageAccounting;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
request?: {
|
|
192
|
+
body?: unknown;
|
|
193
|
+
};
|
|
194
|
+
response?: LanguageModelV2ResponseMetadata & {
|
|
195
|
+
headers?: SharedV2Headers;
|
|
196
|
+
body?: unknown;
|
|
197
|
+
};
|
|
198
|
+
}>;
|
|
199
|
+
doStream(options: LanguageModelV2CallOptions): Promise<{
|
|
200
|
+
stream: ReadableStream<LanguageModelV2StreamPart>;
|
|
201
|
+
warnings: Array<LanguageModelV2CallWarning>;
|
|
202
|
+
request?: {
|
|
203
|
+
body?: unknown;
|
|
204
|
+
};
|
|
205
|
+
response?: LanguageModelV2ResponseMetadata & {
|
|
206
|
+
headers?: SharedV2Headers;
|
|
207
|
+
body?: unknown;
|
|
208
|
+
};
|
|
209
|
+
}>;
|
|
182
210
|
}
|
|
183
211
|
|
|
184
|
-
export { LLMGatewayChatLanguageModel, type LLMGatewayChatModelId, type LLMGatewayChatSettings, LLMGatewayCompletionLanguageModel, type LLMGatewayCompletionModelId, type LLMGatewayCompletionSettings, type
|
|
212
|
+
export { LLMGatewayChatLanguageModel, type LLMGatewayChatModelId, type LLMGatewayChatSettings, LLMGatewayCompletionLanguageModel, type LLMGatewayCompletionModelId, type LLMGatewayCompletionSettings, type LLMGatewayProviderOptions, type LLMGatewaySharedSettings, type LLMGatewayUsageAccounting };
|