@opencode/ai 2.1.4 → 2.2.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 +283 -114
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/cache-policy.d.ts +4 -0
- package/dist/cache-policy.js +20 -6
- package/dist/decision-client.d.ts +21 -0
- package/dist/decision-client.js +55 -0
- package/dist/decision.d.ts +472 -0
- package/dist/decision.js +158 -0
- package/dist/effect.d.ts +38 -0
- package/dist/effect.js +27 -0
- package/dist/effort-updates.d.ts +2 -2
- package/dist/experimental/cloudflare-run-extraction.d.ts +13 -0
- package/dist/experimental/cloudflare-run-extraction.js +83 -0
- package/dist/experimental/extraction.d.ts +183 -0
- package/dist/experimental/extraction.js +102 -0
- package/dist/experimental/realtime.d.ts +7 -2
- package/dist/experimental/realtime.js +5 -5
- package/dist/experimental.d.ts +2 -3
- package/dist/experimental.js +1 -2
- package/dist/image-client.d.ts +5 -14
- package/dist/image-client.js +0 -1
- package/dist/image.d.ts +6 -176
- package/dist/image.js +4 -11
- package/dist/index.d.ts +1426 -34
- package/dist/index.js +127 -24
- package/dist/llm.d.ts +16 -1
- package/dist/llm.js +34 -0
- package/dist/media-client.d.ts +2 -1
- package/dist/media-model.d.ts +3 -0
- package/dist/media-model.js +4 -1
- package/dist/media.d.ts +0 -7
- package/dist/media.js +0 -6
- package/dist/protocols/alibaba-chat.d.ts +20 -0
- package/dist/protocols/alibaba-images.d.ts +22 -0
- package/dist/protocols/alibaba-images.js +77 -0
- package/dist/protocols/alibaba-messages.d.ts +52 -17
- package/dist/protocols/alibaba-responses.d.ts +6 -3
- package/dist/protocols/anthropic-messages.d.ts +160 -54
- package/dist/protocols/anthropic-messages.js +44 -13
- package/dist/protocols/bedrock-converse.d.ts +110 -15
- package/dist/protocols/bedrock-converse.js +112 -15
- package/dist/protocols/bedrock-event-stream.js +1 -0
- package/dist/protocols/bfl-images.d.ts +9 -0
- package/dist/protocols/bfl-images.js +17 -15
- package/dist/protocols/cartesia-speech.d.ts +0 -18
- package/dist/protocols/cloudflare-run-decisions.d.ts +9 -0
- package/dist/protocols/cloudflare-run-decisions.js +36 -0
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +23 -0
- package/dist/protocols/cloudflare-workers-ai-images.js +80 -0
- package/dist/protocols/deepgram-speech.d.ts +0 -18
- package/dist/protocols/elevenlabs-speech.d.ts +0 -18
- package/dist/protocols/fal-images.d.ts +10 -1
- package/dist/protocols/fal-images.js +16 -25
- package/dist/protocols/fal-video.js +1 -1
- package/dist/protocols/gemini.d.ts +3 -0
- package/dist/protocols/gemini.js +11 -6
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-images.js +8 -37
- package/dist/protocols/google-interactions.d.ts +4 -0
- package/dist/protocols/google-interactions.js +12 -5
- package/dist/protocols/google-speech.d.ts +0 -18
- package/dist/protocols/google-speech.js +0 -1
- package/dist/protocols/google-transcription.d.ts +0 -18
- package/dist/protocols/google-transcription.js +0 -1
- package/dist/protocols/google-video.d.ts +1 -1
- package/dist/protocols/google-video.js +2 -7
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/meta-images.d.ts +7 -1
- package/dist/protocols/meta-images.js +10 -8
- package/dist/protocols/meta-messages.d.ts +52 -17
- package/dist/protocols/meta-messages.js +14 -1
- package/dist/protocols/meta-responses.d.ts +6 -0
- package/dist/protocols/meta-responses.js +29 -1
- package/dist/protocols/open-responses.d.ts +30 -0
- package/dist/protocols/open-responses.js +8 -18
- package/dist/protocols/openai-chat.d.ts +713 -1
- package/dist/protocols/openai-chat.js +35 -22
- package/dist/protocols/openai-compatible-chat.d.ts +22 -1
- package/dist/protocols/openai-compatible-responses.d.ts +8 -5
- package/dist/protocols/openai-decisions.d.ts +22 -0
- package/dist/protocols/openai-decisions.js +128 -0
- package/dist/protocols/openai-images.d.ts +21 -24
- package/dist/protocols/openai-images.js +100 -34
- package/dist/protocols/openai-responses.d.ts +82 -24
- package/dist/protocols/openai-responses.js +32 -2
- package/dist/protocols/openai-speech.d.ts +0 -18
- package/dist/protocols/openai-speech.js +15 -5
- package/dist/protocols/openai-transcription.d.ts +0 -18
- package/dist/protocols/openai-transcription.js +3 -4
- package/dist/protocols/replicate-images.js +1 -1
- package/dist/protocols/runway-video.d.ts +1 -1
- package/dist/protocols/runway-video.js +1 -1
- package/dist/protocols/shared.d.ts +9 -1
- package/dist/protocols/shared.js +13 -2
- package/dist/protocols/stability-images.d.ts +5 -0
- package/dist/protocols/stability-images.js +4 -9
- package/dist/protocols/system-one.d.ts +101 -0
- package/dist/protocols/system-one.js +230 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
- package/dist/protocols/utils/bedrock-cache.js +7 -6
- package/dist/protocols/utils/cache.d.ts +14 -3
- package/dist/protocols/utils/cache.js +11 -4
- package/dist/protocols/utils/gemini-generate-content.d.ts +3 -3
- package/dist/protocols/utils/gemini-generate-content.js +10 -16
- package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
- package/dist/protocols/utils/gemini-json-schema.js +3 -3
- package/dist/protocols/utils/image-sizing.d.ts +31 -0
- package/dist/protocols/utils/image-sizing.js +73 -0
- package/dist/protocols/utils/media-input.d.ts +4 -5
- package/dist/protocols/utils/media-input.js +8 -5
- package/dist/protocols/utils/speech-stream.d.ts +0 -1
- package/dist/protocols/utils/speech-stream.js +0 -1
- package/dist/protocols/utils/tool-schema.js +15 -5
- package/dist/protocols/utils/tool-stream.d.ts +9 -0
- package/dist/protocols/venice-chat.d.ts +19 -0
- package/dist/protocols/venice-chat.js +1 -1
- package/dist/protocols/xai-images.d.ts +1 -2
- package/dist/protocols/xai-images.js +9 -2
- package/dist/protocols/xai-responses.d.ts +10 -0
- package/dist/protocols/xai-responses.js +28 -2
- package/dist/protocols/xai-video.d.ts +1 -1
- package/dist/protocols/xai-video.js +11 -8
- package/dist/protocols/zai-chat.d.ts +21 -0
- package/dist/protocols/zai-images.d.ts +3 -1
- package/dist/protocols/zai-images.js +12 -11
- package/dist/protocols/zai-messages.d.ts +52 -17
- package/dist/provider-error.js +19 -4
- package/dist/providers/alibaba/images.d.ts +2 -0
- package/dist/providers/alibaba/images.js +1 -0
- package/dist/providers/alibaba.d.ts +79 -18
- package/dist/providers/alibaba.js +16 -8
- package/dist/providers/amazon-bedrock-mantle.d.ts +197 -138
- package/dist/providers/amazon-bedrock.d.ts +34 -14
- package/dist/providers/amazon-bedrock.js +11 -11
- package/dist/providers/anthropic-compatible.d.ts +52 -17
- package/dist/providers/anthropic.d.ts +52 -17
- package/dist/providers/azure/images.d.ts +2 -0
- package/dist/providers/azure/images.js +1 -0
- package/dist/providers/azure.d.ts +50 -9
- package/dist/providers/azure.js +19 -1
- package/dist/providers/baseten/decisions.d.ts +2 -0
- package/dist/providers/baseten/decisions.js +1 -0
- package/dist/providers/baseten.d.ts +51 -1
- package/dist/providers/baseten.js +41 -8
- package/dist/providers/cerebras.d.ts +42 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +177 -43
- package/dist/providers/cloudflare-ai-gateway.js +32 -4
- package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
- package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/images.js +1 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +55 -1
- package/dist/providers/cloudflare-workers-ai.js +45 -9
- package/dist/providers/cohere.d.ts +42 -0
- package/dist/providers/deepinfra.d.ts +42 -0
- package/dist/providers/deepseek.d.ts +42 -0
- package/dist/providers/digitalocean/decisions.d.ts +2 -0
- package/dist/providers/digitalocean/decisions.js +1 -0
- package/dist/providers/digitalocean/images.d.ts +2 -0
- package/dist/providers/digitalocean/images.js +1 -0
- package/dist/providers/digitalocean.d.ts +72 -1
- package/dist/providers/digitalocean.js +39 -8
- package/dist/providers/fireworks.d.ts +42 -0
- package/dist/providers/google/images.d.ts +2 -0
- package/dist/providers/google/images.js +1 -0
- package/dist/providers/google-vertex/images.d.ts +2 -0
- package/dist/providers/google-vertex/images.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +21 -0
- package/dist/providers/google-vertex-messages.d.ts +52 -17
- package/dist/providers/google-vertex-responses.d.ts +3 -0
- package/dist/providers/google-vertex.d.ts +3 -1
- package/dist/providers/google-vertex.js +30 -13
- package/dist/providers/google.d.ts +5 -4
- package/dist/providers/google.js +15 -8
- package/dist/providers/groq.d.ts +42 -4
- package/dist/providers/groq.js +0 -6
- package/dist/providers/meta.d.ts +197 -138
- package/dist/providers/minimax.d.ts +76 -17
- package/dist/providers/moonshot.d.ts +76 -17
- package/dist/providers/openai/images.d.ts +2 -0
- package/dist/providers/openai/images.js +1 -0
- package/dist/providers/openai-compatible/images.d.ts +2 -0
- package/dist/providers/openai-compatible/images.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +3 -0
- package/dist/providers/openai-compatible.d.ts +24 -1
- package/dist/providers/openai-compatible.js +21 -9
- package/dist/providers/openai-options.d.ts +3 -1
- package/dist/providers/openai.d.ts +46 -9
- package/dist/providers/openai.js +20 -4
- package/dist/providers/opencode/decisions.d.ts +2 -0
- package/dist/providers/opencode/decisions.js +1 -0
- package/dist/providers/opencode.d.ts +9 -10
- package/dist/providers/opencode.js +10 -8
- package/dist/providers/openrouter/decisions.d.ts +2 -0
- package/dist/providers/openrouter/decisions.js +1 -0
- package/dist/providers/openrouter/images.d.ts +2 -0
- package/dist/providers/openrouter/images.js +1 -0
- package/dist/providers/openrouter.d.ts +92 -11
- package/dist/providers/openrouter.js +38 -16
- package/dist/providers/togetherai.d.ts +42 -0
- package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
- package/dist/providers/typesafe-ai/decisions.js +1 -0
- package/dist/providers/typesafe-ai.d.ts +9 -10
- package/dist/providers/typesafe-ai.js +10 -8
- package/dist/providers/venice.d.ts +19 -0
- package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
- package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/images.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +10 -16
- package/dist/providers/vercel-ai-gateway.js +31 -85
- package/dist/providers/xai/images.d.ts +2 -0
- package/dist/providers/xai/images.js +1 -0
- package/dist/providers/xai.d.ts +28 -5
- package/dist/providers/xai.js +15 -8
- package/dist/providers/zai/images.d.ts +2 -0
- package/dist/providers/zai/images.js +1 -0
- package/dist/providers/zai-coding-plan.d.ts +76 -17
- package/dist/providers/zai.d.ts +26 -4
- package/dist/providers/zai.js +15 -8
- package/dist/route/client.d.ts +2 -2
- package/dist/route/client.js +26 -4
- package/dist/route/decision.d.ts +58 -0
- package/dist/route/decision.js +75 -0
- package/dist/route/executor.d.ts +1 -1
- package/dist/route/framing.d.ts +2 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.js +3 -0
- package/dist/route/media-protocol.d.ts +1 -0
- package/dist/route/media-protocol.js +12 -8
- package/dist/route/media.d.ts +5 -1
- package/dist/route/media.js +6 -2
- package/dist/route/transport/http.js +1 -0
- package/dist/route/transport/index.d.ts +1 -0
- package/dist/schema/events.d.ts +148 -6
- package/dist/schema/events.js +20 -0
- package/dist/schema/messages.d.ts +6 -2
- package/dist/schema/messages.js +3 -0
- package/dist/schema/options.d.ts +5 -3
- package/dist/schema/options.js +8 -3
- package/dist/speech-client.d.ts +5 -14
- package/dist/speech-client.js +0 -1
- package/dist/speech.d.ts +0 -135
- package/dist/speech.js +2 -4
- package/dist/testing.d.ts +25 -24
- package/dist/testing.js +3 -21
- package/dist/transcription-client.d.ts +5 -14
- package/dist/transcription.d.ts +0 -135
- package/dist/transcription.js +1 -1
- package/dist/utils/media-type.js +22 -1
- package/dist/video-client.d.ts +5 -14
- package/dist/video-client.js +0 -1
- package/dist/video.d.ts +1 -136
- package/dist/video.js +3 -5
- package/package.json +513 -11
- package/dist/experimental/evaluation-client.d.ts +0 -21
- package/dist/experimental/evaluation-client.js +0 -64
- package/dist/experimental/evaluation.d.ts +0 -242
- package/dist/experimental/evaluation.js +0 -108
- package/dist/experimental/system-one.d.ts +0 -16
- package/dist/experimental/system-one.js +0 -135
- package/dist/promise.d.ts +0 -1021
- package/dist/promise.js +0 -101
- package/dist/provider.d.ts +0 -23
- package/dist/provider.js +0 -2
|
@@ -21,6 +21,11 @@ export declare const route: Route<{
|
|
|
21
21
|
readonly image_url: {
|
|
22
22
|
readonly url: string;
|
|
23
23
|
};
|
|
24
|
+
} | {
|
|
25
|
+
readonly type: "video_url";
|
|
26
|
+
readonly video_url: {
|
|
27
|
+
readonly url: string;
|
|
28
|
+
};
|
|
24
29
|
} | {
|
|
25
30
|
readonly type: "file";
|
|
26
31
|
readonly file: {
|
|
@@ -42,6 +47,11 @@ export declare const route: Route<{
|
|
|
42
47
|
readonly image_url: {
|
|
43
48
|
readonly url: string;
|
|
44
49
|
};
|
|
50
|
+
} | {
|
|
51
|
+
readonly type: "video_url";
|
|
52
|
+
readonly video_url: {
|
|
53
|
+
readonly url: string;
|
|
54
|
+
};
|
|
45
55
|
} | {
|
|
46
56
|
readonly type: "file";
|
|
47
57
|
readonly file: {
|
|
@@ -123,7 +133,18 @@ export declare const route: Route<{
|
|
|
123
133
|
} | undefined;
|
|
124
134
|
readonly store?: boolean | undefined;
|
|
125
135
|
readonly prompt_cache_key?: string | undefined;
|
|
136
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
137
|
+
readonly prompt_cache_options?: {
|
|
138
|
+
readonly ttl?: string | undefined;
|
|
139
|
+
} | undefined;
|
|
126
140
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
141
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
142
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
143
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
144
|
+
readonly metadata?: {
|
|
145
|
+
readonly [x: string]: string;
|
|
146
|
+
} | undefined;
|
|
147
|
+
readonly safety_identifier?: string | undefined;
|
|
127
148
|
readonly tool_stream?: boolean | undefined;
|
|
128
149
|
readonly max_completion_tokens?: number | undefined;
|
|
129
150
|
readonly max_tokens?: number | undefined;
|
|
@@ -143,6 +164,11 @@ export declare const routes: Route<{
|
|
|
143
164
|
readonly image_url: {
|
|
144
165
|
readonly url: string;
|
|
145
166
|
};
|
|
167
|
+
} | {
|
|
168
|
+
readonly type: "video_url";
|
|
169
|
+
readonly video_url: {
|
|
170
|
+
readonly url: string;
|
|
171
|
+
};
|
|
146
172
|
} | {
|
|
147
173
|
readonly type: "file";
|
|
148
174
|
readonly file: {
|
|
@@ -164,6 +190,11 @@ export declare const routes: Route<{
|
|
|
164
190
|
readonly image_url: {
|
|
165
191
|
readonly url: string;
|
|
166
192
|
};
|
|
193
|
+
} | {
|
|
194
|
+
readonly type: "video_url";
|
|
195
|
+
readonly video_url: {
|
|
196
|
+
readonly url: string;
|
|
197
|
+
};
|
|
167
198
|
} | {
|
|
168
199
|
readonly type: "file";
|
|
169
200
|
readonly file: {
|
|
@@ -245,7 +276,18 @@ export declare const routes: Route<{
|
|
|
245
276
|
} | undefined;
|
|
246
277
|
readonly store?: boolean | undefined;
|
|
247
278
|
readonly prompt_cache_key?: string | undefined;
|
|
279
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
280
|
+
readonly prompt_cache_options?: {
|
|
281
|
+
readonly ttl?: string | undefined;
|
|
282
|
+
} | undefined;
|
|
248
283
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
284
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
285
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
286
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
287
|
+
readonly metadata?: {
|
|
288
|
+
readonly [x: string]: string;
|
|
289
|
+
} | undefined;
|
|
290
|
+
readonly safety_identifier?: string | undefined;
|
|
249
291
|
readonly tool_stream?: boolean | undefined;
|
|
250
292
|
readonly max_completion_tokens?: number | undefined;
|
|
251
293
|
readonly max_tokens?: number | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { decisionModel as model } from "../typesafe-ai.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { HttpOptions, type ModelID } from "../schema/index.js";
|
|
1
|
+
import { HttpOptions, type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
2
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
3
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
4
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
4
5
|
export type Options = ProviderAuthOption<"optional"> & {
|
|
@@ -6,21 +7,19 @@ export type Options = ProviderAuthOption<"optional"> & {
|
|
|
6
7
|
readonly headers?: Record<string, string>;
|
|
7
8
|
readonly http?: HttpOptions.Input;
|
|
8
9
|
};
|
|
10
|
+
export type Settings = ProviderPackage.Settings & {
|
|
11
|
+
readonly apiKey?: string;
|
|
12
|
+
};
|
|
9
13
|
export declare const configure: (input?: Options) => {
|
|
10
14
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
11
|
-
|
|
12
|
-
evaluation: (modelID: string | ModelID) => import("../experimental.js").EvaluationModel<import("../experimental.js").EvaluationOptions>;
|
|
13
|
-
};
|
|
15
|
+
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
14
16
|
configure: typeof configure;
|
|
15
17
|
};
|
|
16
18
|
export declare const provider: {
|
|
17
19
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
18
|
-
|
|
19
|
-
evaluation: (modelID: string | ModelID) => import("../experimental.js").EvaluationModel<import("../experimental.js").EvaluationOptions>;
|
|
20
|
-
};
|
|
20
|
+
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
21
21
|
configure: typeof configure;
|
|
22
22
|
};
|
|
23
|
-
export declare const
|
|
24
|
-
|
|
25
|
-
};
|
|
23
|
+
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
24
|
+
export declare const decisionModel: (modelID: string, { apiKey, baseURL, body, headers, ...providerOptions }: Settings) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
26
25
|
export * as TypeSafeAI from "./typesafe-ai.js";
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { HttpOptions, ProviderID } from "../schema/index.js";
|
|
2
2
|
import { AuthOptions } from "../route/auth-options.js";
|
|
3
|
-
import { SystemOne } from "../
|
|
3
|
+
import { SystemOne } from "../protocols/system-one.js";
|
|
4
4
|
export const id = ProviderID.make("typesafe-ai");
|
|
5
5
|
const baseURL = "https://api.typesafe.ai/v1";
|
|
6
6
|
export const configure = (input = {}) => {
|
|
7
|
-
const
|
|
8
|
-
id: modelID,
|
|
7
|
+
const route = SystemOne.route.with({
|
|
9
8
|
provider: id,
|
|
10
9
|
providerMetadataKey: "typesafe",
|
|
10
|
+
endpoint: { baseURL: input.baseURL ?? baseURL },
|
|
11
11
|
auth: AuthOptions.bearer(input, "TYPESAFE_API_KEY"),
|
|
12
|
-
|
|
13
|
-
headers: input.headers,
|
|
14
|
-
http:
|
|
12
|
+
// Required for images; text-only requests are unchanged with it.
|
|
13
|
+
headers: { "TypeSafe-Danger-Zone-Images": "true", ...input.headers },
|
|
14
|
+
http: input.http,
|
|
15
15
|
});
|
|
16
|
-
|
|
16
|
+
const decision = (modelID, providerOptions) => route.model({ id: modelID, providerOptions });
|
|
17
|
+
return { id, decision, configure };
|
|
17
18
|
};
|
|
18
19
|
export const provider = configure();
|
|
19
|
-
export const
|
|
20
|
+
export const decision = provider.decision;
|
|
21
|
+
export const decisionModel = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({ apiKey, baseURL, headers, http: body === undefined ? undefined : { body } }).decision(modelID, providerOptions);
|
|
20
22
|
export * as TypeSafeAI from "./typesafe-ai.js";
|
|
@@ -44,7 +44,16 @@ export declare const routes: Route<{
|
|
|
44
44
|
} | undefined;
|
|
45
45
|
readonly store?: boolean | undefined;
|
|
46
46
|
readonly prompt_cache_key?: string | undefined;
|
|
47
|
+
readonly prompt_cache_options?: {
|
|
48
|
+
readonly ttl?: string | undefined;
|
|
49
|
+
} | undefined;
|
|
47
50
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
51
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
52
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
53
|
+
readonly metadata?: {
|
|
54
|
+
readonly [x: string]: string;
|
|
55
|
+
} | undefined;
|
|
56
|
+
readonly safety_identifier?: string | undefined;
|
|
48
57
|
readonly tool_stream?: boolean | undefined;
|
|
49
58
|
readonly max_completion_tokens?: number | undefined;
|
|
50
59
|
readonly max_tokens?: number | undefined;
|
|
@@ -61,6 +70,11 @@ export declare const routes: Route<{
|
|
|
61
70
|
readonly image_url: {
|
|
62
71
|
readonly url: string;
|
|
63
72
|
};
|
|
73
|
+
} | {
|
|
74
|
+
readonly type: "video_url";
|
|
75
|
+
readonly video_url: {
|
|
76
|
+
readonly url: string;
|
|
77
|
+
};
|
|
64
78
|
} | {
|
|
65
79
|
readonly type: "file";
|
|
66
80
|
readonly file: {
|
|
@@ -82,6 +96,11 @@ export declare const routes: Route<{
|
|
|
82
96
|
readonly image_url: {
|
|
83
97
|
readonly url: string;
|
|
84
98
|
};
|
|
99
|
+
} | {
|
|
100
|
+
readonly type: "video_url";
|
|
101
|
+
readonly video_url: {
|
|
102
|
+
readonly url: string;
|
|
103
|
+
};
|
|
85
104
|
} | {
|
|
86
105
|
readonly type: "file";
|
|
87
106
|
readonly file: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { decisionModel as model } from "../vercel-ai-gateway.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { imageModel as model } from "../vercel-ai-gateway.js";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { EvaluationModel } from "../experimental/evaluation.js";
|
|
2
1
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
3
2
|
import type { ProviderPackage } from "../provider-package.js";
|
|
4
3
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
5
4
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
6
|
-
import { ModelID } from "../schema/index.js";
|
|
5
|
+
import { ModelID, type ProviderOptions } from "../schema/index.js";
|
|
7
6
|
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
8
7
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
9
8
|
export interface GatewayOptions {
|
|
@@ -17,7 +16,7 @@ export interface GatewayOptions {
|
|
|
17
16
|
readonly order?: ReadonlyArray<string>;
|
|
18
17
|
/** Sort candidate providers by cost (`"cost"`), throughput (`"tps"`), or time-to-first-token (`"ttft"`). */
|
|
19
18
|
readonly sort?: "cost" | "tps" | "ttft" | (string & {});
|
|
20
|
-
/** Fallback models to try in order
|
|
19
|
+
/** Fallback models to try in order. */
|
|
21
20
|
readonly models?: ReadonlyArray<string | Readonly<Record<string, unknown>>>;
|
|
22
21
|
/** Restrict routing to providers with zero data retention agreements. */
|
|
23
22
|
readonly zeroDataRetention?: boolean;
|
|
@@ -64,10 +63,6 @@ export type ProviderOptionsInput = OpenResponsesProviderOptionsInput & Omit<Anth
|
|
|
64
63
|
/** Responses API count of stable input items to anchor for caching, sent as top-level `cache_anchor_items`. */
|
|
65
64
|
readonly cacheAnchorItems?: number;
|
|
66
65
|
};
|
|
67
|
-
export interface EvaluationOptions {
|
|
68
|
-
readonly [key: string]: unknown;
|
|
69
|
-
readonly gateway?: GatewayOptions;
|
|
70
|
-
}
|
|
71
66
|
export type Options = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
72
67
|
readonly baseURL?: string;
|
|
73
68
|
readonly providerOptions?: ProviderOptionsInput;
|
|
@@ -84,9 +79,8 @@ export declare const configure: (input?: Options) => {
|
|
|
84
79
|
messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
85
80
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
86
81
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
82
|
+
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
83
|
+
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
90
84
|
configure: typeof configure;
|
|
91
85
|
};
|
|
92
86
|
export declare const provider: {
|
|
@@ -95,19 +89,19 @@ export declare const provider: {
|
|
|
95
89
|
messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
96
90
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
97
91
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
};
|
|
92
|
+
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
93
|
+
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
101
94
|
configure: typeof configure;
|
|
102
95
|
};
|
|
103
|
-
export declare const
|
|
104
|
-
evaluation: (modelID: string | ModelID) => EvaluationModel<EvaluationOptions>;
|
|
105
|
-
};
|
|
96
|
+
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
106
97
|
export declare const messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
107
98
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
108
99
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
100
|
+
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
109
101
|
export declare const model: ProviderPackage.Definition<Settings, ProviderOptionsInput>["model"];
|
|
110
102
|
export declare const messagesModel: ProviderPackage.Definition<Settings, ProviderOptionsInput>["model"];
|
|
111
103
|
export declare const responsesModel: ProviderPackage.Definition<Settings, ProviderOptionsInput>["model"];
|
|
112
104
|
export declare const chatModel: ProviderPackage.Definition<Settings, ProviderOptionsInput>["model"];
|
|
105
|
+
export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
106
|
+
export declare const decisionModel: (modelID: string, settings: Settings) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
113
107
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
-
import { Headers, HttpClientRequest } from "effect/http";
|
|
3
|
-
import { EvaluationAnswer, EvaluationInput, EvaluationModel, EvaluationQuestion, EvaluationResponse, EvaluationRounding, } from "../experimental/evaluation.js";
|
|
4
2
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
5
3
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
6
4
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
7
|
-
import {
|
|
5
|
+
import { OpenAIDecisions } from "../protocols/openai-decisions.js";
|
|
6
|
+
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
7
|
+
import { ProviderShared } from "../protocols/shared.js";
|
|
8
8
|
import { gatewayProtocol } from "../protocols/utils/gateway-protocol.js";
|
|
9
|
-
import { Auth } from "../route/auth.js";
|
|
10
9
|
import { AuthOptions } from "../route/auth-options.js";
|
|
11
10
|
import { Route } from "../route/client.js";
|
|
12
11
|
import { Endpoint } from "../route/endpoint.js";
|
|
13
|
-
import { RequestExecutor } from "../route/executor.js";
|
|
14
12
|
import { Framing } from "../route/framing.js";
|
|
15
|
-
import {
|
|
13
|
+
import { MediaRoute } from "../route/media.js";
|
|
14
|
+
import { LLMRequest, ModelID, ProviderID, ProviderMetadata, ReasoningEffort, } from "../schema/index.js";
|
|
16
15
|
export const id = ProviderID.make("vercel-ai-gateway");
|
|
17
16
|
const baseURL = "https://ai-gateway.vercel.sh/v1";
|
|
18
17
|
const GatewayOptionsSchema = Schema.Struct({
|
|
@@ -107,22 +106,6 @@ const chatRoute = route({
|
|
|
107
106
|
framing: OpenAIChat.framing,
|
|
108
107
|
});
|
|
109
108
|
export const routes = [messagesRoute, responsesRoute, chatRoute];
|
|
110
|
-
const Request = Schema.StructWithRest(Schema.Struct({
|
|
111
|
-
model: Schema.String,
|
|
112
|
-
state: EvaluationInput,
|
|
113
|
-
questions: Schema.Record(Schema.String, EvaluationQuestion),
|
|
114
|
-
providerOptions: Schema.optional(ProviderOptions),
|
|
115
|
-
}), [JsonObject]);
|
|
116
|
-
const Response = Schema.Struct({
|
|
117
|
-
model: optionalNull(Schema.String),
|
|
118
|
-
answers: Schema.Record(Schema.String, EvaluationAnswer),
|
|
119
|
-
usage: optionalNull(Schema.Struct({
|
|
120
|
-
inputTokens: optionalNull(Schema.Number),
|
|
121
|
-
outputTokens: optionalNull(Schema.Number),
|
|
122
|
-
})),
|
|
123
|
-
rounding: optionalNull(EvaluationRounding),
|
|
124
|
-
providerMetadata: optionalNull(ProviderMetadata),
|
|
125
|
-
});
|
|
126
109
|
export const configure = (input = {}) => {
|
|
127
110
|
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input;
|
|
128
111
|
const configured = {
|
|
@@ -147,80 +130,43 @@ export const configure = (input = {}) => {
|
|
|
147
130
|
return chat(modelID);
|
|
148
131
|
return messages(modelID);
|
|
149
132
|
};
|
|
150
|
-
const
|
|
151
|
-
|
|
133
|
+
const media = MediaRoute.deployment({ ...input, baseURL: configured.endpoint.baseURL }, configured.auth);
|
|
134
|
+
const image = (modelID, providerOptions) => OpenAIImages.model({ ...media, id: modelID, provider: id, providerOptions });
|
|
135
|
+
const decisionRoute = OpenAIDecisions.route.with({
|
|
152
136
|
provider: id,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
const url = new URL(`${(input.baseURL ?? baseURL).replace(/\/$/, "")}/evaluate`);
|
|
158
|
-
Object.entries(req.http?.query ?? {}).forEach(([key, value]) => url.searchParams.set(key, value));
|
|
159
|
-
const body = yield* Schema.encodeUnknownEffect(Schema.fromJsonString(Request))({
|
|
160
|
-
...req.http?.body,
|
|
161
|
-
model: req.model.id,
|
|
162
|
-
state: req.state,
|
|
163
|
-
questions: req.questions,
|
|
164
|
-
providerOptions: req.options,
|
|
165
|
-
}).pipe(Effect.mapError((cause) => new AIError({ reason: new InvalidRequestError({ message: cause.message, cause }) })));
|
|
166
|
-
const headers = yield* Auth.toEffect(configured.auth)({
|
|
167
|
-
request: req,
|
|
168
|
-
method: "POST",
|
|
169
|
-
url: url.toString(),
|
|
170
|
-
body,
|
|
171
|
-
headers: Headers.fromInput({ ...input.headers, ...req.http?.headers }),
|
|
172
|
-
});
|
|
173
|
-
const res = yield* send(HttpClientRequest.post(url).pipe(HttpClientRequest.setHeaders(headers), HttpClientRequest.bodyText(body, "application/json")));
|
|
174
|
-
const http = RequestExecutor.responseHttp(res);
|
|
175
|
-
const fail = (message, cause, body) => new AIError({
|
|
176
|
-
reason: new InvalidProviderOutputError({
|
|
177
|
-
route: "vercel-evaluation",
|
|
178
|
-
message,
|
|
179
|
-
body,
|
|
180
|
-
http,
|
|
181
|
-
cause,
|
|
182
|
-
}),
|
|
183
|
-
});
|
|
184
|
-
const text = yield* res.text.pipe(Effect.mapError((cause) => fail("Failed to read the Vercel AI Gateway evaluation response", cause)));
|
|
185
|
-
const data = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Response))(text).pipe(Effect.mapError((cause) => fail("Vercel AI Gateway returned an invalid evaluation response", cause, text)));
|
|
186
|
-
const inputTokens = data.usage?.inputTokens ?? undefined;
|
|
187
|
-
const outputTokens = data.usage?.outputTokens ?? undefined;
|
|
188
|
-
const usage = data.usage
|
|
189
|
-
? new Usage({
|
|
190
|
-
inputTokens,
|
|
191
|
-
outputTokens,
|
|
192
|
-
totalTokens: ProviderShared.totalTokens(inputTokens, outputTokens, undefined),
|
|
193
|
-
providerMetadata: { gateway: data.usage },
|
|
194
|
-
})
|
|
195
|
-
: undefined;
|
|
196
|
-
return new EvaluationResponse({
|
|
197
|
-
model: ModelID.make(data.model ?? req.model.id),
|
|
198
|
-
answers: data.answers,
|
|
199
|
-
usage,
|
|
200
|
-
rounding: data.rounding ?? undefined,
|
|
201
|
-
providerMetadata: data.providerMetadata ?? undefined,
|
|
202
|
-
});
|
|
203
|
-
}),
|
|
204
|
-
},
|
|
137
|
+
endpoint: { baseURL: configured.endpoint.baseURL },
|
|
138
|
+
auth: configured.auth,
|
|
139
|
+
headers: input.headers,
|
|
140
|
+
http: input.http,
|
|
205
141
|
});
|
|
206
|
-
|
|
142
|
+
const decision = (modelID, providerOptions) => decisionRoute.model({ id: modelID, providerOptions });
|
|
143
|
+
return { id, model, messages, responses, chat, image, decision, configure };
|
|
207
144
|
};
|
|
208
145
|
export const provider = configure();
|
|
209
|
-
export const
|
|
146
|
+
export const decision = provider.decision;
|
|
210
147
|
export const messages = provider.messages;
|
|
211
148
|
export const responses = provider.responses;
|
|
212
149
|
export const chat = provider.chat;
|
|
213
|
-
export const
|
|
214
|
-
export const
|
|
215
|
-
export const
|
|
216
|
-
export const
|
|
217
|
-
|
|
218
|
-
|
|
150
|
+
export const image = provider.image;
|
|
151
|
+
export const model = (modelID, settings) => configure(config(settings)).model(modelID);
|
|
152
|
+
export const messagesModel = (modelID, settings) => configure(config(settings)).messages(modelID);
|
|
153
|
+
export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
|
|
154
|
+
export const chatModel = (modelID, settings) => configure(config(settings)).chat(modelID);
|
|
155
|
+
export const imageModel = (modelID, settings) => {
|
|
156
|
+
const input = config(settings);
|
|
157
|
+
return configure(input).image(modelID, input.providerOptions);
|
|
158
|
+
};
|
|
159
|
+
export const decisionModel = (modelID, settings) => {
|
|
160
|
+
const input = config(settings);
|
|
161
|
+
return configure(input).decision(modelID, input.providerOptions);
|
|
162
|
+
};
|
|
163
|
+
function config({ apiKey, baseURL, headers, body, ...providerOptions }) {
|
|
164
|
+
return {
|
|
219
165
|
apiKey,
|
|
220
166
|
baseURL,
|
|
221
167
|
headers,
|
|
222
168
|
http: body === undefined ? undefined : { body },
|
|
223
169
|
providerOptions,
|
|
224
|
-
}
|
|
170
|
+
};
|
|
225
171
|
}
|
|
226
172
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { imageModel as model } from "../xai.js";
|
package/dist/providers/xai.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
2
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
3
|
-
import { type ModelID } from "../schema/index.js";
|
|
3
|
+
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
4
|
+
import { XAIResponses } from "../protocols/xai-responses.js";
|
|
4
5
|
import type { OpenAIOptionsInput } from "./openai-options.js";
|
|
5
6
|
import type { ProviderPackage } from "../provider-package.js";
|
|
6
7
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
-
export type XAIProviderOptionsInput = OpenAIOptionsInput & {
|
|
8
|
+
export type XAIProviderOptionsInput = OpenAIOptionsInput & XAIResponses.OptionsInput & {
|
|
8
9
|
readonly contextManagement?: never;
|
|
9
10
|
};
|
|
10
11
|
export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
@@ -31,6 +32,11 @@ export declare const routes: (Route<unknown, import("../protocols/open-responses
|
|
|
31
32
|
readonly image_url: {
|
|
32
33
|
readonly url: string;
|
|
33
34
|
};
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "video_url";
|
|
37
|
+
readonly video_url: {
|
|
38
|
+
readonly url: string;
|
|
39
|
+
};
|
|
34
40
|
} | {
|
|
35
41
|
readonly type: "file";
|
|
36
42
|
readonly file: {
|
|
@@ -52,6 +58,11 @@ export declare const routes: (Route<unknown, import("../protocols/open-responses
|
|
|
52
58
|
readonly image_url: {
|
|
53
59
|
readonly url: string;
|
|
54
60
|
};
|
|
61
|
+
} | {
|
|
62
|
+
readonly type: "video_url";
|
|
63
|
+
readonly video_url: {
|
|
64
|
+
readonly url: string;
|
|
65
|
+
};
|
|
55
66
|
} | {
|
|
56
67
|
readonly type: "file";
|
|
57
68
|
readonly file: {
|
|
@@ -133,7 +144,18 @@ export declare const routes: (Route<unknown, import("../protocols/open-responses
|
|
|
133
144
|
} | undefined;
|
|
134
145
|
readonly store?: boolean | undefined;
|
|
135
146
|
readonly prompt_cache_key?: string | undefined;
|
|
147
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
148
|
+
readonly prompt_cache_options?: {
|
|
149
|
+
readonly ttl?: string | undefined;
|
|
150
|
+
} | undefined;
|
|
136
151
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
152
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
153
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
154
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
155
|
+
readonly metadata?: {
|
|
156
|
+
readonly [x: string]: string;
|
|
157
|
+
} | undefined;
|
|
158
|
+
readonly safety_identifier?: string | undefined;
|
|
137
159
|
readonly tool_stream?: boolean | undefined;
|
|
138
160
|
readonly max_completion_tokens?: number | undefined;
|
|
139
161
|
readonly max_tokens?: number | undefined;
|
|
@@ -153,7 +175,7 @@ export declare const configure: (input?: LanguageModelOptions) => {
|
|
|
153
175
|
endpoint: import("../route/client.js").CompactOperation;
|
|
154
176
|
}>;
|
|
155
177
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
156
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
178
|
+
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
157
179
|
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
|
|
158
180
|
configure: typeof configure;
|
|
159
181
|
};
|
|
@@ -166,14 +188,15 @@ export declare const provider: {
|
|
|
166
188
|
endpoint: import("../route/client.js").CompactOperation;
|
|
167
189
|
}>;
|
|
168
190
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
169
|
-
image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
191
|
+
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
170
192
|
video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
|
|
171
193
|
configure: typeof configure;
|
|
172
194
|
};
|
|
173
195
|
export declare const model: ProviderPackage.Definition<Settings, XAIProviderOptionsInput, typeof responsesRoute.compact>["model"];
|
|
196
|
+
export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
174
197
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
|
|
175
198
|
endpoint: import("../route/client.js").CompactOperation;
|
|
176
199
|
}>;
|
|
177
200
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
178
|
-
export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
201
|
+
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
|
|
179
202
|
export declare const video: (modelID: string | ModelID) => import("../video.js").VideoModel<import("../protocols/xai-video.js").XAIVideoOptions>;
|
package/dist/providers/xai.js
CHANGED
|
@@ -67,19 +67,26 @@ export const configure = (input = {}) => {
|
|
|
67
67
|
model: responses,
|
|
68
68
|
responses,
|
|
69
69
|
chat,
|
|
70
|
-
image: (modelID) => XAIImages.model({ ...media, id: modelID }),
|
|
70
|
+
image: (modelID, providerOptions) => XAIImages.model({ ...media, id: modelID, providerOptions }),
|
|
71
71
|
video: (modelID) => XAIVideo.model({ ...media, id: modelID }),
|
|
72
72
|
configure,
|
|
73
73
|
};
|
|
74
74
|
};
|
|
75
75
|
export const provider = configure();
|
|
76
|
-
export const model = (modelID,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
export const model = (modelID, settings) => configure(config(settings)).model(modelID);
|
|
77
|
+
export const imageModel = (modelID, settings) => {
|
|
78
|
+
const input = config(settings);
|
|
79
|
+
return configure(input).image(modelID, input.providerOptions);
|
|
80
|
+
};
|
|
81
|
+
function config({ apiKey, baseURL, body, headers, ...providerOptions }) {
|
|
82
|
+
return {
|
|
83
|
+
apiKey,
|
|
84
|
+
baseURL,
|
|
85
|
+
headers,
|
|
86
|
+
http: body === undefined ? undefined : { body },
|
|
87
|
+
providerOptions,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
83
90
|
export const responses = provider.responses;
|
|
84
91
|
export const chat = provider.chat;
|
|
85
92
|
export const image = provider.image;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { imageModel as model } from "../zai.js";
|