@convex-dev/ai-sdk-provider 0.2.1 → 0.3.1
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 +63 -9
- package/dist/commonjs/decision-model.d.ts +4 -0
- package/dist/commonjs/decision-model.d.ts.map +1 -0
- package/dist/commonjs/{evaluation-model.js → decision-model.js} +3 -3
- package/dist/commonjs/decision-model.js.map +1 -0
- package/dist/commonjs/index.d.ts +46 -37
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +97 -26
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/transcription-model.d.ts +10 -0
- package/dist/commonjs/transcription-model.d.ts.map +1 -0
- package/dist/commonjs/transcription-model.js +102 -0
- package/dist/commonjs/transcription-model.js.map +1 -0
- package/dist/commonjs/video-model.d.ts +1 -1
- package/dist/commonjs/video-model.d.ts.map +1 -1
- package/dist/esm/decision-model.d.ts +4 -0
- package/dist/esm/decision-model.d.ts.map +1 -0
- package/dist/esm/{evaluation-model.js → decision-model.js} +2 -2
- package/dist/esm/decision-model.js.map +1 -0
- package/dist/esm/index.d.ts +46 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +96 -24
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/transcription-model.d.ts +10 -0
- package/dist/esm/transcription-model.d.ts.map +1 -0
- package/dist/esm/transcription-model.js +99 -0
- package/dist/esm/transcription-model.js.map +1 -0
- package/dist/esm/video-model.d.ts +1 -1
- package/dist/esm/video-model.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/{evaluation-model.ts → decision-model.ts} +3 -3
- package/src/index.ts +138 -25
- package/src/transcription-model.ts +133 -0
- package/src/video-model.ts +1 -1
- package/dist/commonjs/evaluation-model.d.ts +0 -5
- package/dist/commonjs/evaluation-model.d.ts.map +0 -1
- package/dist/commonjs/evaluation-model.js.map +0 -1
- package/dist/esm/evaluation-model.d.ts +0 -5
- package/dist/esm/evaluation-model.d.ts.map +0 -1
- package/dist/esm/evaluation-model.js.map +0 -1
package/README.md
CHANGED
|
@@ -36,6 +36,26 @@ export const embed = action({
|
|
|
36
36
|
Embedding batches larger than the gateway's 512-input limit are split into
|
|
37
37
|
multiple requests by the AI SDK.
|
|
38
38
|
|
|
39
|
+
## Optional ZDR routing
|
|
40
|
+
|
|
41
|
+
Pass `{ zdr: true }` to use inference endpoints with a zero-data-retention
|
|
42
|
+
policy:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const { text } = await generateText({
|
|
46
|
+
model: convexGateway("openai/gpt-4o-mini", { zdr: true }),
|
|
47
|
+
prompt: "Summarize this document",
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Also supported by `messages`, `responses`, `embeddingModel`, and
|
|
52
|
+
`evaluationModel`. The setting applies to that model instance and overrides
|
|
53
|
+
`provider.zdr` from other SDK options. Omit it to use the default policy;
|
|
54
|
+
`false` cannot disable a stricter gateway policy.
|
|
55
|
+
|
|
56
|
+
Not every model has a ZDR endpoint. See
|
|
57
|
+
[routing requirements and retention limits](https://docs.convex.dev/ai-gateway/api#provider-preferences).
|
|
58
|
+
|
|
39
59
|
## Choose a model interface
|
|
40
60
|
|
|
41
61
|
For text generation, start with `convexGateway(model)`. It works across model
|
|
@@ -91,10 +111,11 @@ gateway response, including provider-specific fields such as `confidence`, is
|
|
|
91
111
|
available in `decision.response.body`.
|
|
92
112
|
|
|
93
113
|
`getServiceToken("ai-gateway")` supplies a short-lived deployment JWT. The
|
|
94
|
-
action runtime caches and refreshes the credential as needed, so
|
|
95
|
-
|
|
114
|
+
action runtime caches and refreshes the credential as needed, so `convexGateway`
|
|
115
|
+
calls it on every request.
|
|
96
116
|
|
|
97
|
-
Requires Convex 1.45 or later
|
|
117
|
+
Requires Convex 1.45 or later and AI SDK 7.0.105 or later. The provider works in
|
|
118
|
+
the default runtime and in Node.js actions, which need Node.js 22 or later.
|
|
98
119
|
|
|
99
120
|
## Generate images
|
|
100
121
|
|
|
@@ -110,6 +131,38 @@ const { images } = await generateImage({
|
|
|
110
131
|
});
|
|
111
132
|
```
|
|
112
133
|
|
|
134
|
+
Image request costs are available in each entry of `result.calls`, at
|
|
135
|
+
`providerMetadata?.convexGateway?.cost`, in US dollars. Each call may generate
|
|
136
|
+
multiple images; the cost is for the call, not each image.
|
|
137
|
+
|
|
138
|
+
## Transcribe and generate speech
|
|
139
|
+
|
|
140
|
+
Speech-to-text and text-to-speech are in alpha.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import {
|
|
144
|
+
experimental_generateSpeech as generateSpeech,
|
|
145
|
+
experimental_transcribe as transcribe,
|
|
146
|
+
} from "ai";
|
|
147
|
+
import { convexGateway } from "@convex-dev/ai-sdk-provider";
|
|
148
|
+
|
|
149
|
+
const { text, providerMetadata } = await transcribe({
|
|
150
|
+
model: convexGateway.transcriptionModel("openai/whisper-large-v3-turbo"),
|
|
151
|
+
audio: recordingBytes,
|
|
152
|
+
});
|
|
153
|
+
const cost = providerMetadata.convexGateway?.cost;
|
|
154
|
+
|
|
155
|
+
const { audio } = await generateSpeech({
|
|
156
|
+
model: convexGateway.speechModel("hexgrad/kokoro-82m"),
|
|
157
|
+
text: "Your order has shipped.",
|
|
158
|
+
voice: "af_heart",
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Speech results have no `cost` in `providerMetadata`, because the cost is known
|
|
163
|
+
only after the audio is sent. Convex still bills for speech. The charge appears
|
|
164
|
+
on the Convex usage page.
|
|
165
|
+
|
|
113
166
|
## Generate videos
|
|
114
167
|
|
|
115
168
|
Video generation is in alpha. APIs may change, and completion callbacks are best
|
|
@@ -131,10 +184,11 @@ const bytes = video.uint8Array;
|
|
|
131
184
|
const cost = providerMetadata?.convexGateway?.cost;
|
|
132
185
|
```
|
|
133
186
|
|
|
134
|
-
The call waits for generation and download, with a
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
187
|
+
The call waits for generation and download, with a 64 MiB limit per video. It
|
|
188
|
+
fails if generation takes longer than about five minutes; use async videos for
|
|
189
|
+
longer jobs. Store the returned bytes in Convex file storage. The AI SDK splits
|
|
190
|
+
`n > 1` into separate requests. Cancelling a request does not cancel the
|
|
191
|
+
upstream job and can still incur a charge.
|
|
138
192
|
|
|
139
193
|
An image in the prompt becomes the first frame. Use `frameImages` for explicit
|
|
140
194
|
frames, `inputReferences` for image/audio/video references, and `generateAudio`
|
|
@@ -147,8 +201,8 @@ take precedence. Supported values depend on the
|
|
|
147
201
|
|
|
148
202
|
## Async videos
|
|
149
203
|
|
|
150
|
-
With AI SDK 7.0.
|
|
151
|
-
waiting for the video. See the
|
|
204
|
+
With AI SDK 7.0.105 or later, use `experimental_startVideo` to submit a job
|
|
205
|
+
without waiting for the video. See the
|
|
152
206
|
[async availability requirements](https://docs.convex.dev/ai-gateway/images-and-videos#async-videos)
|
|
153
207
|
before using these routes.
|
|
154
208
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type experimental_evaluate, type ProviderMetadata } from "ai";
|
|
2
|
+
export type DecisionModel = Exclude<Parameters<typeof experimental_evaluate>[0]["model"], string>;
|
|
3
|
+
export declare function createDecisionModel(modelId: string, baseURL: string, fetch: typeof globalThis.fetch, usageMetadata: (usage: unknown) => ProviderMetadata | undefined): DecisionModel;
|
|
4
|
+
//# sourceMappingURL=decision-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-model.d.ts","sourceRoot":"","sources":["../../src/decision-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACtB,MAAM,IAAI,CAAC;AAGZ,MAAM,MAAM,aAAa,GAAG,OAAO,CACjC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EACpD,MAAM,CACP,CAAC;AAyBF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,EAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,gBAAgB,GAAG,SAAS,GAC9D,aAAa,CA+Ef"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createDecisionModel = createDecisionModel;
|
|
4
4
|
const ai_1 = require("ai");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const probabilities = zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional();
|
|
@@ -22,7 +22,7 @@ const responseSchema = zod_1.z.object({
|
|
|
22
22
|
cost: zod_1.z.number().nonnegative().optional(),
|
|
23
23
|
}),
|
|
24
24
|
});
|
|
25
|
-
function
|
|
25
|
+
function createDecisionModel(modelId, baseURL, fetch, usageMetadata) {
|
|
26
26
|
return {
|
|
27
27
|
specificationVersion: "v4",
|
|
28
28
|
provider: "convexGateway",
|
|
@@ -93,4 +93,4 @@ function createEvaluationModel(modelId, baseURL, fetch, usageMetadata) {
|
|
|
93
93
|
},
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
//# sourceMappingURL=
|
|
96
|
+
//# sourceMappingURL=decision-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decision-model.js","sourceRoot":"","sources":["../../src/decision-model.ts"],"names":[],"mappings":";;AAmCA,kDAoFC;AAvHD,2BAIY;AACZ,6BAAwB;AAOxB,MAAM,aAAa,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAClE,MAAM,cAAc,GAAG,OAAC,CAAC,MAAM,CAAC;IAC9B,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE;IACd,KAAK,EAAE,OAA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C,IAAI,EAAE,OAAO;iBACd;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/commonjs/index.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
1
2
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
2
3
|
import { wrapEmbeddingModel, wrapLanguageModel } from "ai";
|
|
4
|
+
import { type DecisionModel } from "./decision-model.js";
|
|
5
|
+
import { type TranscriptionModel } from "./transcription-model.js";
|
|
6
|
+
import { type GatewayVideoModel } from "./video-model.js";
|
|
3
7
|
type Provider = ReturnType<typeof createOpenAICompatible>;
|
|
4
8
|
type ChatModel = ReturnType<Provider>;
|
|
5
9
|
type EmbeddingModel = ReturnType<typeof wrapEmbeddingModel>;
|
|
6
10
|
type ImageModel = ReturnType<Provider["imageModel"]>;
|
|
11
|
+
type SpeechModel = ReturnType<ReturnType<typeof createOpenAI>["speech"]>;
|
|
7
12
|
type GatewayLanguageModel = ReturnType<typeof wrapLanguageModel>;
|
|
13
|
+
export interface GatewayModelOptions {
|
|
14
|
+
/** Require an inference endpoint with a zero-data-retention policy. */
|
|
15
|
+
zdr?: boolean;
|
|
16
|
+
}
|
|
8
17
|
/**
|
|
9
18
|
* The recommended model interface for text generation through the Convex AI gateway.
|
|
10
19
|
* Use `messages` or `responses` only for endpoint-specific features.
|
|
@@ -12,42 +21,42 @@ type GatewayLanguageModel = ReturnType<typeof wrapLanguageModel>;
|
|
|
12
21
|
* `getServiceToken` caches and refreshes credentials within the current action,
|
|
13
22
|
* so calling this more than once in the same action is fine.
|
|
14
23
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
24
|
+
declare function convexGateway(modelId: string, options?: GatewayModelOptions): ChatModel;
|
|
25
|
+
declare function messages(modelId: string, options?: GatewayModelOptions): GatewayLanguageModel;
|
|
26
|
+
declare function responses(modelId: string, options?: GatewayModelOptions): GatewayLanguageModel;
|
|
27
|
+
/** Decide typed questions through the alpha Decisions API. */
|
|
28
|
+
declare function decisionModel(modelId: string, options?: GatewayModelOptions): DecisionModel;
|
|
29
|
+
declare function embeddingModel(modelId: string, options?: GatewayModelOptions): EmbeddingModel;
|
|
30
|
+
/** Image model for the AI SDK's `generateImage`. */
|
|
31
|
+
declare function imageModel(modelId: string): ImageModel;
|
|
32
|
+
/** Speech-to-text for the AI SDK's `experimental_transcribe`. */
|
|
33
|
+
declare function transcriptionModel(modelId: string): TranscriptionModel;
|
|
34
|
+
/**
|
|
35
|
+
* Text-to-speech for the AI SDK's `experimental_generateSpeech`. The gateway
|
|
36
|
+
* reports speech cost after the call, so results carry no cost metadata.
|
|
37
|
+
*/
|
|
38
|
+
declare function speechModel(modelId: string): SpeechModel;
|
|
39
|
+
/** Video generation for the AI SDK's `experimental_generateVideo`. */
|
|
40
|
+
declare function videoModel(modelId: string): GatewayVideoModel;
|
|
41
|
+
/**
|
|
42
|
+
* The recommended model interface for text generation through the Convex AI gateway.
|
|
43
|
+
* Use `messages` or `responses` only for endpoint-specific features.
|
|
44
|
+
*
|
|
45
|
+
* `getServiceToken` caches and refreshes credentials within the current action,
|
|
46
|
+
* so calling this more than once in the same action is fine.
|
|
47
|
+
*/
|
|
48
|
+
declare const gateway: typeof convexGateway & {
|
|
49
|
+
messages: typeof messages;
|
|
50
|
+
responses: typeof responses;
|
|
51
|
+
decisionModel: typeof decisionModel;
|
|
52
|
+
/** @deprecated Use `decisionModel` instead. */
|
|
53
|
+
evaluationModel: typeof decisionModel;
|
|
54
|
+
embeddingModel: typeof embeddingModel;
|
|
55
|
+
imageModel: typeof imageModel;
|
|
56
|
+
transcriptionModel: typeof transcriptionModel;
|
|
57
|
+
speechModel: typeof speechModel;
|
|
58
|
+
videoModel: typeof videoModel;
|
|
59
|
+
};
|
|
60
|
+
export { gateway as convexGateway };
|
|
52
61
|
export { verifyVideoWebhook, type VideoWebhookEvent } from "./video-webhook.js";
|
|
53
62
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,sBAAsB,EAEvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE5E,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC1D,KAAK,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;AACtC,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI5D,KAAK,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;AACrD,KAAK,WAAW,GAAG,UAAU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C"}
|
package/dist/commonjs/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyVideoWebhook = void 0;
|
|
4
|
-
exports.convexGateway = convexGateway;
|
|
3
|
+
exports.verifyVideoWebhook = exports.convexGateway = void 0;
|
|
5
4
|
const anthropic_1 = require("@ai-sdk/anthropic");
|
|
6
5
|
const openai_1 = require("@ai-sdk/openai");
|
|
7
6
|
const openai_compatible_1 = require("@ai-sdk/openai-compatible");
|
|
8
7
|
const ai_1 = require("ai");
|
|
9
8
|
const server_1 = require("convex/server");
|
|
10
|
-
const
|
|
9
|
+
const decision_model_js_1 = require("./decision-model.js");
|
|
10
|
+
const transcription_model_js_1 = require("./transcription-model.js");
|
|
11
11
|
const video_model_js_1 = require("./video-model.js");
|
|
12
12
|
const maxEmbeddingsPerCall = 512;
|
|
13
13
|
// Official providers require a credential before gatewayFetch replaces it with a deployment JWT.
|
|
@@ -57,11 +57,11 @@ const costMetadataExtractor = {
|
|
|
57
57
|
};
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
|
-
function createGatewayProvider() {
|
|
60
|
+
function createGatewayProvider(fetch = gatewayFetch) {
|
|
61
61
|
return (0, openai_compatible_1.createOpenAICompatible)({
|
|
62
62
|
name: "convexGateway",
|
|
63
63
|
baseURL: gatewayBaseURL(),
|
|
64
|
-
fetch
|
|
64
|
+
fetch,
|
|
65
65
|
metadataExtractor: costMetadataExtractor,
|
|
66
66
|
supportsStructuredOutputs: true,
|
|
67
67
|
supportedUrls: () => ({ "image/*": [/^https?:\/\/.*$/] }),
|
|
@@ -75,9 +75,12 @@ function sdkModelId(gatewayModelId, provider) {
|
|
|
75
75
|
// OpenRouter uses dots in Anthropic versions; the Anthropic SDK's capability lookup uses hyphens.
|
|
76
76
|
return provider === "anthropic" ? modelId.replaceAll(".", "-") : modelId;
|
|
77
77
|
}
|
|
78
|
-
function gatewayModelFetch(gatewayModelId, input, init) {
|
|
78
|
+
function gatewayModelFetch(gatewayModelId, input, init, options) {
|
|
79
79
|
const body = JSON.parse(init?.body);
|
|
80
80
|
body.model = gatewayModelId;
|
|
81
|
+
if (options?.zdr !== undefined) {
|
|
82
|
+
body.provider = { ...body.provider, zdr: options.zdr };
|
|
83
|
+
}
|
|
81
84
|
return gatewayFetch(input, { ...init, body: JSON.stringify(body) });
|
|
82
85
|
}
|
|
83
86
|
function gatewayLanguageModel(modelId, model, middleware) {
|
|
@@ -95,50 +98,118 @@ function gatewayLanguageModel(modelId, model, middleware) {
|
|
|
95
98
|
* `getServiceToken` caches and refreshes credentials within the current action,
|
|
96
99
|
* so calling this more than once in the same action is fine.
|
|
97
100
|
*/
|
|
98
|
-
function convexGateway(modelId) {
|
|
99
|
-
return createGatewayProvider()(modelId);
|
|
101
|
+
function convexGateway(modelId, options) {
|
|
102
|
+
return createGatewayProvider((input, init) => gatewayModelFetch(modelId, input, init, options))(modelId);
|
|
100
103
|
}
|
|
101
|
-
|
|
104
|
+
function messages(modelId, options) {
|
|
102
105
|
const provider = (0, anthropic_1.createAnthropic)({
|
|
103
106
|
name: "convexGateway.messages",
|
|
104
107
|
baseURL: gatewayBaseURL(),
|
|
105
108
|
authToken: placeholderCredential,
|
|
106
|
-
fetch: (input, init) => gatewayModelFetch(modelId, input, init),
|
|
109
|
+
fetch: (input, init) => gatewayModelFetch(modelId, input, init, options),
|
|
107
110
|
});
|
|
108
111
|
return gatewayLanguageModel(modelId, provider.messages(sdkModelId(modelId, "anthropic")));
|
|
109
|
-
}
|
|
110
|
-
|
|
112
|
+
}
|
|
113
|
+
function responses(modelId, options) {
|
|
111
114
|
const provider = (0, openai_1.createOpenAI)({
|
|
112
115
|
name: "convexGateway.responses",
|
|
113
116
|
baseURL: gatewayBaseURL(),
|
|
114
117
|
apiKey: placeholderCredential,
|
|
115
|
-
fetch: (input, init) => gatewayModelFetch(modelId, input, init),
|
|
118
|
+
fetch: (input, init) => gatewayModelFetch(modelId, input, init, options),
|
|
116
119
|
});
|
|
117
120
|
return gatewayLanguageModel(modelId, provider.responses(sdkModelId(modelId, "openai")), (0, ai_1.defaultSettingsMiddleware)({
|
|
118
121
|
settings: { providerOptions: { openai: { store: false } } },
|
|
119
122
|
}));
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
return (0,
|
|
124
|
-
}
|
|
125
|
-
|
|
123
|
+
}
|
|
124
|
+
/** Decide typed questions through the alpha Decisions API. */
|
|
125
|
+
function decisionModel(modelId, options) {
|
|
126
|
+
return (0, decision_model_js_1.createDecisionModel)(modelId, gatewayBaseURL("alpha"), (input, init) => gatewayModelFetch(modelId, input, init, options), convexGatewayUsageMetadata);
|
|
127
|
+
}
|
|
128
|
+
function embeddingModel(modelId, options) {
|
|
126
129
|
return (0, ai_1.wrapEmbeddingModel)({
|
|
127
|
-
model: createGatewayProvider().embeddingModel(modelId),
|
|
130
|
+
model: createGatewayProvider((input, init) => gatewayModelFetch(modelId, input, init, options)).embeddingModel(modelId),
|
|
128
131
|
middleware: {
|
|
129
132
|
specificationVersion: "v4",
|
|
130
133
|
overrideMaxEmbeddingsPerCall: () => maxEmbeddingsPerCall,
|
|
131
134
|
},
|
|
132
135
|
});
|
|
133
|
-
}
|
|
136
|
+
}
|
|
134
137
|
/** Image model for the AI SDK's `generateImage`. */
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
function imageModel(modelId) {
|
|
139
|
+
const { specificationVersion, provider, maxImagesPerCall } = createGatewayProvider().imageModel(modelId);
|
|
140
|
+
return {
|
|
141
|
+
specificationVersion,
|
|
142
|
+
provider,
|
|
143
|
+
modelId,
|
|
144
|
+
maxImagesPerCall,
|
|
145
|
+
async doGenerate(options) {
|
|
146
|
+
if (options.files?.length || options.mask) {
|
|
147
|
+
throw new Error("Convex AI Gateway does not support image editing. Use a text prompt without input images or a mask.");
|
|
148
|
+
}
|
|
149
|
+
// The SDK's image adapter discards `usage` and has no metadata hook, so
|
|
150
|
+
// each call reads it from its own response through a per-call fetch.
|
|
151
|
+
let usage;
|
|
152
|
+
const model = createGatewayProvider(async (input, init) => {
|
|
153
|
+
const response = await gatewayFetch(input, init);
|
|
154
|
+
if (response.ok) {
|
|
155
|
+
usage = (await response.clone().json()).usage;
|
|
156
|
+
}
|
|
157
|
+
return response;
|
|
158
|
+
}).imageModel(modelId);
|
|
159
|
+
const result = await model.doGenerate(options);
|
|
160
|
+
const metadata = convexGatewayUsageMetadata(usage)?.convexGateway;
|
|
161
|
+
return {
|
|
162
|
+
...result,
|
|
163
|
+
...(metadata && {
|
|
164
|
+
// The SDK's image metadata type requires a per-image `images` array.
|
|
165
|
+
providerMetadata: { convexGateway: { ...metadata, images: [] } },
|
|
166
|
+
}),
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** Speech-to-text for the AI SDK's `experimental_transcribe`. */
|
|
172
|
+
function transcriptionModel(modelId) {
|
|
173
|
+
return (0, transcription_model_js_1.createTranscriptionModel)(modelId, gatewayBaseURL(), gatewayFetch, convexGatewayUsageMetadata);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Text-to-speech for the AI SDK's `experimental_generateSpeech`. The gateway
|
|
177
|
+
* reports speech cost after the call, so results carry no cost metadata.
|
|
178
|
+
*/
|
|
179
|
+
function speechModel(modelId) {
|
|
180
|
+
const provider = (0, openai_1.createOpenAI)({
|
|
181
|
+
name: "convexGateway.speech",
|
|
182
|
+
baseURL: gatewayBaseURL(),
|
|
183
|
+
apiKey: placeholderCredential,
|
|
184
|
+
fetch: (input, init) => gatewayModelFetch(modelId, input, init),
|
|
185
|
+
});
|
|
186
|
+
return provider.speech(modelId);
|
|
187
|
+
}
|
|
138
188
|
/** Video generation for the AI SDK's `experimental_generateVideo`. */
|
|
139
|
-
|
|
189
|
+
function videoModel(modelId) {
|
|
140
190
|
return (0, video_model_js_1.createVideoModel)(modelId, gatewayBaseURL(), gatewayFetch, convexGatewayUsageMetadata);
|
|
141
|
-
}
|
|
191
|
+
}
|
|
192
|
+
// Editors show this copy on hover over the import and the function's copy on calls and signature help.
|
|
193
|
+
/**
|
|
194
|
+
* The recommended model interface for text generation through the Convex AI gateway.
|
|
195
|
+
* Use `messages` or `responses` only for endpoint-specific features.
|
|
196
|
+
*
|
|
197
|
+
* `getServiceToken` caches and refreshes credentials within the current action,
|
|
198
|
+
* so calling this more than once in the same action is fine.
|
|
199
|
+
*/
|
|
200
|
+
const gateway = Object.assign(convexGateway, {
|
|
201
|
+
messages,
|
|
202
|
+
responses,
|
|
203
|
+
decisionModel,
|
|
204
|
+
/** @deprecated Use `decisionModel` instead. */
|
|
205
|
+
evaluationModel: decisionModel,
|
|
206
|
+
embeddingModel,
|
|
207
|
+
imageModel,
|
|
208
|
+
transcriptionModel,
|
|
209
|
+
speechModel,
|
|
210
|
+
videoModel,
|
|
211
|
+
});
|
|
212
|
+
exports.convexGateway = gateway;
|
|
142
213
|
var video_webhook_js_1 = require("./video-webhook.js");
|
|
143
214
|
Object.defineProperty(exports, "verifyVideoWebhook", { enumerable: true, get: function () { return video_webhook_js_1.verifyVideoWebhook; } });
|
|
144
215
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAoD;AACpD,2CAA8C;AAC9C,iEAGmC;AACnC,2BAIY;AACZ,0CAAgD;AAChD,2DAA8E;AAC9E,qEAGkC;AAClC,qDAA4E;AAkB5E,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,iGAAiG;AACjG,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C;;;GAGG;AACH,MAAM,qBAAqB,GAAG,+BAA+B,CAAC;AAE9D,SAAS,cAAc,CA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S,kBAAkB,CAAC,OAAe;IACzC,OAAO,IAAA,iDAAwB,EAC7B,OAAO,EACP,cAAc,EAAE,EAChB,YAAY,EACZ,0BAA0B,CAC3B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,OAAe;IAClC,MAAM,QAAQ,GAAG,IAAA,qBAAY,EAAC;QAC5B,IAAI,EAAE,sBAAsB;QAC5B,OAAO,EAAE,cAAc,EAAE;QACzB,MAAM,EAAE,qBAAqB;QAC7B,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;KAChE,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAED,sEAAsE;AACtE,SAAS,UAAU,CAAC,OAAe;IACjC,OAAO,IAAA,iCAAgB,EACrB,OAAO,EACP,cAAc,EAAE,EAChB,YAAY,EACZ,0BAA0B,CAC3B,CAAC;AACJ,CAAC;AAED,uGAAuG;AACvG;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE;IAC3C,QAAQ;IACR,SAAS;IACT,aAAa;IACb,+CAA+C;IAC/C,eAAe,EAAE,aAAa;IAC9B,cAAc;IACd,UAAU;IACV,kBAAkB;IAClB,WAAW;IACX,UAAU;CACX,CAAC,CAAC;AAEiB,gCAAa;AAEjC,uDAAgF;AAAvE,sHAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type experimental_transcribe as transcribe, type ProviderMetadata } from "ai";
|
|
2
|
+
export type TranscriptionModel = Extract<Parameters<typeof transcribe>[0]["model"], {
|
|
3
|
+
specificationVersion: "v4";
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* The gateway accepts JSON only, so this model sends base64 audio instead of
|
|
7
|
+
* the multipart upload `@ai-sdk/openai` uses.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createTranscriptionModel(modelId: string, baseURL: string, fetch: typeof globalThis.fetch, usageMetadata: (usage: unknown) => ProviderMetadata | undefined): TranscriptionModel;
|
|
10
|
+
//# sourceMappingURL=transcription-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcription-model.d.ts","sourceRoot":"","sources":["../../src/transcription-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,IAAI,UAAU,EAC1C,KAAK,gBAAgB,EACtB,MAAM,IAAI,CAAC;AAEZ,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACtC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EACzC;IAAE,oBAAoB,EAAE,IAAI,CAAA;CAAE,CAC/B,CAAC;AAmCF;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,EAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,gBAAgB,GAAG,SAAS,GAC9D,kBAAkB,CA+EpB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTranscriptionModel = createTranscriptionModel;
|
|
4
|
+
const ai_1 = require("ai");
|
|
5
|
+
// OpenRouter names formats by extension, not media type.
|
|
6
|
+
const audioFormats = {
|
|
7
|
+
"audio/mpeg": "mp3",
|
|
8
|
+
"audio/mp3": "mp3",
|
|
9
|
+
"audio/mpga": "mp3",
|
|
10
|
+
"audio/x-mp3": "mp3",
|
|
11
|
+
"audio/wav": "wav",
|
|
12
|
+
"audio/wave": "wav",
|
|
13
|
+
"audio/x-wav": "wav",
|
|
14
|
+
"audio/flac": "flac",
|
|
15
|
+
"audio/x-flac": "flac",
|
|
16
|
+
"audio/mp4": "m4a",
|
|
17
|
+
"audio/m4a": "m4a",
|
|
18
|
+
"audio/x-m4a": "m4a",
|
|
19
|
+
"audio/ogg": "ogg",
|
|
20
|
+
"audio/webm": "webm",
|
|
21
|
+
"audio/aac": "aac",
|
|
22
|
+
};
|
|
23
|
+
function base64(audio) {
|
|
24
|
+
if (typeof audio === "string")
|
|
25
|
+
return audio;
|
|
26
|
+
// Chunked so large recordings stay under the engine's argument limit.
|
|
27
|
+
let binary = "";
|
|
28
|
+
for (let i = 0; i < audio.length; i += 0x8000) {
|
|
29
|
+
binary += String.fromCharCode(...audio.subarray(i, i + 0x8000));
|
|
30
|
+
}
|
|
31
|
+
return btoa(binary);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The gateway accepts JSON only, so this model sends base64 audio instead of
|
|
35
|
+
* the multipart upload `@ai-sdk/openai` uses.
|
|
36
|
+
*/
|
|
37
|
+
function createTranscriptionModel(modelId, baseURL, fetch, usageMetadata) {
|
|
38
|
+
return {
|
|
39
|
+
specificationVersion: "v4",
|
|
40
|
+
provider: "convexGateway",
|
|
41
|
+
modelId,
|
|
42
|
+
async doGenerate(options) {
|
|
43
|
+
const format = audioFormats[options.mediaType.split(";")[0].trim().toLowerCase()];
|
|
44
|
+
if (!format) {
|
|
45
|
+
throw new Error(`Unsupported audio type for the Convex AI gateway: ${options.mediaType}`);
|
|
46
|
+
}
|
|
47
|
+
const extra = options.providerOptions?.convexGateway ?? {};
|
|
48
|
+
const headers = new Headers();
|
|
49
|
+
for (const [key, value] of Object.entries(options.headers ?? {})) {
|
|
50
|
+
if (value !== undefined)
|
|
51
|
+
headers.set(key, value);
|
|
52
|
+
}
|
|
53
|
+
headers.set("Content-Type", "application/json");
|
|
54
|
+
const timestamp = new Date();
|
|
55
|
+
const url = `${baseURL}/audio/transcriptions`;
|
|
56
|
+
const requestBody = {
|
|
57
|
+
...extra,
|
|
58
|
+
model: modelId,
|
|
59
|
+
input_audio: { data: base64(options.audio), format },
|
|
60
|
+
};
|
|
61
|
+
const response = await fetch(url, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers,
|
|
64
|
+
signal: options.abortSignal,
|
|
65
|
+
body: JSON.stringify(requestBody),
|
|
66
|
+
});
|
|
67
|
+
// A proxy error page is not JSON; the status message covers it.
|
|
68
|
+
const body = (await response.json().catch(() => ({})));
|
|
69
|
+
if (!response.ok || typeof body.text !== "string") {
|
|
70
|
+
throw new ai_1.APICallError({
|
|
71
|
+
message: body.error?.message ?? `Transcription failed (${response.status})`,
|
|
72
|
+
url,
|
|
73
|
+
requestBodyValues: requestBody,
|
|
74
|
+
statusCode: response.status,
|
|
75
|
+
responseHeaders: Object.fromEntries(response.headers),
|
|
76
|
+
responseBody: JSON.stringify(body),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const duration = body.duration ?? body.usage?.seconds;
|
|
80
|
+
return {
|
|
81
|
+
text: body.text,
|
|
82
|
+
// Present with `response_format: "verbose_json"`.
|
|
83
|
+
segments: (Array.isArray(body.segments) ? body.segments : []).flatMap(({ text, start, end }) => typeof text === "string" &&
|
|
84
|
+
typeof start === "number" &&
|
|
85
|
+
typeof end === "number"
|
|
86
|
+
? [{ text, startSecond: start, endSecond: end }]
|
|
87
|
+
: []),
|
|
88
|
+
language: typeof body.language === "string" ? body.language : undefined,
|
|
89
|
+
durationInSeconds: typeof duration === "number" ? duration : undefined,
|
|
90
|
+
warnings: [],
|
|
91
|
+
providerMetadata: usageMetadata(body.usage),
|
|
92
|
+
response: {
|
|
93
|
+
timestamp,
|
|
94
|
+
modelId,
|
|
95
|
+
headers: Object.fromEntries(response.headers),
|
|
96
|
+
body,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=transcription-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcription-model.js","sourceRoot":"","sources":["../../src/transcription-model.ts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AgB,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC3C,QAAQ,EAAE;oBACR,SAAS;oBACT,OAAO;oBACP,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC;oBAC7C,IAAI;iBACL;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -21,7 +21,7 @@ type StatusResult = {
|
|
|
21
21
|
status: "error";
|
|
22
22
|
error: string;
|
|
23
23
|
});
|
|
24
|
-
type GatewayVideoModel = Omit<VideoModel, "doStatus" | "handleWebhookOption"> & {
|
|
24
|
+
export type GatewayVideoModel = Omit<VideoModel, "doStatus" | "handleWebhookOption"> & {
|
|
25
25
|
doStart(options: VideoOptions & {
|
|
26
26
|
webhookUrl?: string;
|
|
27
27
|
}): Promise<StartResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video-model.d.ts","sourceRoot":"","sources":["../../src/video-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,SAAS,EACT,gBAAgB,EACjB,MAAM,IAAI,CAAC;AAEZ,KAAK,UAAU,GAAG,OAAO,CACvB,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EACzD;IAAE,oBAAoB,EAAE,IAAI,CAAA;CAAE,CAC/B,CAAC;AACF,KAAK,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,KAAK,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9E,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,WAA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AS,CAAA;CAAE,CAAC;AAC1E,KAAK,YAAY,GAAG;IAClB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;CACnC,GAAG,CAAC;IAAE,MAAM,EAAE,SAAS,GAAG,WAAW,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAC/E,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,UAAU,EACV,UAAU,GAAG,qBAAqB,CACnC,GAAG;IACF,OAAO,CACL,OAAO,EAAE,YAAY,GAAG;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9C,OAAO,CAAC,WAAW,CAAC,CAAC;IACxB,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACzD,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACxD,CAAC;AAoHF,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,EAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,gBAAgB,GAAG,SAAS,GAC9D,iBAAiB,CA4GnB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type experimental_evaluate, type ProviderMetadata } from "ai";
|
|
2
|
+
export type DecisionModel = Exclude<Parameters<typeof experimental_evaluate>[0]["model"], string>;
|
|
3
|
+
export declare function createDecisionModel(modelId: string, baseURL: string, fetch: typeof globalThis.fetch, usageMetadata: (usage: unknown) => ProviderMetadata | undefined): DecisionModel;
|
|
4
|
+
//# sourceMappingURL=decision-model.d.ts.map
|