@opencode/ai 0.0.0-dev-20120 → 0.0.0-dev-20123
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/dist/experimental/evaluation.js +1 -1
- package/dist/generation.d.ts +1 -7
- package/dist/generation.js +1 -11
- package/dist/image.d.ts +2 -2
- package/dist/image.js +2 -2
- package/dist/llm.js +1 -1
- package/dist/media-model.d.ts +0 -2
- package/dist/media-model.js +0 -2
- package/dist/protocols/alibaba-messages.d.ts +1 -1
- package/dist/protocols/anthropic-messages.d.ts +34 -34
- package/dist/protocols/assemblyai-transcription.d.ts +2 -1
- package/dist/protocols/assemblyai-transcription.js +10 -14
- package/dist/protocols/bfl-images.js +15 -31
- package/dist/protocols/cartesia-speech.d.ts +2 -2
- package/dist/protocols/cartesia-speech.js +10 -16
- package/dist/protocols/deepgram-speech.d.ts +3 -3
- package/dist/protocols/deepgram-speech.js +7 -11
- package/dist/protocols/deepgram-transcription.d.ts +2 -1
- package/dist/protocols/deepgram-transcription.js +9 -13
- package/dist/protocols/elevenlabs-speech.d.ts +3 -3
- package/dist/protocols/elevenlabs-speech.js +9 -13
- package/dist/protocols/fal-images.d.ts +2 -1
- package/dist/protocols/fal-images.js +16 -29
- package/dist/protocols/fal-video.d.ts +2 -2
- package/dist/protocols/fal-video.js +9 -24
- package/dist/protocols/gemini.d.ts +13 -13
- package/dist/protocols/google-images.d.ts +3 -3
- package/dist/protocols/google-images.js +11 -21
- package/dist/protocols/google-speech.js +7 -13
- package/dist/protocols/google-transcription.d.ts +2 -1
- package/dist/protocols/google-transcription.js +8 -20
- package/dist/protocols/google-video.d.ts +2 -2
- package/dist/protocols/google-video.js +14 -30
- package/dist/protocols/meta-images.d.ts +3 -4
- package/dist/protocols/meta-images.js +12 -21
- package/dist/protocols/meta-messages.d.ts +5 -5
- package/dist/protocols/meta-responses.js +5 -2
- package/dist/protocols/mistral-chat.js +6 -3
- package/dist/protocols/openai-images.d.ts +4 -5
- package/dist/protocols/openai-images.js +24 -55
- package/dist/protocols/openai-responses.js +8 -2
- package/dist/protocols/openai-speech.js +7 -11
- package/dist/protocols/openai-transcription.js +21 -29
- package/dist/protocols/replicate-images.js +11 -17
- package/dist/protocols/runway-video.d.ts +3 -3
- package/dist/protocols/runway-video.js +10 -16
- package/dist/protocols/shared.d.ts +5 -17
- package/dist/protocols/shared.js +3 -39
- package/dist/protocols/stability-images.d.ts +2 -1
- package/dist/protocols/stability-images.js +24 -36
- package/dist/protocols/utils/fal-queue.d.ts +1 -3
- package/dist/protocols/utils/fal-queue.js +4 -6
- package/dist/protocols/utils/media-input.d.ts +15 -1
- package/dist/protocols/utils/media-input.js +22 -0
- package/dist/protocols/utils/speech-stream.d.ts +3 -3
- package/dist/protocols/utils/speech-stream.js +1 -4
- package/dist/protocols/utils/tool-schema.js +19 -6
- package/dist/protocols/xai-images.d.ts +4 -4
- package/dist/protocols/xai-images.js +12 -28
- package/dist/protocols/xai-video.js +12 -18
- package/dist/protocols/zai-images.d.ts +2 -2
- package/dist/protocols/zai-images.js +8 -11
- package/dist/protocols/zai-messages.d.ts +1 -1
- package/dist/providers/alibaba.d.ts +1 -1
- package/dist/providers/anthropic-compatible.d.ts +5 -5
- package/dist/providers/anthropic.d.ts +5 -5
- package/dist/providers/assemblyai.d.ts +1 -1
- package/dist/providers/assemblyai.js +5 -10
- package/dist/providers/azure.js +2 -2
- package/dist/providers/black-forest-labs.d.ts +1 -1
- package/dist/providers/black-forest-labs.js +5 -10
- package/dist/providers/cartesia.d.ts +1 -1
- package/dist/providers/cartesia.js +5 -10
- package/dist/providers/cloudflare-ai-gateway.d.ts +10 -10
- package/dist/providers/deepgram.d.ts +1 -1
- package/dist/providers/deepgram.js +6 -12
- package/dist/providers/elevenlabs.d.ts +1 -1
- package/dist/providers/elevenlabs.js +5 -10
- package/dist/providers/fal.d.ts +1 -1
- package/dist/providers/fal.js +5 -12
- package/dist/providers/google-vertex-messages.d.ts +5 -5
- package/dist/providers/google-vertex.d.ts +3 -3
- package/dist/providers/google.d.ts +3 -3
- package/dist/providers/google.js +7 -12
- package/dist/providers/meta.d.ts +8 -8
- package/dist/providers/meta.js +4 -8
- package/dist/providers/minimax.d.ts +5 -5
- package/dist/providers/moonshot.d.ts +5 -5
- package/dist/providers/openai.d.ts +7 -8
- package/dist/providers/openai.js +10 -11
- package/dist/providers/opencode-zen.js +1 -1
- package/dist/providers/openrouter.d.ts +6 -7
- package/dist/providers/openrouter.js +1 -1
- package/dist/providers/replicate.d.ts +1 -1
- package/dist/providers/replicate.js +5 -10
- package/dist/providers/runway.d.ts +1 -1
- package/dist/providers/runway.js +5 -10
- package/dist/providers/stability.d.ts +1 -1
- package/dist/providers/stability.js +6 -11
- package/dist/providers/typesafe-ai.js +1 -1
- package/dist/providers/vercel-ai-gateway.js +1 -1
- package/dist/providers/xai.js +5 -10
- package/dist/providers/zai-coding-plan.d.ts +1 -1
- package/dist/providers/zai.js +4 -8
- package/dist/route/client.d.ts +0 -1
- package/dist/route/client.js +1 -6
- package/dist/route/endpoint.d.ts +1 -0
- package/dist/route/endpoint.js +2 -2
- package/dist/route/framing.d.ts +10 -1
- package/dist/route/framing.js +45 -5
- package/dist/route/media-protocol.d.ts +42 -35
- package/dist/route/media-protocol.js +67 -62
- package/dist/route/media.d.ts +6 -2
- package/dist/route/media.js +40 -29
- package/dist/schema/options.d.ts +6 -3
- package/dist/schema/options.js +7 -3
- package/dist/speech.d.ts +2 -2
- package/dist/speech.js +2 -2
- package/dist/transcription.js +2 -2
- package/dist/utils/json.d.ts +4 -0
- package/dist/utils/json.js +4 -0
- package/dist/video.d.ts +2 -2
- package/dist/video.js +2 -2
- package/package.json +3 -3
- package/dist/protocols/utils/meta-image.d.ts +0 -2
- package/dist/protocols/utils/meta-image.js +0 -13
- package/dist/protocols/utils/openai-image.d.ts +0 -5
- package/dist/protocols/utils/openai-image.js +0 -18
|
@@ -2,12 +2,10 @@ import { Effect, Schema } from "effect";
|
|
|
2
2
|
import { Media } from "../media.js";
|
|
3
3
|
import { MediaProtocol } from "../route/media-protocol.js";
|
|
4
4
|
import { MediaRoute } from "../route/media.js";
|
|
5
|
-
import {
|
|
5
|
+
import { mergeJsonRecords } from "../schema/index.js";
|
|
6
6
|
import { VideoModel, VideoResponse } from "../video.js";
|
|
7
7
|
import { ProviderShared, optionalNull } from "./shared.js";
|
|
8
|
-
const
|
|
9
|
-
const NAME = "xAI Video";
|
|
10
|
-
const PROVIDER = ProviderID.make("xai");
|
|
8
|
+
const route = MediaProtocol.identity({ id: "xai-video", name: "xAI Video", provider: "xai" });
|
|
11
9
|
export const DEFAULT_BASE_URL = "https://api.x.ai/v1";
|
|
12
10
|
export const PATH = "/videos/generations";
|
|
13
11
|
export const EDIT_PATH = "/videos/edits";
|
|
@@ -41,7 +39,7 @@ const STATUS = {
|
|
|
41
39
|
// ---------------------------------------------------------------------------
|
|
42
40
|
// 5. Request body construction
|
|
43
41
|
// ---------------------------------------------------------------------------
|
|
44
|
-
const mediaInput = (asset) => ProviderShared.mediaReference(asset,
|
|
42
|
+
const mediaInput = (asset) => ProviderShared.mediaReference(asset, route.provider, route.name).pipe(Effect.map((reference) => (reference.type === "ref" ? { file_id: reference.value } : { url: reference.value })));
|
|
45
43
|
const nativeOptions = (options) => {
|
|
46
44
|
if (!options)
|
|
47
45
|
return undefined;
|
|
@@ -69,13 +67,13 @@ const fromRequest = Effect.fn("XAIVideo.fromRequest")(function* (request) {
|
|
|
69
67
|
// ---------------------------------------------------------------------------
|
|
70
68
|
// 6. Response decoding
|
|
71
69
|
// ---------------------------------------------------------------------------
|
|
72
|
-
const decodeStart =
|
|
70
|
+
const decodeStart = route.decodeStarted(StartResponse, (value) => ({
|
|
73
71
|
token: { requestID: value.request_id },
|
|
74
72
|
snapshot: { id: value.request_id, status: "running" },
|
|
75
73
|
}));
|
|
76
74
|
// `progress` is undocumented but observed live as a 0..100 percentage (recorded cassette: 1 → 10 → 37 → 100).
|
|
77
75
|
const fraction = (progress) => progress !== undefined && progress !== null && progress >= 0 && progress <= 100 ? progress / 100 : undefined;
|
|
78
|
-
const decodeVideoStatus =
|
|
76
|
+
const decodeVideoStatus = route.decodeJson(VideoStatus);
|
|
79
77
|
const decodeStatus = Effect.fn("XAIVideo.decodeStatus")(function* (response, context) {
|
|
80
78
|
const output = yield* decodeVideoStatus(response);
|
|
81
79
|
const status = yield* MediaProtocol.status(STATUS, output.value.status, output);
|
|
@@ -86,23 +84,23 @@ const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, con
|
|
|
86
84
|
const decoded = output.value;
|
|
87
85
|
const status = yield* MediaProtocol.status(STATUS, decoded.status, output);
|
|
88
86
|
if (status === "running")
|
|
89
|
-
return yield* output.invalid(`${
|
|
87
|
+
return yield* output.invalid(`${route.name} request ${context.token.requestID} has not finished`);
|
|
90
88
|
if (status === "failed") {
|
|
91
89
|
const code = decoded.error?.code ?? undefined;
|
|
92
90
|
const message = decoded.error?.message ?? undefined;
|
|
93
|
-
return yield* output.ended("failed", `${
|
|
91
|
+
return yield* output.ended("failed", `${route.name} generation failed${code === undefined ? "" : ` (${code})`}${message === undefined ? "" : `: ${message}`}`);
|
|
94
92
|
}
|
|
95
93
|
if (status !== "completed")
|
|
96
|
-
return yield* output.ended("expired", `${
|
|
94
|
+
return yield* output.ended("expired", `${route.name} request ${context.token.requestID} expired`);
|
|
97
95
|
// `respect_moderation: false` marks a filtered result; a URL may still be present, so report it as a notice.
|
|
98
96
|
const notices = decoded.video?.respect_moderation === false
|
|
99
|
-
? [{ type: "moderated", message: `${
|
|
97
|
+
? [{ type: "moderated", message: `${route.name} flagged the generated video for moderation` }]
|
|
100
98
|
: undefined;
|
|
101
99
|
const url = decoded.video?.url ?? undefined;
|
|
102
100
|
if (url === undefined && notices !== undefined)
|
|
103
|
-
return yield* output.contentPolicy(`${
|
|
101
|
+
return yield* output.contentPolicy(`${route.name} withheld the video for moderation`);
|
|
104
102
|
if (url === undefined)
|
|
105
|
-
return yield* output.invalid(`${
|
|
103
|
+
return yield* output.invalid(`${route.name} completed without a video URL`);
|
|
106
104
|
const duration = decoded.video?.duration ?? undefined;
|
|
107
105
|
return new VideoResponse({
|
|
108
106
|
videos: [
|
|
@@ -119,9 +117,7 @@ const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, con
|
|
|
119
117
|
// 7. Protocol and route
|
|
120
118
|
// ---------------------------------------------------------------------------
|
|
121
119
|
const statusPath = (token) => `${STATUS_PATH}/${token.requestID}`;
|
|
122
|
-
export const protocol = MediaProtocol.queued({
|
|
123
|
-
id: ADAPTER,
|
|
124
|
-
name: NAME,
|
|
120
|
+
export const protocol = MediaProtocol.queued(route, {
|
|
125
121
|
token: Token,
|
|
126
122
|
unsupported: ["n", "seed", "negativePrompt"],
|
|
127
123
|
start: { body: { from: fromRequest }, decode: decodeStart },
|
|
@@ -135,8 +131,6 @@ const startPath = (request) => {
|
|
|
135
131
|
return request.providerOptions?.mode === "extend" ? EXTEND_PATH : EDIT_PATH;
|
|
136
132
|
};
|
|
137
133
|
export const model = (input) => VideoModel.fromRoute({
|
|
138
|
-
id: ADAPTER,
|
|
139
|
-
provider: PROVIDER,
|
|
140
134
|
protocol,
|
|
141
135
|
baseURL: DEFAULT_BASE_URL,
|
|
142
136
|
path: ({ request }) => startPath(request),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ImageModel, ImageResponse, type ImageRequestFor } from "../image.js";
|
|
2
2
|
import { MediaProtocol } from "../route/media-protocol.js";
|
|
3
3
|
import { MediaRoute } from "../route/media.js";
|
|
4
|
+
import { type OpenString } from "../schema/index.js";
|
|
4
5
|
export declare const DEFAULT_BASE_URL = "https://api.z.ai/api/paas/v4";
|
|
5
6
|
export declare const PATH = "/images/generations";
|
|
6
|
-
export type ZAIImageString<Known extends string> = Known | (string & {});
|
|
7
7
|
/** Provider-native options. The common `size` field lives on the request. */
|
|
8
8
|
export type ZAIImageOptions = {
|
|
9
|
-
readonly quality?:
|
|
9
|
+
readonly quality?: OpenString<"hd" | "standard">;
|
|
10
10
|
readonly userID?: string;
|
|
11
11
|
} & Record<string, unknown>;
|
|
12
12
|
export type Request = ImageRequestFor<ZAIImageOptions>;
|
|
@@ -3,10 +3,8 @@ import { ImageModel, ImageResponse } from "../image.js";
|
|
|
3
3
|
import { Media } from "../media.js";
|
|
4
4
|
import { MediaProtocol } from "../route/media-protocol.js";
|
|
5
5
|
import { MediaRoute } from "../route/media.js";
|
|
6
|
-
import {
|
|
7
|
-
const
|
|
8
|
-
const NAME = "Z.ai Images";
|
|
9
|
-
const PROVIDER = ProviderID.make("zai");
|
|
6
|
+
import { mergeJsonRecords } from "../schema/index.js";
|
|
7
|
+
const route = MediaProtocol.identity({ id: "zai-images", name: "Z.ai Images", provider: "zai" });
|
|
10
8
|
export const DEFAULT_BASE_URL = "https://api.z.ai/api/paas/v4";
|
|
11
9
|
export const PATH = "/images/generations";
|
|
12
10
|
// ---------------------------------------------------------------------------
|
|
@@ -37,11 +35,12 @@ const fromRequest = Effect.fn("ZAIImages.fromRequest")(function* (request) {
|
|
|
37
35
|
// ---------------------------------------------------------------------------
|
|
38
36
|
// 6. Response decoding
|
|
39
37
|
// ---------------------------------------------------------------------------
|
|
38
|
+
const decodeDocument = route.decodeJson(ZAIImageResponse);
|
|
40
39
|
const decodeResponse = Effect.fn("ZAIImages.decodeResponse")(function* (response) {
|
|
41
|
-
const output = yield*
|
|
40
|
+
const output = yield* decodeDocument(response);
|
|
42
41
|
const decoded = output.value;
|
|
43
42
|
if (decoded.data.length === 0)
|
|
44
|
-
return yield* output.invalid(`${
|
|
43
|
+
return yield* output.invalid(`${route.name} returned no images`);
|
|
45
44
|
const filters = decoded.content_filter ?? [];
|
|
46
45
|
return new ImageResponse({
|
|
47
46
|
// Z.ai returns only URLs and no content type; the media type resolves when the asset is materialized.
|
|
@@ -51,7 +50,7 @@ const decodeResponse = Effect.fn("ZAIImages.decodeResponse")(function* (response
|
|
|
51
50
|
? undefined
|
|
52
51
|
: filters.map((filter) => ({
|
|
53
52
|
type: "moderated",
|
|
54
|
-
message: `${
|
|
53
|
+
message: `${route.name} applied a content filter${filter.role === undefined ? "" : ` for ${filter.role}`}${filter.level === undefined ? "" : ` at level ${filter.level}`}`,
|
|
55
54
|
providerMetadata: { zai: filter },
|
|
56
55
|
})),
|
|
57
56
|
providerMetadata: {
|
|
@@ -67,14 +66,12 @@ const decodeResponse = Effect.fn("ZAIImages.decodeResponse")(function* (response
|
|
|
67
66
|
// ---------------------------------------------------------------------------
|
|
68
67
|
// 7. Protocol and route
|
|
69
68
|
// ---------------------------------------------------------------------------
|
|
70
|
-
export const protocol = MediaProtocol.inline({
|
|
71
|
-
id: ADAPTER,
|
|
72
|
-
name: NAME,
|
|
69
|
+
export const protocol = MediaProtocol.inline(route, {
|
|
73
70
|
unsupported: ["images", "mask", "n", "aspectRatio", "seed", "format"],
|
|
74
71
|
body: { from: fromRequest },
|
|
75
72
|
response: { decode: decodeResponse },
|
|
76
73
|
});
|
|
77
|
-
export const model = (input) => ImageModel.fromRoute({
|
|
74
|
+
export const model = (input) => ImageModel.fromRoute({ protocol, baseURL: DEFAULT_BASE_URL, path: PATH }, input);
|
|
78
75
|
export const ZAIImages = {
|
|
79
76
|
protocol,
|
|
80
77
|
model,
|
|
@@ -222,7 +222,7 @@ export declare const protocol: Protocol<{
|
|
|
222
222
|
readonly thinking?: {
|
|
223
223
|
readonly type: string;
|
|
224
224
|
} | undefined;
|
|
225
|
-
readonly service_tier?: "auto" |
|
|
225
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
226
226
|
readonly container?: string | {
|
|
227
227
|
readonly id?: string | null | undefined;
|
|
228
228
|
readonly skills?: readonly {
|
|
@@ -372,7 +372,7 @@ export declare const routes: (Route<{
|
|
|
372
372
|
readonly type: string;
|
|
373
373
|
readonly budget_tokens?: number | undefined;
|
|
374
374
|
} | undefined;
|
|
375
|
-
readonly service_tier?: "auto" |
|
|
375
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
376
376
|
readonly container?: string | {
|
|
377
377
|
readonly id?: string | null | undefined;
|
|
378
378
|
readonly skills?: readonly {
|
|
@@ -238,20 +238,20 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
238
238
|
readonly thinking?: {
|
|
239
239
|
readonly type: "enabled";
|
|
240
240
|
readonly budget_tokens: number;
|
|
241
|
-
readonly display?: (
|
|
241
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
242
242
|
readonly block_binding?: {
|
|
243
|
-
readonly prefix_mismatch_behavior?: (
|
|
243
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
244
244
|
} | undefined;
|
|
245
245
|
} | {
|
|
246
246
|
readonly type: "adaptive";
|
|
247
|
-
readonly display?: (
|
|
247
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
248
248
|
readonly block_binding?: {
|
|
249
|
-
readonly prefix_mismatch_behavior?: (
|
|
249
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
250
250
|
} | undefined;
|
|
251
251
|
} | {
|
|
252
252
|
readonly type: "disabled";
|
|
253
253
|
} | undefined;
|
|
254
|
-
readonly service_tier?: "auto" |
|
|
254
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
255
255
|
readonly container?: string | {
|
|
256
256
|
readonly id?: string | null | undefined;
|
|
257
257
|
readonly skills?: readonly {
|
|
@@ -223,20 +223,20 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
223
223
|
readonly thinking?: {
|
|
224
224
|
readonly type: "enabled";
|
|
225
225
|
readonly budget_tokens: number;
|
|
226
|
-
readonly display?: (
|
|
226
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
227
227
|
readonly block_binding?: {
|
|
228
|
-
readonly prefix_mismatch_behavior?: (
|
|
228
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
229
229
|
} | undefined;
|
|
230
230
|
} | {
|
|
231
231
|
readonly type: "adaptive";
|
|
232
|
-
readonly display?: (
|
|
232
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
233
233
|
readonly block_binding?: {
|
|
234
|
-
readonly prefix_mismatch_behavior?: (
|
|
234
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
235
235
|
} | undefined;
|
|
236
236
|
} | {
|
|
237
237
|
readonly type: "disabled";
|
|
238
238
|
} | undefined;
|
|
239
|
-
readonly service_tier?: "auto" |
|
|
239
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
240
240
|
readonly container?: string | {
|
|
241
241
|
readonly id?: string | null | undefined;
|
|
242
242
|
readonly skills?: readonly {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { HttpOptions, type ModelID } from "../schema/index.js";
|
|
2
|
+
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
3
|
export type { AssemblyAITranscriptionOptions } from "../protocols/assemblyai-transcription.js";
|
|
4
4
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
5
|
export type Config = ProviderAuthOption<"optional"> & {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { MediaRoute } from "../route/media.js";
|
|
3
|
+
import { ProviderID } from "../schema/index.js";
|
|
4
|
+
import { AssemblyAITranscription } from "../protocols/assemblyai-transcription.js";
|
|
4
5
|
export const id = ProviderID.make("assemblyai");
|
|
5
|
-
const baseURL = DEFAULT_BASE_URL;
|
|
6
6
|
// The key is the whole `authorization` value, without a scheme.
|
|
7
7
|
const auth = (options) => {
|
|
8
8
|
if ("auth" in options && options.auth)
|
|
@@ -12,13 +12,8 @@ const auth = (options) => {
|
|
|
12
12
|
.pipe(Auth.header("authorization"));
|
|
13
13
|
};
|
|
14
14
|
export const configure = (input = {}) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
auth: auth(input),
|
|
18
|
-
baseURL: input.baseURL ?? baseURL,
|
|
19
|
-
headers: input.headers,
|
|
20
|
-
http: input.http === undefined ? undefined : HttpOptions.make(input.http),
|
|
21
|
-
});
|
|
15
|
+
const media = MediaRoute.deployment(input, auth(input));
|
|
16
|
+
const transcription = (modelID) => AssemblyAITranscription.model({ ...media, id: modelID });
|
|
22
17
|
return {
|
|
23
18
|
id,
|
|
24
19
|
transcription,
|
package/dist/providers/azure.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
2
|
import {} from "../route/auth-options.js";
|
|
3
|
+
import { Endpoint } from "../route/endpoint.js";
|
|
3
4
|
import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
|
|
4
5
|
import * as OpenAIChat from "../protocols/openai-chat.js";
|
|
5
6
|
import * as OpenAIResponses from "../protocols/openai-responses.js";
|
|
6
|
-
import { ProviderShared } from "../protocols/shared.js";
|
|
7
7
|
import { withOpenAIOptions } from "./openai-options.js";
|
|
8
8
|
export const id = ProviderID.make("azure");
|
|
9
9
|
const routeAuth = Auth.remove("authorization");
|
|
@@ -58,7 +58,7 @@ const configuredRoute = (route, input, modelID) => route.with({
|
|
|
58
58
|
endpoint: endpoint(input, modelID),
|
|
59
59
|
});
|
|
60
60
|
function endpoint(input, modelID) {
|
|
61
|
-
const baseURL =
|
|
61
|
+
const baseURL = Endpoint.trimBaseUrl(input.baseURL ?? resourceBaseURL(input.resourceName));
|
|
62
62
|
const query = { "api-version": input.apiVersion ?? "v1", ...input.queryParams };
|
|
63
63
|
if (input.useDeploymentBasedUrls)
|
|
64
64
|
return { baseURL: `${baseURL}/deployments/${modelID}`, query };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { HttpOptions, type ModelID } from "../schema/index.js";
|
|
2
|
+
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
3
|
export type { BlackForestLabsImageOptions } from "../protocols/bfl-images.js";
|
|
4
4
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
5
|
export type Config = ProviderAuthOption<"optional"> & {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { MediaRoute } from "../route/media.js";
|
|
3
|
+
import { ProviderID } from "../schema/index.js";
|
|
4
|
+
import { BlackForestLabsImages } from "../protocols/bfl-images.js";
|
|
4
5
|
export const id = ProviderID.make("black-forest-labs");
|
|
5
|
-
const baseURL = DEFAULT_BASE_URL;
|
|
6
6
|
const auth = (options) => {
|
|
7
7
|
if ("auth" in options && options.auth)
|
|
8
8
|
return options.auth;
|
|
@@ -11,13 +11,8 @@ const auth = (options) => {
|
|
|
11
11
|
.pipe(Auth.header("x-key"));
|
|
12
12
|
};
|
|
13
13
|
export const configure = (input = {}) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
auth: auth(input),
|
|
17
|
-
baseURL: input.baseURL ?? baseURL,
|
|
18
|
-
headers: input.headers,
|
|
19
|
-
http: input.http === undefined ? undefined : HttpOptions.make(input.http),
|
|
20
|
-
});
|
|
14
|
+
const media = MediaRoute.deployment(input, auth(input));
|
|
15
|
+
const image = (modelID) => BlackForestLabsImages.model({ ...media, id: modelID });
|
|
21
16
|
return {
|
|
22
17
|
id,
|
|
23
18
|
image,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { HttpOptions, type ModelID } from "../schema/index.js";
|
|
2
|
+
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
3
|
export type { CartesiaEncoding, CartesiaSpeechOptions } from "../protocols/cartesia-speech.js";
|
|
4
4
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
5
|
export type Config = ProviderAuthOption<"optional"> & {
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { AuthOptions } from "../route/auth-options.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { MediaRoute } from "../route/media.js";
|
|
3
|
+
import { ProviderID } from "../schema/index.js";
|
|
4
|
+
import { CartesiaSpeech } from "../protocols/cartesia-speech.js";
|
|
4
5
|
export const id = ProviderID.make("cartesia");
|
|
5
|
-
const baseURL = DEFAULT_BASE_URL;
|
|
6
6
|
const auth = (options) => AuthOptions.bearer(options, "CARTESIA_API_KEY");
|
|
7
7
|
export const configure = (input = {}) => {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
auth: auth(input),
|
|
11
|
-
baseURL: input.baseURL ?? baseURL,
|
|
12
|
-
headers: input.headers,
|
|
13
|
-
http: input.http === undefined ? undefined : HttpOptions.make(input.http),
|
|
14
|
-
});
|
|
8
|
+
const media = MediaRoute.deployment(input, auth(input));
|
|
9
|
+
const speech = (modelID) => CartesiaSpeech.model({ ...media, id: modelID });
|
|
15
10
|
return {
|
|
16
11
|
id,
|
|
17
12
|
speech,
|
|
@@ -474,20 +474,20 @@ export declare const messagesRoute: import("../route/client.js").Route<{
|
|
|
474
474
|
readonly thinking?: {
|
|
475
475
|
readonly type: "enabled";
|
|
476
476
|
readonly budget_tokens: number;
|
|
477
|
-
readonly display?: (
|
|
477
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
478
478
|
readonly block_binding?: {
|
|
479
|
-
readonly prefix_mismatch_behavior?: (
|
|
479
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
480
480
|
} | undefined;
|
|
481
481
|
} | {
|
|
482
482
|
readonly type: "adaptive";
|
|
483
|
-
readonly display?: (
|
|
483
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
484
484
|
readonly block_binding?: {
|
|
485
|
-
readonly prefix_mismatch_behavior?: (
|
|
485
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
486
486
|
} | undefined;
|
|
487
487
|
} | {
|
|
488
488
|
readonly type: "disabled";
|
|
489
489
|
} | undefined;
|
|
490
|
-
readonly service_tier?: "auto" |
|
|
490
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
491
491
|
readonly container?: string | {
|
|
492
492
|
readonly id?: string | null | undefined;
|
|
493
493
|
readonly skills?: readonly {
|
|
@@ -858,20 +858,20 @@ export declare const routes: (import("../route/client.js").Route<{
|
|
|
858
858
|
readonly thinking?: {
|
|
859
859
|
readonly type: "enabled";
|
|
860
860
|
readonly budget_tokens: number;
|
|
861
|
-
readonly display?: (
|
|
861
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
862
862
|
readonly block_binding?: {
|
|
863
|
-
readonly prefix_mismatch_behavior?: (
|
|
863
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
864
864
|
} | undefined;
|
|
865
865
|
} | {
|
|
866
866
|
readonly type: "adaptive";
|
|
867
|
-
readonly display?: (
|
|
867
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
868
868
|
readonly block_binding?: {
|
|
869
|
-
readonly prefix_mismatch_behavior?: (
|
|
869
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
870
870
|
} | undefined;
|
|
871
871
|
} | {
|
|
872
872
|
readonly type: "disabled";
|
|
873
873
|
} | undefined;
|
|
874
|
-
readonly service_tier?: "auto" |
|
|
874
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
875
875
|
readonly container?: string | {
|
|
876
876
|
readonly id?: string | null | undefined;
|
|
877
877
|
readonly skills?: readonly {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { HttpOptions, type ModelID } from "../schema/index.js";
|
|
2
|
+
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
3
|
export type { DeepgramEncoding, DeepgramSpeechOptions } from "../protocols/deepgram-speech.js";
|
|
4
4
|
export type { DeepgramTranscriptionOptions } from "../protocols/deepgram-transcription.js";
|
|
5
5
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { MediaRoute } from "../route/media.js";
|
|
3
|
+
import { ProviderID } from "../schema/index.js";
|
|
4
|
+
import { DeepgramSpeech } from "../protocols/deepgram-speech.js";
|
|
4
5
|
import { DeepgramTranscription } from "../protocols/deepgram-transcription.js";
|
|
5
6
|
export const id = ProviderID.make("deepgram");
|
|
6
|
-
const baseURL = DEFAULT_BASE_URL;
|
|
7
7
|
const auth = (options) => {
|
|
8
8
|
if ("auth" in options && options.auth)
|
|
9
9
|
return options.auth;
|
|
@@ -12,17 +12,11 @@ const auth = (options) => {
|
|
|
12
12
|
.pipe(Auth.scheme("Token"));
|
|
13
13
|
};
|
|
14
14
|
export const configure = (input = {}) => {
|
|
15
|
-
const media = (
|
|
16
|
-
id: modelID,
|
|
17
|
-
auth: auth(input),
|
|
18
|
-
baseURL: input.baseURL ?? baseURL,
|
|
19
|
-
headers: input.headers,
|
|
20
|
-
http: input.http === undefined ? undefined : HttpOptions.make(input.http),
|
|
21
|
-
});
|
|
15
|
+
const media = MediaRoute.deployment(input, auth(input));
|
|
22
16
|
return {
|
|
23
17
|
id,
|
|
24
|
-
speech: (modelID) => DeepgramSpeech.model(media
|
|
25
|
-
transcription: (modelID) => DeepgramTranscription.model(media
|
|
18
|
+
speech: (modelID) => DeepgramSpeech.model({ ...media, id: modelID }),
|
|
19
|
+
transcription: (modelID) => DeepgramTranscription.model({ ...media, id: modelID }),
|
|
26
20
|
configure,
|
|
27
21
|
};
|
|
28
22
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { HttpOptions, type ModelID } from "../schema/index.js";
|
|
2
|
+
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
3
|
export type { ElevenLabsOutputFormat, ElevenLabsSpeechOptions } from "../protocols/elevenlabs-speech.js";
|
|
4
4
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
5
|
export type Config = ProviderAuthOption<"optional"> & {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { MediaRoute } from "../route/media.js";
|
|
3
|
+
import { ProviderID } from "../schema/index.js";
|
|
4
|
+
import { ElevenLabsSpeech } from "../protocols/elevenlabs-speech.js";
|
|
4
5
|
export const id = ProviderID.make("elevenlabs");
|
|
5
|
-
const baseURL = DEFAULT_BASE_URL;
|
|
6
6
|
const auth = (options) => {
|
|
7
7
|
if ("auth" in options && options.auth)
|
|
8
8
|
return options.auth;
|
|
@@ -11,13 +11,8 @@ const auth = (options) => {
|
|
|
11
11
|
.pipe(Auth.header("xi-api-key"));
|
|
12
12
|
};
|
|
13
13
|
export const configure = (input = {}) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
auth: auth(input),
|
|
17
|
-
baseURL: input.baseURL ?? baseURL,
|
|
18
|
-
headers: input.headers,
|
|
19
|
-
http: input.http === undefined ? undefined : HttpOptions.make(input.http),
|
|
20
|
-
});
|
|
14
|
+
const media = MediaRoute.deployment(input, auth(input));
|
|
15
|
+
const speech = (modelID) => ElevenLabsSpeech.model({ ...media, id: modelID });
|
|
21
16
|
return {
|
|
22
17
|
id,
|
|
23
18
|
speech,
|
package/dist/providers/fal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { HttpOptions, type ModelID } from "../schema/index.js";
|
|
2
|
+
import { type HttpOptions, type ModelID } from "../schema/index.js";
|
|
3
3
|
export type { FalImageOptions } from "../protocols/fal-images.js";
|
|
4
4
|
export type { FalVideoOptions } from "../protocols/fal-video.js";
|
|
5
5
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
package/dist/providers/fal.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Auth } from "../route/auth.js";
|
|
2
|
-
import {
|
|
2
|
+
import { MediaRoute } from "../route/media.js";
|
|
3
|
+
import { ProviderID } from "../schema/index.js";
|
|
3
4
|
import { FalImages } from "../protocols/fal-images.js";
|
|
4
5
|
import { FalVideo } from "../protocols/fal-video.js";
|
|
5
|
-
import { FalQueue } from "../protocols/utils/fal-queue.js";
|
|
6
6
|
export const id = ProviderID.make("fal");
|
|
7
|
-
const baseURL = FalQueue.DEFAULT_BASE_URL;
|
|
8
7
|
// fal authenticates with `Authorization: Key <FAL_KEY>` rather than a bearer token.
|
|
9
8
|
const auth = (options) => {
|
|
10
9
|
if ("auth" in options && options.auth)
|
|
@@ -14,17 +13,11 @@ const auth = (options) => {
|
|
|
14
13
|
.pipe(Auth.scheme("Key"));
|
|
15
14
|
};
|
|
16
15
|
export const configure = (input = {}) => {
|
|
17
|
-
const media = (
|
|
18
|
-
id: modelID,
|
|
19
|
-
auth: auth(input),
|
|
20
|
-
baseURL: input.baseURL ?? baseURL,
|
|
21
|
-
headers: input.headers,
|
|
22
|
-
http: input.http === undefined ? undefined : HttpOptions.make(input.http),
|
|
23
|
-
});
|
|
16
|
+
const media = MediaRoute.deployment(input, auth(input));
|
|
24
17
|
return {
|
|
25
18
|
id,
|
|
26
|
-
image: (modelID) => FalImages.model(media
|
|
27
|
-
video: (modelID) => FalVideo.model(media
|
|
19
|
+
image: (modelID) => FalImages.model({ ...media, id: modelID }),
|
|
20
|
+
video: (modelID) => FalVideo.model({ ...media, id: modelID }),
|
|
28
21
|
configure,
|
|
29
22
|
};
|
|
30
23
|
};
|
|
@@ -236,20 +236,20 @@ export declare const routes: Route<{
|
|
|
236
236
|
thinking?: {
|
|
237
237
|
readonly type: "enabled";
|
|
238
238
|
readonly budget_tokens: number;
|
|
239
|
-
readonly display?: (
|
|
239
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
240
240
|
readonly block_binding?: {
|
|
241
|
-
readonly prefix_mismatch_behavior?: (
|
|
241
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
242
242
|
} | undefined;
|
|
243
243
|
} | {
|
|
244
244
|
readonly type: "adaptive";
|
|
245
|
-
readonly display?: (
|
|
245
|
+
readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
|
|
246
246
|
readonly block_binding?: {
|
|
247
|
-
readonly prefix_mismatch_behavior?: (
|
|
247
|
+
readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
|
|
248
248
|
} | undefined;
|
|
249
249
|
} | {
|
|
250
250
|
readonly type: "disabled";
|
|
251
251
|
} | undefined;
|
|
252
|
-
service_tier?: "auto" |
|
|
252
|
+
service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
253
253
|
container?: string | {
|
|
254
254
|
readonly id?: string | null | undefined;
|
|
255
255
|
readonly skills?: readonly {
|
|
@@ -83,8 +83,8 @@ export declare const routes: Route<{
|
|
|
83
83
|
} | undefined;
|
|
84
84
|
readonly cachedContent?: string | undefined;
|
|
85
85
|
readonly safetySettings?: readonly {
|
|
86
|
-
readonly category: (
|
|
87
|
-
readonly threshold: (
|
|
86
|
+
readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY">;
|
|
87
|
+
readonly threshold: import("../schema/options.js").OpenString<"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF">;
|
|
88
88
|
}[] | undefined;
|
|
89
89
|
readonly labels?: {
|
|
90
90
|
readonly [x: string]: string;
|
|
@@ -105,7 +105,7 @@ export declare const routes: Route<{
|
|
|
105
105
|
readonly thinkingConfig?: {
|
|
106
106
|
readonly thinkingBudget?: number | undefined;
|
|
107
107
|
readonly includeThoughts?: boolean | undefined;
|
|
108
|
-
readonly thinkingLevel?: (
|
|
108
|
+
readonly thinkingLevel?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
|
|
109
109
|
} | undefined;
|
|
110
110
|
readonly maxOutputTokens?: number | undefined;
|
|
111
111
|
} | undefined;
|
|
@@ -68,8 +68,8 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
68
68
|
} | undefined;
|
|
69
69
|
readonly cachedContent?: string | undefined;
|
|
70
70
|
readonly safetySettings?: readonly {
|
|
71
|
-
readonly category: (
|
|
72
|
-
readonly threshold: (
|
|
71
|
+
readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY">;
|
|
72
|
+
readonly threshold: import("../schema/options.js").OpenString<"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF">;
|
|
73
73
|
}[] | undefined;
|
|
74
74
|
readonly labels?: {
|
|
75
75
|
readonly [x: string]: string;
|
|
@@ -90,7 +90,7 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
90
90
|
readonly thinkingConfig?: {
|
|
91
91
|
readonly thinkingBudget?: number | undefined;
|
|
92
92
|
readonly includeThoughts?: boolean | undefined;
|
|
93
|
-
readonly thinkingLevel?: (
|
|
93
|
+
readonly thinkingLevel?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
|
|
94
94
|
} | undefined;
|
|
95
95
|
readonly maxOutputTokens?: number | undefined;
|
|
96
96
|
} | undefined;
|