@opencode/ai 2.2.5 → 2.2.7
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 +228 -72
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/cache-policy.d.ts +1 -1
- package/dist/cache-policy.js +16 -4
- package/dist/decision-client.d.ts +3 -3
- package/dist/decision.d.ts +30 -125
- package/dist/decision.js +27 -15
- package/dist/effect.d.ts +10 -15
- package/dist/effect.js +6 -6
- package/dist/effort-updates.d.ts +3 -3
- package/dist/effort-updates.js +2 -2
- package/dist/embedding-client.d.ts +21 -0
- package/dist/embedding-client.js +30 -0
- package/dist/embedding.d.ts +111 -0
- package/dist/embedding.js +75 -0
- package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
- package/dist/experimental/cloudflare-run-extraction.js +4 -1
- package/dist/experimental/extraction.d.ts +10 -40
- package/dist/experimental/extraction.js +14 -13
- package/dist/experimental.d.ts +8 -8
- package/dist/experimental.js +4 -4
- package/dist/generation.d.ts +0 -2
- package/dist/generation.js +2 -2
- package/dist/image-client.d.ts +13 -7
- package/dist/image-client.js +1 -1
- package/dist/image.d.ts +357 -465
- package/dist/image.js +17 -18
- package/dist/index.d.ts +35 -467
- package/dist/index.js +23 -17
- package/dist/llm.d.ts +65 -266
- package/dist/llm.js +101 -92
- package/dist/loop.d.ts +38 -0
- package/dist/loop.js +136 -0
- package/dist/media-model.d.ts +1 -1
- package/dist/media-model.js +8 -6
- package/dist/media.d.ts +9 -0
- package/dist/media.js +37 -2
- package/dist/protocols/alibaba-chat.d.ts +9 -1
- package/dist/protocols/alibaba-chat.js +3 -3
- package/dist/protocols/alibaba-images.d.ts +2 -2
- package/dist/protocols/alibaba-messages.js +3 -3
- package/dist/protocols/alibaba-responses.js +8 -20
- package/dist/protocols/anthropic-messages.d.ts +1 -1
- package/dist/protocols/anthropic-messages.js +57 -176
- package/dist/protocols/assemblyai-transcription.d.ts +2 -2
- package/dist/protocols/bedrock-converse.js +10 -16
- package/dist/protocols/cartesia-speech.d.ts +2 -2
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
- package/dist/protocols/cohere-chat.js +9 -12
- package/dist/protocols/deepgram-speech.d.ts +2 -2
- package/dist/protocols/deepgram-transcription.d.ts +2 -2
- package/dist/protocols/elevenlabs-speech.d.ts +2 -2
- package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
- package/dist/protocols/gemini.d.ts +3 -0
- package/dist/protocols/gemini.js +54 -72
- package/dist/protocols/google-embed-content.d.ts +34 -0
- package/dist/protocols/google-embed-content.js +110 -0
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-interactions.d.ts +3 -4
- package/dist/protocols/google-interactions.js +44 -30
- package/dist/protocols/google-speech.d.ts +2 -2
- package/dist/protocols/google-transcription.d.ts +2 -2
- package/dist/protocols/google-vertex-predict-embeddings.d.ts +18 -0
- package/dist/protocols/google-vertex-predict-embeddings.js +74 -0
- package/dist/protocols/google-video.d.ts +2 -2
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/meta-images.d.ts +2 -2
- package/dist/protocols/meta-responses.js +26 -23
- package/dist/protocols/minimax-images.d.ts +2 -2
- package/dist/protocols/mistral-chat.js +7 -10
- package/dist/protocols/open-responses-channel.js +6 -19
- package/dist/protocols/open-responses-continuation.d.ts +1 -5
- package/dist/protocols/open-responses-continuation.js +1 -3
- package/dist/protocols/open-responses.d.ts +2 -22
- package/dist/protocols/open-responses.js +41 -23
- package/dist/protocols/openai-chat.d.ts +27 -23
- package/dist/protocols/openai-chat.js +62 -57
- package/dist/protocols/openai-compatible-chat.d.ts +2 -1
- package/dist/protocols/openai-compatible-responses.d.ts +2 -2
- package/dist/protocols/openai-compatible-responses.js +1 -1
- package/dist/protocols/openai-decisions.js +15 -2
- package/dist/protocols/openai-embeddings.d.ts +16 -0
- package/dist/protocols/openai-embeddings.js +76 -0
- package/dist/protocols/openai-images.d.ts +2 -2
- package/dist/protocols/openai-responses.js +10 -29
- package/dist/protocols/openai-speech.d.ts +2 -2
- package/dist/protocols/openai-transcription.d.ts +2 -2
- package/dist/protocols/runway-video.d.ts +2 -2
- package/dist/protocols/shared.d.ts +14 -7
- package/dist/protocols/shared.js +40 -15
- package/dist/protocols/system-one.d.ts +4 -4
- package/dist/protocols/system-one.js +8 -1
- package/dist/protocols/utils/bedrock-cache.js +2 -5
- package/dist/protocols/utils/bedrock-media.d.ts +0 -3
- package/dist/protocols/utils/cache.d.ts +3 -0
- package/dist/protocols/utils/cache.js +15 -2
- package/dist/protocols/utils/image-sizing.d.ts +1 -1
- package/dist/protocols/utils/responses-checkpoint.js +1 -1
- package/dist/protocols/utils/responses-compaction.d.ts +1 -1
- package/dist/protocols/utils/responses-compaction.js +6 -5
- package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
- package/dist/protocols/utils/responses-hosted-tools.js +31 -0
- package/dist/protocols/utils/tool-stream.d.ts +5 -271
- package/dist/protocols/utils/tool-stream.js +3 -13
- package/dist/protocols/venice-chat.d.ts +7 -1
- package/dist/protocols/venice-chat.js +4 -4
- package/dist/protocols/xai-images.d.ts +2 -2
- package/dist/protocols/xai-responses.js +5 -25
- package/dist/protocols/xai-video.d.ts +2 -2
- package/dist/protocols/zai-chat.d.ts +9 -1
- package/dist/protocols/zai-chat.js +1 -1
- package/dist/protocols/zai-images.d.ts +2 -2
- package/dist/protocols/zai-messages.js +3 -3
- package/dist/provider-error.d.ts +0 -1
- package/dist/provider-error.js +7 -80
- package/dist/providers/alibaba/embeddings.d.ts +2 -0
- package/dist/providers/alibaba/embeddings.js +1 -0
- package/dist/providers/alibaba.d.ts +70 -4
- package/dist/providers/alibaba.js +20 -2
- package/dist/providers/amazon-bedrock-mantle.d.ts +7 -3
- package/dist/providers/amazon-bedrock-mantle.js +6 -3
- package/dist/providers/amazon-bedrock.d.ts +6 -7
- package/dist/providers/amazon-bedrock.js +1 -1
- package/dist/providers/anthropic-compatible.d.ts +7 -8
- package/dist/providers/anthropic-compatible.js +2 -5
- package/dist/providers/anthropic.d.ts +8 -9
- package/dist/providers/anthropic.js +2 -7
- package/dist/providers/assemblyai.d.ts +2 -2
- package/dist/providers/assemblyai.js +2 -7
- package/dist/providers/azure/embeddings.d.ts +2 -0
- package/dist/providers/azure/embeddings.js +1 -0
- package/dist/providers/azure/messages.d.ts +2 -0
- package/dist/providers/azure/messages.js +1 -0
- package/dist/providers/azure.d.ts +325 -7
- package/dist/providers/azure.js +40 -9
- package/dist/providers/baseten.d.ts +7 -5
- package/dist/providers/baseten.js +7 -21
- package/dist/providers/cartesia.d.ts +1 -1
- package/dist/providers/cerebras.d.ts +7 -5
- package/dist/providers/cerebras.js +4 -15
- package/dist/providers/cloudflare-ai-gateway.d.ts +23 -13
- package/dist/providers/cloudflare-ai-gateway.js +28 -40
- package/dist/providers/cloudflare-shared.d.ts +9 -0
- package/dist/providers/cloudflare-shared.js +25 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +6 -4
- package/dist/providers/cloudflare-workers-ai.js +4 -20
- package/dist/providers/cohere/chat.js +2 -7
- package/dist/providers/cohere/embeddings.d.ts +2 -0
- package/dist/providers/cohere/embeddings.js +1 -0
- package/dist/providers/cohere.d.ts +14 -5
- package/dist/providers/cohere.js +23 -13
- package/dist/providers/deepgram.d.ts +2 -2
- package/dist/providers/deepgram.js +2 -7
- package/dist/providers/deepinfra/embeddings.d.ts +2 -0
- package/dist/providers/deepinfra/embeddings.js +1 -0
- package/dist/providers/deepinfra.d.ts +10 -5
- package/dist/providers/deepinfra.js +20 -14
- package/dist/providers/deepseek.d.ts +7 -5
- package/dist/providers/deepseek.js +3 -14
- package/dist/providers/digitalocean/embeddings.d.ts +2 -0
- package/dist/providers/digitalocean/embeddings.js +1 -0
- package/dist/providers/digitalocean.d.ts +18 -5
- package/dist/providers/digitalocean.js +28 -14
- package/dist/providers/elevenlabs.d.ts +2 -2
- package/dist/providers/elevenlabs.js +2 -7
- package/dist/providers/fireworks/embeddings.d.ts +2 -0
- package/dist/providers/fireworks/embeddings.js +1 -0
- package/dist/providers/fireworks.d.ts +10 -5
- package/dist/providers/fireworks.js +17 -14
- package/dist/providers/google/embeddings.d.ts +2 -0
- package/dist/providers/google/embeddings.js +1 -0
- package/dist/providers/google/interactions.d.ts +1 -1
- package/dist/providers/google/interactions.js +2 -7
- package/dist/providers/google-vertex/embeddings.d.ts +2 -0
- package/dist/providers/google-vertex/embeddings.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +4 -3
- package/dist/providers/google-vertex-chat.js +3 -29
- package/dist/providers/google-vertex-interactions.d.ts +3 -3
- package/dist/providers/google-vertex-messages.d.ts +3 -3
- package/dist/providers/google-vertex-messages.js +3 -29
- package/dist/providers/google-vertex-mistral.d.ts +3 -3
- package/dist/providers/google-vertex-mistral.js +3 -29
- package/dist/providers/google-vertex-responses.d.ts +3 -3
- package/dist/providers/google-vertex-responses.js +4 -30
- package/dist/providers/google-vertex-shared.d.ts +31 -0
- package/dist/providers/google-vertex-shared.js +25 -0
- package/dist/providers/google-vertex.d.ts +10 -3
- package/dist/providers/google-vertex.js +52 -0
- package/dist/providers/google.d.ts +21 -13
- package/dist/providers/google.js +23 -19
- package/dist/providers/groq.d.ts +10 -5
- package/dist/providers/groq.js +4 -15
- package/dist/providers/meta.d.ts +6 -5
- package/dist/providers/meta.js +10 -23
- package/dist/providers/minimax/chat.js +2 -7
- package/dist/providers/minimax/responses.js +2 -7
- package/dist/providers/minimax.d.ts +6 -5
- package/dist/providers/minimax.js +7 -22
- package/dist/providers/mistral.d.ts +10 -11
- package/dist/providers/mistral.js +3 -14
- package/dist/providers/moonshot/messages.js +2 -7
- package/dist/providers/moonshot/responses.js +2 -7
- package/dist/providers/moonshot.d.ts +6 -5
- package/dist/providers/moonshot.js +4 -16
- package/dist/providers/openai/embeddings.d.ts +2 -0
- package/dist/providers/openai/embeddings.js +1 -0
- package/dist/providers/openai-compatible/embeddings.d.ts +2 -0
- package/dist/providers/openai-compatible/embeddings.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +6 -7
- package/dist/providers/openai-compatible-responses.js +2 -8
- package/dist/providers/openai-compatible.d.ts +10 -7
- package/dist/providers/openai-compatible.js +17 -10
- package/dist/providers/openai.d.ts +11 -4
- package/dist/providers/openai.js +17 -3
- package/dist/providers/opencode.d.ts +4 -4
- package/dist/providers/opencode.js +6 -2
- package/dist/providers/openrouter/embeddings.d.ts +2 -0
- package/dist/providers/openrouter/embeddings.js +1 -0
- package/dist/providers/openrouter.d.ts +24 -5
- package/dist/providers/openrouter.js +31 -24
- package/dist/providers/runway.d.ts +1 -1
- package/dist/providers/settings.d.ts +40 -0
- package/dist/providers/settings.js +19 -0
- package/dist/providers/togetherai.d.ts +7 -5
- package/dist/providers/togetherai.js +5 -15
- package/dist/providers/typesafe-ai.d.ts +4 -4
- package/dist/providers/typesafe-ai.js +6 -2
- package/dist/providers/venice.d.ts +5 -4
- package/dist/providers/venice.js +6 -2
- package/dist/providers/vercel-ai-gateway/embeddings.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/embeddings.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +9 -5
- package/dist/providers/vercel-ai-gateway.js +30 -29
- package/dist/providers/xai.d.ts +5 -4
- package/dist/providers/xai.js +4 -12
- package/dist/providers/zai-coding-plan/messages.js +2 -7
- package/dist/providers/zai-coding-plan/responses.js +2 -7
- package/dist/providers/zai-coding-plan.d.ts +6 -5
- package/dist/providers/zai-coding-plan.js +8 -15
- package/dist/providers/zai.d.ts +6 -5
- package/dist/providers/zai.js +10 -22
- package/dist/public.d.ts +14 -0
- package/dist/public.js +6 -0
- package/dist/route/auth-options.d.ts +9 -5
- package/dist/route/auth-options.js +10 -7
- package/dist/route/client.d.ts +50 -37
- package/dist/route/client.js +42 -53
- package/dist/route/decision.d.ts +8 -8
- package/dist/route/decision.js +3 -3
- package/dist/route/embedding.d.ts +61 -0
- package/dist/route/embedding.js +88 -0
- package/dist/route/executor.d.ts +5 -0
- package/dist/route/executor.js +10 -0
- package/dist/route/index.d.ts +5 -7
- package/dist/route/index.js +1 -1
- package/dist/route/media.d.ts +7 -11
- package/dist/route/media.js +22 -26
- package/dist/route/transport/http.js +6 -5
- package/dist/route/transport/websocket.js +7 -1
- package/dist/schema/errors.d.ts +16 -17
- package/dist/schema/errors.js +63 -12
- package/dist/schema/events.d.ts +2563 -2954
- package/dist/schema/events.js +54 -109
- package/dist/schema/messages.d.ts +194 -137
- package/dist/schema/messages.js +66 -83
- package/dist/schema/options.d.ts +112 -65
- package/dist/schema/options.js +52 -101
- package/dist/speech-client.d.ts +7 -7
- package/dist/speech.d.ts +306 -316
- package/dist/speech.js +16 -14
- package/dist/testing.d.ts +31 -175
- package/dist/testing.js +60 -5
- package/dist/tool-history.d.ts +1 -1
- package/dist/tool-history.js +3 -10
- package/dist/tool-runtime.d.ts +9 -2
- package/dist/tool-runtime.js +17 -31
- package/dist/tool.d.ts +39 -43
- package/dist/tool.js +16 -26
- package/dist/transcription-client.d.ts +7 -7
- package/dist/transcription.d.ts +314 -265
- package/dist/transcription.js +16 -14
- package/dist/utils/provider-codes.d.ts +3 -0
- package/dist/utils/provider-codes.js +41 -0
- package/dist/video-client.d.ts +7 -7
- package/dist/video-client.js +1 -1
- package/dist/video.d.ts +269 -287
- package/dist/video.js +16 -14
- package/package.json +309 -257
- package/dist/experimental/testing.d.ts +0 -3
- package/dist/experimental/testing.js +0 -3
- package/dist/testing/decision.d.ts +0 -16
- package/dist/testing/decision.js +0 -20
- package/dist/testing/image.d.ts +0 -14
- package/dist/testing/image.js +0 -12
- package/dist/testing/media.d.ts +0 -18
- package/dist/testing/media.js +0 -36
- package/dist/testing/script.d.ts +0 -28
- package/dist/testing/script.js +0 -60
- package/dist/testing/speech.d.ts +0 -14
- package/dist/testing/speech.js +0 -12
- package/dist/testing/transcription.d.ts +0 -14
- package/dist/testing/transcription.js +0 -12
- package/dist/testing/video.d.ts +0 -14
- package/dist/testing/video.js +0 -12
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
+
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
|
+
import type { Auth } from "../route/auth.js";
|
|
4
|
+
type Connection = "apiKey" | "baseURL" | "body" | "headers";
|
|
5
|
+
/**
|
|
6
|
+
* Splits flat provider settings into connection config, treating every other key as a provider option.
|
|
7
|
+
* The overload keeps each provider's option keys; a generic rest would type them as `Omit`, which collapses
|
|
8
|
+
* to the `Settings` index signature.
|
|
9
|
+
*/
|
|
10
|
+
export declare function toConfig<Settings extends ProviderPackage.Settings>(settings?: Settings): {
|
|
11
|
+
apiKey: Settings["apiKey"];
|
|
12
|
+
baseURL: Settings["baseURL"];
|
|
13
|
+
headers: Settings["headers"];
|
|
14
|
+
http: {
|
|
15
|
+
body: NonNullable<Settings["body"]>;
|
|
16
|
+
} | undefined;
|
|
17
|
+
providerOptions: {
|
|
18
|
+
[Key in keyof Settings as Key extends Connection ? never : Key]: Settings[Key];
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type BearerInput = ProviderAuthOption<"optional"> & {
|
|
22
|
+
readonly baseURL?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Turns provider config into route options with `Authorization: Bearer` auth. The endpoint falls back to
|
|
26
|
+
* `baseURL` when given, otherwise it is left to the route.
|
|
27
|
+
*/
|
|
28
|
+
export declare function bearerRouteDefaults<Input extends BearerInput>(input: Input, envVar: string | ReadonlyArray<string>, baseURL: string): Omit<Input, "apiKey" | "auth" | "baseURL"> & {
|
|
29
|
+
endpoint: {
|
|
30
|
+
baseURL: string;
|
|
31
|
+
};
|
|
32
|
+
auth: Auth.Definition;
|
|
33
|
+
};
|
|
34
|
+
export declare function bearerRouteDefaults<Input extends BearerInput>(input: Input, envVar: string | ReadonlyArray<string>): Omit<Input, "apiKey" | "auth" | "baseURL"> & {
|
|
35
|
+
endpoint: {
|
|
36
|
+
baseURL: string;
|
|
37
|
+
} | undefined;
|
|
38
|
+
auth: Auth.Definition;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
2
|
+
export function toConfig({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
|
|
3
|
+
return {
|
|
4
|
+
apiKey,
|
|
5
|
+
baseURL,
|
|
6
|
+
headers,
|
|
7
|
+
http: body === undefined ? undefined : { body },
|
|
8
|
+
providerOptions,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function bearerRouteDefaults(input, envVar, baseURL) {
|
|
12
|
+
const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input;
|
|
13
|
+
const resolved = endpoint ?? baseURL;
|
|
14
|
+
return {
|
|
15
|
+
...defaults,
|
|
16
|
+
endpoint: resolved === undefined ? undefined : { baseURL: resolved },
|
|
17
|
+
auth: AuthOptions.bearer(input, envVar),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
-
import {
|
|
3
|
-
import { Route
|
|
4
|
-
import { type ModelID } from "../schema/index.js";
|
|
2
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
3
|
+
import { Route } from "../route/client.js";
|
|
4
|
+
import { type ModelID, type RequestOptions } from "../schema/index.js";
|
|
5
5
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
6
6
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
-
export type Config = Omit<
|
|
7
|
+
export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
8
8
|
readonly baseURL?: string;
|
|
9
9
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
10
10
|
};
|
|
11
11
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
12
|
-
readonly apiKey?: string;
|
|
12
|
+
readonly apiKey?: string | false;
|
|
13
13
|
readonly baseURL?: string;
|
|
14
14
|
};
|
|
15
15
|
export declare const route: Route<{
|
|
@@ -112,6 +112,7 @@ export declare const route: Route<{
|
|
|
112
112
|
readonly reasoning?: string | undefined;
|
|
113
113
|
readonly reasoning_text?: string | undefined;
|
|
114
114
|
readonly reasoning_details?: unknown;
|
|
115
|
+
readonly reasoning_opaque?: string | undefined;
|
|
115
116
|
})[];
|
|
116
117
|
readonly tools?: readonly ({
|
|
117
118
|
readonly type: "function";
|
|
@@ -286,6 +287,7 @@ export declare const routes: Route<{
|
|
|
286
287
|
readonly reasoning?: string | undefined;
|
|
287
288
|
readonly reasoning_text?: string | undefined;
|
|
288
289
|
readonly reasoning_details?: unknown;
|
|
290
|
+
readonly reasoning_opaque?: string | undefined;
|
|
289
291
|
})[];
|
|
290
292
|
readonly tools?: readonly ({
|
|
291
293
|
readonly type: "function";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
2
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
3
2
|
import { Route } from "../route/client.js";
|
|
4
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
5
4
|
import { ProviderID } from "../schema/index.js";
|
|
5
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
6
6
|
export const id = ProviderID.make("togetherai");
|
|
7
7
|
const baseURL = "https://api.together.xyz/v1";
|
|
8
8
|
export const route = Route.make({
|
|
@@ -15,26 +15,16 @@ export const route = Route.make({
|
|
|
15
15
|
});
|
|
16
16
|
export const routes = [route];
|
|
17
17
|
export const configure = (input = {}) => {
|
|
18
|
-
const
|
|
19
|
-
const configured = route.with({
|
|
20
|
-
...defaults,
|
|
21
|
-
endpoint: { baseURL: endpoint ?? baseURL },
|
|
22
|
-
auth: AuthOptions.bearer(input, ["TOGETHER_API_KEY", "TOGETHER_AI_API_KEY"]),
|
|
23
|
-
});
|
|
18
|
+
const configured = route.with(bearerRouteDefaults(input, ["TOGETHER_API_KEY", "TOGETHER_AI_API_KEY"], baseURL));
|
|
24
19
|
return {
|
|
25
20
|
id,
|
|
26
21
|
model: (modelID) => configured.model({
|
|
27
22
|
id: modelID,
|
|
28
|
-
compatibility: { maxTokensField: "max_tokens"
|
|
23
|
+
compatibility: { maxTokensField: "max_tokens" },
|
|
24
|
+
capabilities: { tools: { strict: false } },
|
|
29
25
|
}),
|
|
30
26
|
configure,
|
|
31
27
|
};
|
|
32
28
|
};
|
|
33
29
|
export const provider = configure();
|
|
34
|
-
export const model = (modelID,
|
|
35
|
-
apiKey,
|
|
36
|
-
baseURL,
|
|
37
|
-
headers,
|
|
38
|
-
http: body === undefined ? undefined : { body },
|
|
39
|
-
providerOptions,
|
|
40
|
-
}).model(modelID);
|
|
30
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { HttpOptions, type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
1
|
+
import { type HttpOptions, type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
2
2
|
import type { ProviderPackage } from "../provider-package.js";
|
|
3
3
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
5
5
|
export type Config = ProviderAuthOption<"optional"> & {
|
|
6
6
|
readonly baseURL?: string;
|
|
7
7
|
readonly headers?: Record<string, string>;
|
|
8
|
-
readonly http?: HttpOptions
|
|
8
|
+
readonly http?: HttpOptions;
|
|
9
9
|
};
|
|
10
10
|
export type Settings = ProviderPackage.Settings & {
|
|
11
|
-
readonly apiKey?: string;
|
|
11
|
+
readonly apiKey?: string | false;
|
|
12
12
|
};
|
|
13
13
|
export declare const configure: (input?: Config) => {
|
|
14
14
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
@@ -21,5 +21,5 @@ export declare const provider: {
|
|
|
21
21
|
configure: typeof configure;
|
|
22
22
|
};
|
|
23
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,
|
|
24
|
+
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
25
25
|
export * as TypeSafeAI from "./typesafe-ai.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderID } from "../schema/index.js";
|
|
2
2
|
import { AuthOptions } from "../route/auth-options.js";
|
|
3
3
|
import { SystemOne } from "../protocols/system-one.js";
|
|
4
|
+
import { toConfig } from "./settings.js";
|
|
4
5
|
export const id = ProviderID.make("typesafe-ai");
|
|
5
6
|
const baseURL = "https://api.typesafe.ai/v1";
|
|
6
7
|
export const configure = (input = {}) => {
|
|
@@ -18,5 +19,8 @@ export const configure = (input = {}) => {
|
|
|
18
19
|
};
|
|
19
20
|
export const provider = configure();
|
|
20
21
|
export const decision = provider.decision;
|
|
21
|
-
export const decisionModel = (modelID,
|
|
22
|
+
export const decisionModel = (modelID, settings) => {
|
|
23
|
+
const input = toConfig(settings);
|
|
24
|
+
return configure(input).decision(modelID, input.providerOptions);
|
|
25
|
+
};
|
|
22
26
|
export * as TypeSafeAI from "./typesafe-ai.js";
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { VeniceChat } from "../protocols/venice-chat.js";
|
|
3
3
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
|
-
import { Route
|
|
5
|
-
import { type ModelID } from "../schema/index.js";
|
|
4
|
+
import { Route } from "../route/client.js";
|
|
5
|
+
import { type ModelID, type RequestOptions } from "../schema/index.js";
|
|
6
6
|
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
7
7
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
8
8
|
export type ChatOptionsInput = VeniceChat.OptionsInput;
|
|
9
|
-
export type Config = Omit<
|
|
9
|
+
export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
10
10
|
readonly baseURL?: string;
|
|
11
11
|
readonly queryParams?: Readonly<Record<string, string>>;
|
|
12
12
|
readonly providerOptions?: ChatOptionsInput | OpenResponsesProviderOptionsInput;
|
|
13
13
|
};
|
|
14
14
|
export type Settings<Options = ChatOptionsInput> = ProviderPackage.Settings & Options & {
|
|
15
|
-
readonly apiKey?: string;
|
|
15
|
+
readonly apiKey?: string | false;
|
|
16
16
|
readonly baseURL?: string;
|
|
17
17
|
readonly queryParams?: Readonly<Record<string, string>>;
|
|
18
18
|
};
|
|
@@ -363,6 +363,7 @@ export declare const routes: (Route<{
|
|
|
363
363
|
readonly reasoning?: string | undefined;
|
|
364
364
|
readonly reasoning_text?: string | undefined;
|
|
365
365
|
readonly reasoning_details?: unknown;
|
|
366
|
+
readonly reasoning_opaque?: string | undefined;
|
|
366
367
|
readonly tool_calls?: readonly ({
|
|
367
368
|
readonly id: string;
|
|
368
369
|
readonly type: "custom";
|
package/dist/providers/venice.js
CHANGED
|
@@ -22,7 +22,7 @@ const responsesRoute = Route.make({
|
|
|
22
22
|
protocol: OpenResponses.protocol,
|
|
23
23
|
endpoint: Endpoint.path("/responses", { baseURL }),
|
|
24
24
|
transport: OpenResponses.httpTransport,
|
|
25
|
-
|
|
25
|
+
options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
|
|
26
26
|
});
|
|
27
27
|
export const routes = [route, responsesRoute];
|
|
28
28
|
export const configure = (input = {}) => {
|
|
@@ -32,7 +32,11 @@ export const configure = (input = {}) => {
|
|
|
32
32
|
endpoint: { baseURL: endpoint ?? baseURL, query: queryParams },
|
|
33
33
|
auth: AuthOptions.bearer(input, "VENICE_API_KEY"),
|
|
34
34
|
};
|
|
35
|
-
const chat = (modelID) => route.with(options).model({
|
|
35
|
+
const chat = (modelID) => route.with(options).model({
|
|
36
|
+
id: modelID,
|
|
37
|
+
compatibility: VeniceChat.compatibility,
|
|
38
|
+
capabilities: VeniceChat.capabilities,
|
|
39
|
+
});
|
|
36
40
|
const responses = (modelID) => responsesRoute.with(options).model({ id: modelID });
|
|
37
41
|
return { id, model: chat, chat, responses, configure };
|
|
38
42
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { embeddingModel as model } from "../vercel-ai-gateway.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
2
2
|
import type { ProviderPackage } from "../provider-package.js";
|
|
3
|
-
import {
|
|
4
|
-
import { Route
|
|
5
|
-
import { ModelID, type ProviderOptions } from "../schema/index.js";
|
|
3
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
4
|
+
import { Route } from "../route/client.js";
|
|
5
|
+
import { ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
6
6
|
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
7
7
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
8
8
|
export interface GatewayOptions {
|
|
@@ -63,12 +63,12 @@ export type ProviderOptionsInput = OpenResponsesProviderOptionsInput & Omit<Anth
|
|
|
63
63
|
/** Responses API count of stable input items to anchor for caching, sent as top-level `cache_anchor_items`. */
|
|
64
64
|
readonly cacheAnchorItems?: number;
|
|
65
65
|
};
|
|
66
|
-
export type Config = Omit<
|
|
66
|
+
export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
67
67
|
readonly baseURL?: string;
|
|
68
68
|
readonly providerOptions?: ProviderOptionsInput;
|
|
69
69
|
};
|
|
70
70
|
export type Settings = ProviderPackage.Settings & ProviderOptionsInput & {
|
|
71
|
-
readonly apiKey?: string;
|
|
71
|
+
readonly apiKey?: string | false;
|
|
72
72
|
};
|
|
73
73
|
export declare const routes: Route<{
|
|
74
74
|
readonly [x: string]: unknown;
|
|
@@ -81,6 +81,7 @@ export declare const configure: (input?: Config) => {
|
|
|
81
81
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
82
82
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
83
83
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
84
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
|
|
84
85
|
configure: typeof configure;
|
|
85
86
|
};
|
|
86
87
|
export declare const provider: {
|
|
@@ -91,9 +92,11 @@ export declare const provider: {
|
|
|
91
92
|
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
92
93
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
93
94
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
95
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
|
|
94
96
|
configure: typeof configure;
|
|
95
97
|
};
|
|
96
98
|
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
99
|
+
export declare const embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
|
|
97
100
|
export declare const messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
98
101
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
99
102
|
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
@@ -104,4 +107,5 @@ export declare const responsesModel: ProviderPackage.Model<Settings, ProviderOpt
|
|
|
104
107
|
export declare const chatModel: ProviderPackage.Model<Settings, ProviderOptionsInput>;
|
|
105
108
|
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
106
109
|
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
|
|
110
|
+
export declare const embeddingModel: (modelID: string, settings?: Settings) => import("../embedding.js").EmbeddingModel<import("../embedding.js").EmbeddingOptions>;
|
|
107
111
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
|
@@ -3,16 +3,17 @@ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
|
|
|
3
3
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
4
4
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
5
5
|
import { OpenAIDecisions } from "../protocols/openai-decisions.js";
|
|
6
|
+
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
6
7
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
7
8
|
import { XAIImages } from "../protocols/xai-images.js";
|
|
8
9
|
import { ProviderShared } from "../protocols/shared.js";
|
|
9
10
|
import { gatewayProtocol } from "../protocols/utils/gateway-protocol.js";
|
|
10
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
11
11
|
import { Route } from "../route/client.js";
|
|
12
12
|
import { Endpoint } from "../route/endpoint.js";
|
|
13
13
|
import { Framing } from "../route/framing.js";
|
|
14
14
|
import { MediaRoute } from "../route/media.js";
|
|
15
|
-
import {
|
|
15
|
+
import { ModelID, ProviderID, ProviderMetadata, ReasoningEffort, } from "../schema/index.js";
|
|
16
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
16
17
|
export const id = ProviderID.make("vercel-ai-gateway");
|
|
17
18
|
const baseURL = "https://ai-gateway.vercel.sh/v1";
|
|
18
19
|
const GatewayOptionsSchema = Schema.Struct({
|
|
@@ -44,13 +45,14 @@ const prepare = (api) => Effect.fnUntraced(function* (request) {
|
|
|
44
45
|
return { request, body: { providerOptions } };
|
|
45
46
|
const enabled = effort !== "none";
|
|
46
47
|
const thinking = request.providerOptions?.thinking ?? { type: enabled ? "adaptive" : "disabled" };
|
|
47
|
-
const next =
|
|
48
|
+
const next = {
|
|
49
|
+
...request,
|
|
48
50
|
providerOptions: {
|
|
49
51
|
...request.providerOptions,
|
|
50
52
|
effort: enabled ? effort : undefined,
|
|
51
53
|
thinking,
|
|
52
54
|
},
|
|
53
|
-
}
|
|
55
|
+
};
|
|
54
56
|
return { request: next, body: { providerOptions } };
|
|
55
57
|
}
|
|
56
58
|
case "responses":
|
|
@@ -81,7 +83,7 @@ const route = (input) => Route.make({
|
|
|
81
83
|
endpoint: Endpoint.path(input.path, { baseURL }),
|
|
82
84
|
framing: input.framing,
|
|
83
85
|
headers: ({ request }) => request.promptCacheKey ? { "x-session-affinity": request.promptCacheKey } : {},
|
|
84
|
-
|
|
86
|
+
options: input.options,
|
|
85
87
|
});
|
|
86
88
|
const messagesRoute = route({
|
|
87
89
|
id: "vercel-ai-gateway-messages",
|
|
@@ -89,7 +91,7 @@ const messagesRoute = route({
|
|
|
89
91
|
api: "messages",
|
|
90
92
|
path: "/messages",
|
|
91
93
|
framing: AnthropicMessages.framing,
|
|
92
|
-
|
|
94
|
+
options: { headers: { "anthropic-version": "2023-06-01" } },
|
|
93
95
|
});
|
|
94
96
|
const responsesRoute = route({
|
|
95
97
|
id: "vercel-ai-gateway-responses",
|
|
@@ -97,7 +99,7 @@ const responsesRoute = route({
|
|
|
97
99
|
api: "responses",
|
|
98
100
|
path: "/responses",
|
|
99
101
|
framing: Framing.sse,
|
|
100
|
-
|
|
102
|
+
options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
|
|
101
103
|
});
|
|
102
104
|
const chatRoute = route({
|
|
103
105
|
id: "vercel-ai-gateway-chat",
|
|
@@ -117,12 +119,7 @@ const imageSizing = (request) => {
|
|
|
117
119
|
return { providerOptions: { xai: { aspect_ratio: request.aspect, resolution: XAIImages.resolution(request) } } };
|
|
118
120
|
};
|
|
119
121
|
export const configure = (input = {}) => {
|
|
120
|
-
const
|
|
121
|
-
const configured = {
|
|
122
|
-
...defaults,
|
|
123
|
-
endpoint: { baseURL: endpoint ?? baseURL },
|
|
124
|
-
auth: AuthOptions.bearer(input, ["AI_GATEWAY_API_KEY", "VERCEL_OIDC_TOKEN"]),
|
|
125
|
-
};
|
|
122
|
+
const configured = bearerRouteDefaults(input, ["AI_GATEWAY_API_KEY", "VERCEL_OIDC_TOKEN"], baseURL);
|
|
126
123
|
const messages = (modelID) => messagesRoute.with(configured).model({
|
|
127
124
|
id: modelID,
|
|
128
125
|
// Recorded Gateway translations for non-Claude models return thinking with empty signatures.
|
|
@@ -150,33 +147,37 @@ export const configure = (input = {}) => {
|
|
|
150
147
|
http: input.http,
|
|
151
148
|
});
|
|
152
149
|
const decision = (modelID, providerOptions) => decisionRoute.model({ id: modelID, providerOptions });
|
|
153
|
-
|
|
150
|
+
const embeddingRoute = OpenAIEmbeddings.route.with({
|
|
151
|
+
provider: id,
|
|
152
|
+
endpoint: { baseURL: configured.endpoint.baseURL },
|
|
153
|
+
auth: configured.auth,
|
|
154
|
+
headers: input.headers,
|
|
155
|
+
http: input.http,
|
|
156
|
+
});
|
|
157
|
+
const embedding = (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions });
|
|
158
|
+
return { id, model, messages, responses, chat, image, decision, embedding, configure };
|
|
154
159
|
};
|
|
155
160
|
export const provider = configure();
|
|
156
161
|
export const decision = provider.decision;
|
|
162
|
+
export const embedding = provider.embedding;
|
|
157
163
|
export const messages = provider.messages;
|
|
158
164
|
export const responses = provider.responses;
|
|
159
165
|
export const chat = provider.chat;
|
|
160
166
|
export const image = provider.image;
|
|
161
|
-
export const model = (modelID, settings) => configure(
|
|
162
|
-
export const messagesModel = (modelID, settings) => configure(
|
|
163
|
-
export const responsesModel = (modelID, settings) => configure(
|
|
164
|
-
export const chatModel = (modelID, settings) => configure(
|
|
167
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
168
|
+
export const messagesModel = (modelID, settings) => configure(toConfig(settings)).messages(modelID);
|
|
169
|
+
export const responsesModel = (modelID, settings) => configure(toConfig(settings)).responses(modelID);
|
|
170
|
+
export const chatModel = (modelID, settings) => configure(toConfig(settings)).chat(modelID);
|
|
165
171
|
export const imageModel = (modelID, settings) => {
|
|
166
|
-
const input =
|
|
172
|
+
const input = toConfig(settings);
|
|
167
173
|
return configure(input).image(modelID, input.providerOptions);
|
|
168
174
|
};
|
|
169
175
|
export const decisionModel = (modelID, settings) => {
|
|
170
|
-
const input =
|
|
176
|
+
const input = toConfig(settings);
|
|
171
177
|
return configure(input).decision(modelID, input.providerOptions);
|
|
172
178
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
headers,
|
|
178
|
-
http: body === undefined ? undefined : { body },
|
|
179
|
-
providerOptions,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
179
|
+
export const embeddingModel = (modelID, settings) => {
|
|
180
|
+
const input = toConfig(settings);
|
|
181
|
+
return configure(input).embedding(modelID, input.providerOptions);
|
|
182
|
+
};
|
|
182
183
|
export * as VercelAIGateway from "./vercel-ai-gateway.js";
|
package/dist/providers/xai.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import { Route
|
|
3
|
-
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
2
|
+
import { Route } from "../route/client.js";
|
|
3
|
+
import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
4
4
|
import { XAIResponses } from "../protocols/xai-responses.js";
|
|
5
5
|
import type { OpenAIOptionsInput } from "./openai-options.js";
|
|
6
6
|
import type { ProviderPackage } from "../provider-package.js";
|
|
@@ -8,12 +8,12 @@ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
|
8
8
|
export type XAIProviderOptionsInput = OpenAIOptionsInput & XAIResponses.OptionsInput & {
|
|
9
9
|
readonly contextManagement?: never;
|
|
10
10
|
};
|
|
11
|
-
export type Config = Omit<
|
|
11
|
+
export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
12
12
|
readonly baseURL?: string;
|
|
13
13
|
readonly providerOptions?: XAIProviderOptionsInput;
|
|
14
14
|
};
|
|
15
15
|
export type Settings = ProviderPackage.Settings & XAIProviderOptionsInput & {
|
|
16
|
-
readonly apiKey?: string;
|
|
16
|
+
readonly apiKey?: string | false;
|
|
17
17
|
readonly baseURL?: string;
|
|
18
18
|
};
|
|
19
19
|
export type { XAIImageOptions } from "../protocols/xai-images.js";
|
|
@@ -123,6 +123,7 @@ export declare const routes: (Route<unknown, import("../protocols/open-responses
|
|
|
123
123
|
readonly reasoning?: string | undefined;
|
|
124
124
|
readonly reasoning_text?: string | undefined;
|
|
125
125
|
readonly reasoning_details?: unknown;
|
|
126
|
+
readonly reasoning_opaque?: string | undefined;
|
|
126
127
|
})[];
|
|
127
128
|
readonly tools?: readonly ({
|
|
128
129
|
readonly type: "function";
|
package/dist/providers/xai.js
CHANGED
|
@@ -8,6 +8,7 @@ import { OpenResponsesChannel } from "../protocols/open-responses-channel.js";
|
|
|
8
8
|
import { XAIResponses } from "../protocols/xai-responses.js";
|
|
9
9
|
import { XAIImages } from "../protocols/xai-images.js";
|
|
10
10
|
import { XAIVideo } from "../protocols/xai-video.js";
|
|
11
|
+
import { toConfig } from "./settings.js";
|
|
11
12
|
export const id = ProviderID.make("xai");
|
|
12
13
|
const baseURL = "https://api.x.ai/v1";
|
|
13
14
|
const RESPONSES_WEBSOCKET_ROTATE_AFTER_MS = 24 * 60 * 1000;
|
|
@@ -27,7 +28,7 @@ const responsesRoute = Route.make({
|
|
|
27
28
|
// rejects `instructions` next to `previous_response_id` and keeps the instructions of the response it continues.
|
|
28
29
|
continuation: ({ instructions: _instructions, ...request }) => (request.store === false ? undefined : request),
|
|
29
30
|
}),
|
|
30
|
-
|
|
31
|
+
options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
|
|
31
32
|
});
|
|
32
33
|
const chatRoute = Route.make({
|
|
33
34
|
id: "xai-chat",
|
|
@@ -73,20 +74,11 @@ export const configure = (input = {}) => {
|
|
|
73
74
|
};
|
|
74
75
|
};
|
|
75
76
|
export const provider = configure();
|
|
76
|
-
export const model = (modelID, settings) => configure(
|
|
77
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
77
78
|
export const imageModel = (modelID, settings) => {
|
|
78
|
-
const input =
|
|
79
|
+
const input = toConfig(settings);
|
|
79
80
|
return configure(input).image(modelID, input.providerOptions);
|
|
80
81
|
};
|
|
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
|
-
}
|
|
90
82
|
export const responses = provider.responses;
|
|
91
83
|
export const chat = provider.chat;
|
|
92
84
|
export const image = provider.image;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { ZAICodingPlan } from "../zai-coding-plan.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
baseURL,
|
|
5
|
-
headers,
|
|
6
|
-
http: body === undefined ? undefined : { body },
|
|
7
|
-
providerOptions,
|
|
8
|
-
}).messages(modelID);
|
|
2
|
+
import { toConfig } from "../settings.js";
|
|
3
|
+
export const model = (modelID, settings) => ZAICodingPlan.configure(toConfig(settings)).messages(modelID);
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { ZAICodingPlan } from "../zai-coding-plan.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
baseURL,
|
|
5
|
-
headers,
|
|
6
|
-
http: body === undefined ? undefined : { body },
|
|
7
|
-
providerOptions,
|
|
8
|
-
}).responses(modelID);
|
|
2
|
+
import { toConfig } from "../settings.js";
|
|
3
|
+
export const model = (modelID, settings) => ZAICodingPlan.configure(toConfig(settings)).responses(modelID);
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { ZAIChat } from "../protocols/zai-chat.js";
|
|
3
3
|
import { ZAIMessages } from "../protocols/zai-messages.js";
|
|
4
|
-
import {
|
|
5
|
-
import { Route
|
|
6
|
-
import { type ModelID } from "../schema/index.js";
|
|
4
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
5
|
+
import { Route } from "../route/client.js";
|
|
6
|
+
import { type ModelID, type RequestOptions } from "../schema/index.js";
|
|
7
7
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
8
8
|
export type ChatOptionsInput = ZAIChat.OptionsInput;
|
|
9
9
|
export type MessagesOptionsInput = ZAIMessages.OptionsInput;
|
|
10
10
|
export type ResponsesOptionsInput = {
|
|
11
11
|
readonly reasoningEffort?: ZAIChat.ReasoningEffort;
|
|
12
12
|
};
|
|
13
|
-
export type Config = Omit<
|
|
13
|
+
export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
14
14
|
/** Overrides the selected API's complete base URL. */
|
|
15
15
|
readonly baseURL?: string;
|
|
16
16
|
readonly providerOptions?: ChatOptionsInput | MessagesOptionsInput | ResponsesOptionsInput;
|
|
17
17
|
};
|
|
18
18
|
export type Settings<Options = ChatOptionsInput> = ProviderPackage.Settings & Options & {
|
|
19
|
-
readonly apiKey?: string;
|
|
19
|
+
readonly apiKey?: string | false;
|
|
20
20
|
readonly baseURL?: string;
|
|
21
21
|
};
|
|
22
22
|
export declare const routes: (Route<{
|
|
@@ -316,6 +316,7 @@ export declare const routes: (Route<{
|
|
|
316
316
|
readonly reasoning?: string | undefined;
|
|
317
317
|
readonly reasoning_text?: string | undefined;
|
|
318
318
|
readonly reasoning_details?: unknown;
|
|
319
|
+
readonly reasoning_opaque?: string | undefined;
|
|
319
320
|
})[];
|
|
320
321
|
readonly tools?: readonly ({
|
|
321
322
|
readonly type: "function";
|
|
@@ -3,11 +3,11 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
|
3
3
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
4
4
|
import { ZAIChat } from "../protocols/zai-chat.js";
|
|
5
5
|
import { ZAIMessages } from "../protocols/zai-messages.js";
|
|
6
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
7
6
|
import { Route } from "../route/client.js";
|
|
8
7
|
import { Endpoint } from "../route/endpoint.js";
|
|
9
8
|
import { Framing } from "../route/framing.js";
|
|
10
9
|
import { ProviderID } from "../schema/index.js";
|
|
10
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
11
11
|
export const id = ProviderID.make("zai-coding-plan");
|
|
12
12
|
const chatRoute = Route.make({
|
|
13
13
|
id: "zai-coding-chat",
|
|
@@ -36,13 +36,12 @@ const responsesRoute = Route.make({
|
|
|
36
36
|
});
|
|
37
37
|
export const routes = [chatRoute, messagesRoute, responsesRoute];
|
|
38
38
|
export const configure = (input = {}) => {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
const chat = (modelID) => chatRoute.with(defaults).model({ id: modelID, compatibility: ZAIChat.compatibility });
|
|
39
|
+
const defaults = bearerRouteDefaults(input, "ZAI_API_KEY");
|
|
40
|
+
const chat = (modelID) => chatRoute.with(defaults).model({
|
|
41
|
+
id: modelID,
|
|
42
|
+
compatibility: ZAIChat.compatibility,
|
|
43
|
+
capabilities: ZAIChat.capabilities,
|
|
44
|
+
});
|
|
46
45
|
const messages = (modelID) => messagesRoute
|
|
47
46
|
.with(defaults)
|
|
48
47
|
.model({ id: modelID, compatibility: { requireSignature: false } });
|
|
@@ -53,11 +52,5 @@ export const provider = configure();
|
|
|
53
52
|
export const chat = provider.chat;
|
|
54
53
|
export const messages = provider.messages;
|
|
55
54
|
export const responses = provider.responses;
|
|
56
|
-
export const model = (modelID,
|
|
57
|
-
apiKey,
|
|
58
|
-
baseURL,
|
|
59
|
-
headers,
|
|
60
|
-
http: body === undefined ? undefined : { body },
|
|
61
|
-
providerOptions,
|
|
62
|
-
}).model(modelID);
|
|
55
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
63
56
|
export * as ZAICodingPlan from "./zai-coding-plan.js";
|