@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
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
3
|
-
import type
|
|
4
|
-
import { type ModelID } from "../schema/index.js";
|
|
3
|
+
import { type ModelID, type RequestOptions } from "../schema/index.js";
|
|
5
4
|
import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
6
5
|
export type { OpenResponsesOptionsInput, OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
|
|
7
6
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
8
|
-
export type Config =
|
|
7
|
+
export type Config = RequestOptions & ProviderAuthOption<"optional"> & {
|
|
9
8
|
readonly provider?: string;
|
|
10
9
|
readonly baseURL: string;
|
|
11
10
|
readonly providerOptions?: OpenResponsesProviderOptionsInput;
|
|
12
11
|
};
|
|
13
12
|
export type Settings = ProviderPackage.Settings & OpenResponsesProviderOptionsInput & {
|
|
14
|
-
readonly apiKey?: string;
|
|
13
|
+
readonly apiKey?: string | false;
|
|
15
14
|
readonly baseURL: string;
|
|
16
15
|
readonly provider?: string;
|
|
17
16
|
};
|
|
18
|
-
export declare const routes: import("../route
|
|
17
|
+
export declare const routes: import("../route.js").Route<{
|
|
19
18
|
readonly model: string;
|
|
20
19
|
readonly input: readonly ({
|
|
21
20
|
readonly type: "configuration_update";
|
|
@@ -212,10 +211,10 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
212
211
|
readonly presence_penalty?: number | undefined;
|
|
213
212
|
readonly frequency_penalty?: number | undefined;
|
|
214
213
|
readonly stream: true;
|
|
215
|
-
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route
|
|
214
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route.js").CompactionOperations | undefined>[];
|
|
216
215
|
export declare const configure: (input: Config) => {
|
|
217
216
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
218
|
-
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route
|
|
217
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route.js").CompactionOperations | undefined>;
|
|
219
218
|
configure: typeof configure;
|
|
220
219
|
};
|
|
221
220
|
export declare const provider: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OpenAICompatibleResponses } from "../protocols/openai-compatible-responses.js";
|
|
2
2
|
import { AuthOptions } from "../route/auth-options.js";
|
|
3
3
|
import { ProviderID } from "../schema/index.js";
|
|
4
|
+
import { toConfig } from "./settings.js";
|
|
4
5
|
export const id = ProviderID.make("openai-compatible");
|
|
5
6
|
export const routes = [OpenAICompatibleResponses.route];
|
|
6
7
|
export const configure = (input) => {
|
|
@@ -22,11 +23,4 @@ export const provider = {
|
|
|
22
23
|
id,
|
|
23
24
|
configure,
|
|
24
25
|
};
|
|
25
|
-
export const model = (modelID, {
|
|
26
|
-
apiKey,
|
|
27
|
-
baseURL,
|
|
28
|
-
headers,
|
|
29
|
-
http: body === undefined ? undefined : { body },
|
|
30
|
-
provider,
|
|
31
|
-
providerOptions,
|
|
32
|
-
}).model(modelID);
|
|
26
|
+
export const model = (modelID, { provider, ...settings }) => configure({ ...toConfig(settings), provider }).model(modelID);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
2
|
-
import type
|
|
1
|
+
import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
2
|
+
import { type OptionsInput as OpenAIEmbeddingOptionsInput } from "../protocols/openai-embeddings.js";
|
|
3
3
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import type { ProviderPackage } from "../provider-package.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 provider?: string;
|
|
9
9
|
readonly baseURL: string;
|
|
10
10
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
11
11
|
};
|
|
12
12
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
13
|
-
readonly apiKey?: string;
|
|
13
|
+
readonly apiKey?: string | false;
|
|
14
14
|
readonly baseURL: string;
|
|
15
15
|
readonly provider?: string;
|
|
16
16
|
};
|
|
17
|
-
export declare const routes: import("../route
|
|
17
|
+
export declare const routes: import("../route.js").Route<{
|
|
18
18
|
readonly model: string;
|
|
19
19
|
readonly messages: readonly ({
|
|
20
20
|
readonly role: "system";
|
|
@@ -114,6 +114,7 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
114
114
|
readonly reasoning?: string | undefined;
|
|
115
115
|
readonly reasoning_text?: string | undefined;
|
|
116
116
|
readonly reasoning_details?: unknown;
|
|
117
|
+
readonly reasoning_opaque?: string | undefined;
|
|
117
118
|
})[];
|
|
118
119
|
readonly tools?: readonly ({
|
|
119
120
|
readonly type: "function";
|
|
@@ -187,11 +188,12 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
187
188
|
readonly presence_penalty?: number | undefined;
|
|
188
189
|
readonly seed?: number | undefined;
|
|
189
190
|
readonly stop?: readonly string[] | undefined;
|
|
190
|
-
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route
|
|
191
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route.js").CompactionOperations | undefined>[];
|
|
191
192
|
export declare const configure: (input: Config) => {
|
|
192
193
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
193
|
-
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route
|
|
194
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route.js").CompactionOperations | undefined>;
|
|
194
195
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
196
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
195
197
|
configure: typeof configure;
|
|
196
198
|
};
|
|
197
199
|
export declare const provider: {
|
|
@@ -200,4 +202,5 @@ export declare const provider: {
|
|
|
200
202
|
};
|
|
201
203
|
export declare const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
|
|
202
204
|
export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
205
|
+
export declare const embeddingModel: (modelID: string, settings: Settings) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
203
206
|
export * as OpenAICompatible from "./openai-compatible.js";
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { mergeProviderOptions, ProviderID } from "../schema/index.js";
|
|
1
|
+
import { mergeProviderOptions, ProviderID, } from "../schema/index.js";
|
|
2
2
|
import { OpenAICompatibleChat } from "../protocols/openai-compatible-chat.js";
|
|
3
|
+
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
3
4
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
4
5
|
import { MediaRoute } from "../route/media.js";
|
|
5
6
|
import { AuthOptions } from "../route/auth-options.js";
|
|
7
|
+
import { toConfig } from "./settings.js";
|
|
6
8
|
export const id = ProviderID.make("openai-compatible");
|
|
7
9
|
export const routes = [OpenAICompatibleChat.route];
|
|
8
10
|
export const configure = (input) => {
|
|
@@ -16,6 +18,13 @@ export const configure = (input) => {
|
|
|
16
18
|
auth,
|
|
17
19
|
});
|
|
18
20
|
const media = MediaRoute.deployment(input, auth);
|
|
21
|
+
const embeddingRoute = OpenAIEmbeddings.route.with({
|
|
22
|
+
provider,
|
|
23
|
+
endpoint: { baseURL },
|
|
24
|
+
auth,
|
|
25
|
+
headers: input.headers,
|
|
26
|
+
http: input.http,
|
|
27
|
+
});
|
|
19
28
|
return {
|
|
20
29
|
id: ProviderID.make(provider),
|
|
21
30
|
model: (modelID) => route.model({ id: modelID }),
|
|
@@ -27,6 +36,7 @@ export const configure = (input) => {
|
|
|
27
36
|
provider,
|
|
28
37
|
providerOptions: mergeProviderOptions(/gpt-image|chatgpt-image/.test(modelID) ? undefined : { response_format: "b64_json" }, providerOptions),
|
|
29
38
|
}),
|
|
39
|
+
embedding: (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions }),
|
|
30
40
|
configure,
|
|
31
41
|
};
|
|
32
42
|
};
|
|
@@ -39,14 +49,11 @@ export const imageModel = (modelID, settings) => {
|
|
|
39
49
|
const input = config(settings);
|
|
40
50
|
return configure(input).image(modelID, input.providerOptions);
|
|
41
51
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
provider,
|
|
49
|
-
providerOptions,
|
|
50
|
-
};
|
|
52
|
+
export const embeddingModel = (modelID, settings) => {
|
|
53
|
+
const input = config(settings);
|
|
54
|
+
return configure(input).embedding(modelID, input.providerOptions);
|
|
55
|
+
};
|
|
56
|
+
function config({ provider, ...settings }) {
|
|
57
|
+
return { ...toConfig(settings), provider };
|
|
51
58
|
}
|
|
52
59
|
export * as OpenAICompatible from "./openai-compatible.js";
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
2
|
-
import type { Route,
|
|
2
|
+
import type { Route, CompactionOperations } from "../route/client.js";
|
|
3
3
|
import type { ProviderPackage } from "../provider-package.js";
|
|
4
|
-
import { ToolDefinition, type ModelID, type OpenString, type ProviderOptions } from "../schema/index.js";
|
|
4
|
+
import { ToolDefinition, type ModelID, type OpenString, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
5
5
|
import * as OpenAIResponses from "../protocols/openai-responses.js";
|
|
6
6
|
import { type OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
7
7
|
import { type OptionsInput as OpenAIDecisionOptionsInput } from "../protocols/openai-decisions.js";
|
|
8
|
+
import { type OptionsInput as OpenAIEmbeddingOptionsInput } from "../protocols/openai-embeddings.js";
|
|
8
9
|
export type { OpenAIOptionsInput, OpenAIResponseIncludable, OpenAIServiceTier } from "./openai-options.js";
|
|
9
10
|
export type { OpenAIImageOptions } from "../protocols/openai-images.js";
|
|
10
11
|
export type { OpenAISpeechOptions } from "../protocols/openai-speech.js";
|
|
11
12
|
export type { OpenAITranscriptionOptions } from "../protocols/openai-transcription.js";
|
|
12
13
|
export type { OptionsInput as OpenAIDecisionOptions } from "../protocols/openai-decisions.js";
|
|
14
|
+
export type { OptionsInput as OpenAIEmbeddingOptions } from "../protocols/openai-embeddings.js";
|
|
13
15
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
14
16
|
export declare const routes: (Route<{
|
|
15
17
|
readonly model: string;
|
|
@@ -111,6 +113,7 @@ export declare const routes: (Route<{
|
|
|
111
113
|
readonly reasoning?: string | undefined;
|
|
112
114
|
readonly reasoning_text?: string | undefined;
|
|
113
115
|
readonly reasoning_details?: unknown;
|
|
116
|
+
readonly reasoning_opaque?: string | undefined;
|
|
114
117
|
})[];
|
|
115
118
|
readonly tools?: readonly ({
|
|
116
119
|
readonly type: "function";
|
|
@@ -417,7 +420,7 @@ export declare const routes: (Route<{
|
|
|
417
420
|
endpoint: import("../route/client.js").CompactOperation;
|
|
418
421
|
trigger: import("../route/client.js").TriggerCompactOperation;
|
|
419
422
|
}>)[];
|
|
420
|
-
export type Config =
|
|
423
|
+
export type Config = RequestOptions & ProviderAuthOption<"optional"> & {
|
|
421
424
|
readonly baseURL?: string;
|
|
422
425
|
readonly queryParams?: Record<string, string>;
|
|
423
426
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
@@ -434,7 +437,7 @@ export interface ImageGenerationOptions {
|
|
|
434
437
|
}
|
|
435
438
|
export declare const imageGeneration: (options?: ImageGenerationOptions) => ToolDefinition;
|
|
436
439
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
437
|
-
readonly apiKey?: string;
|
|
440
|
+
readonly apiKey?: string | false;
|
|
438
441
|
readonly baseURL?: string;
|
|
439
442
|
readonly organization?: string;
|
|
440
443
|
readonly project?: string;
|
|
@@ -455,6 +458,7 @@ export declare const configure: (input?: Config) => {
|
|
|
455
458
|
speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/openai-speech.js").OpenAISpeechOptions>;
|
|
456
459
|
transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/openai-transcription.js").OpenAITranscriptionOptions>;
|
|
457
460
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenAIDecisionOptionsInput>;
|
|
461
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
458
462
|
configure: typeof configure;
|
|
459
463
|
};
|
|
460
464
|
export declare const provider: {
|
|
@@ -472,12 +476,14 @@ export declare const provider: {
|
|
|
472
476
|
speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/openai-speech.js").OpenAISpeechOptions>;
|
|
473
477
|
transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/openai-transcription.js").OpenAITranscriptionOptions>;
|
|
474
478
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenAIDecisionOptionsInput>;
|
|
479
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
475
480
|
configure: typeof configure;
|
|
476
481
|
};
|
|
477
482
|
export declare const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput, typeof OpenAIResponses.route.compact>;
|
|
478
483
|
export declare const chatModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
|
|
479
484
|
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
480
485
|
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<OpenAIDecisionOptionsInput>;
|
|
486
|
+
export declare const embeddingModel: (modelID: string, settings?: Settings) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
|
481
487
|
export declare const responses: (id: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, {
|
|
482
488
|
endpoint: import("../route/client.js").CompactOperation;
|
|
483
489
|
trigger: import("../route/client.js").TriggerCompactOperation;
|
|
@@ -487,3 +493,4 @@ export declare const image: (modelID: string | ModelID, providerOptions?: Provid
|
|
|
487
493
|
export declare const speech: (modelID: string | ModelID) => import("../speech.js").SpeechModel<import("../protocols/openai-speech.js").OpenAISpeechOptions>;
|
|
488
494
|
export declare const transcription: (modelID: string | ModelID) => import("../transcription.js").TranscriptionModel<import("../protocols/openai-transcription.js").OpenAITranscriptionOptions>;
|
|
489
495
|
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenAIDecisionOptionsInput>;
|
|
496
|
+
export declare const embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenAIEmbeddingOptionsInput>;
|
package/dist/providers/openai.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuthOptions } from "../route/auth-options.js";
|
|
2
2
|
import { MediaRoute } from "../route/media.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ProviderID, ToolDefinition, } from "../schema/index.js";
|
|
4
4
|
import * as OpenAIChat from "../protocols/openai-chat.js";
|
|
5
5
|
import * as OpenAIResponses from "../protocols/openai-responses.js";
|
|
6
6
|
import { withOpenAIOptions } from "./openai-options.js";
|
|
@@ -8,6 +8,7 @@ import { OpenAIImages } from "../protocols/openai-images.js";
|
|
|
8
8
|
import { OpenAISpeech } from "../protocols/openai-speech.js";
|
|
9
9
|
import { OpenAITranscription } from "../protocols/openai-transcription.js";
|
|
10
10
|
import { OpenAIDecisions } from "../protocols/openai-decisions.js";
|
|
11
|
+
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
11
12
|
export const id = ProviderID.make("openai");
|
|
12
13
|
export const routes = [OpenAIResponses.route, OpenAIChat.route];
|
|
13
14
|
export const imageGeneration = (options = {}) => ToolDefinition.make({
|
|
@@ -44,12 +45,12 @@ export const configure = (input = {}) => {
|
|
|
44
45
|
const responses = (id) => responsesRoute.with(withOpenAIOptions(id, modelDefaults)).model({ id });
|
|
45
46
|
const chat = (id) => chatRoute.with(withOpenAIOptions(id, modelDefaults)).model({
|
|
46
47
|
id,
|
|
47
|
-
|
|
48
|
+
capabilities: { promptCacheKey: true },
|
|
48
49
|
});
|
|
49
50
|
const deployment = MediaRoute.deployment(input, auth(input));
|
|
50
51
|
const media = {
|
|
51
52
|
...deployment,
|
|
52
|
-
http:
|
|
53
|
+
http: { ...deployment.http, query: { ...deployment.http?.query, ...input.queryParams } },
|
|
53
54
|
};
|
|
54
55
|
// The ChatGPT backend (ChatGPT sign-in) rejects multipart image edits with "Unsupported content type".
|
|
55
56
|
const imageInput = media.baseURL?.startsWith("https://chatgpt.com/") ? "json-edits" : undefined;
|
|
@@ -63,6 +64,13 @@ export const configure = (input = {}) => {
|
|
|
63
64
|
http: media.http,
|
|
64
65
|
});
|
|
65
66
|
const decision = (modelID, providerOptions) => decisionRoute.model({ id: modelID, providerOptions });
|
|
67
|
+
const embeddingRoute = OpenAIEmbeddings.route.with({
|
|
68
|
+
endpoint: { baseURL: media.baseURL },
|
|
69
|
+
auth: media.auth,
|
|
70
|
+
headers: media.headers,
|
|
71
|
+
http: media.http,
|
|
72
|
+
});
|
|
73
|
+
const embedding = (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions });
|
|
66
74
|
return {
|
|
67
75
|
id,
|
|
68
76
|
model: responses,
|
|
@@ -72,6 +80,7 @@ export const configure = (input = {}) => {
|
|
|
72
80
|
speech,
|
|
73
81
|
transcription,
|
|
74
82
|
decision,
|
|
83
|
+
embedding,
|
|
75
84
|
configure,
|
|
76
85
|
};
|
|
77
86
|
};
|
|
@@ -103,9 +112,14 @@ export const decisionModel = (modelID, settings) => {
|
|
|
103
112
|
const input = config(settings);
|
|
104
113
|
return configure(input).decision(modelID, input.providerOptions);
|
|
105
114
|
};
|
|
115
|
+
export const embeddingModel = (modelID, settings) => {
|
|
116
|
+
const input = config(settings);
|
|
117
|
+
return configure(input).embedding(modelID, input.providerOptions);
|
|
118
|
+
};
|
|
106
119
|
export const responses = provider.responses;
|
|
107
120
|
export const chat = provider.chat;
|
|
108
121
|
export const image = provider.image;
|
|
109
122
|
export const speech = provider.speech;
|
|
110
123
|
export const transcription = provider.transcription;
|
|
111
124
|
export const decision = provider.decision;
|
|
125
|
+
export const embedding = provider.embedding;
|
|
@@ -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 OpenCode from "./opencode.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("opencode");
|
|
5
6
|
const baseURL = "https://opencode.ai/inference/systemone/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 OpenCode from "./opencode.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { embeddingModel as model } from "../openrouter.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { Route
|
|
2
|
+
import { Route } from "../route/client.js";
|
|
3
3
|
import { Protocol } from "../route/protocol.js";
|
|
4
|
-
import {
|
|
5
|
-
import { type ModelID, type OpenString, type ProviderOptions } from "../schema/index.js";
|
|
4
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
5
|
+
import { type ModelID, type OpenString, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
6
6
|
import type { ProviderPackage } from "../provider-package.js";
|
|
7
7
|
import { HttpTransport } from "../route/transport/index.js";
|
|
8
8
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
@@ -82,12 +82,17 @@ export interface OpenRouterDecisionOptions {
|
|
|
82
82
|
readonly trace?: Readonly<Record<string, unknown>>;
|
|
83
83
|
readonly user?: string;
|
|
84
84
|
}
|
|
85
|
-
export
|
|
85
|
+
export interface OpenRouterEmbeddingOptions {
|
|
86
|
+
readonly [key: string]: unknown;
|
|
87
|
+
readonly provider?: OpenRouterProviderRouting;
|
|
88
|
+
readonly user?: string;
|
|
89
|
+
}
|
|
90
|
+
export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
86
91
|
readonly baseURL?: string;
|
|
87
92
|
readonly providerOptions?: OpenRouterProviderOptionsInput | OpenRouterResponsesProviderOptionsInput;
|
|
88
93
|
};
|
|
89
94
|
export type Settings<Options = OpenRouterProviderOptionsInput> = ProviderPackage.Settings & Options & {
|
|
90
|
-
readonly apiKey?: string;
|
|
95
|
+
readonly apiKey?: string | false;
|
|
91
96
|
readonly baseURL?: string;
|
|
92
97
|
};
|
|
93
98
|
declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
|
|
@@ -178,6 +183,7 @@ declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
|
|
|
178
183
|
readonly reasoning: Schema.optional<Schema.String>;
|
|
179
184
|
readonly reasoning_text: Schema.optional<Schema.String>;
|
|
180
185
|
readonly reasoning_details: Schema.optional<Schema.Unknown>;
|
|
186
|
+
readonly reasoning_opaque: Schema.optional<Schema.String>;
|
|
181
187
|
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>, Schema.Struct<{
|
|
182
188
|
readonly role: Schema.Literal<"tool">;
|
|
183
189
|
readonly tool_call_id: Schema.String;
|
|
@@ -368,6 +374,7 @@ export declare const protocol: Protocol<{
|
|
|
368
374
|
readonly reasoning?: string | undefined;
|
|
369
375
|
readonly reasoning_text?: string | undefined;
|
|
370
376
|
readonly reasoning_details?: unknown;
|
|
377
|
+
readonly reasoning_opaque?: string | undefined;
|
|
371
378
|
})[];
|
|
372
379
|
tools?: readonly ({
|
|
373
380
|
readonly type: "function";
|
|
@@ -471,6 +478,7 @@ export declare const protocol: Protocol<{
|
|
|
471
478
|
readonly reasoning?: string | null | undefined;
|
|
472
479
|
readonly reasoning_text?: string | null | undefined;
|
|
473
480
|
readonly reasoning_details?: unknown;
|
|
481
|
+
readonly reasoning_opaque?: string | null | undefined;
|
|
474
482
|
readonly tool_calls?: readonly {
|
|
475
483
|
readonly index?: number | null | undefined;
|
|
476
484
|
readonly id?: string | null | undefined;
|
|
@@ -496,6 +504,7 @@ export declare const protocol: Protocol<{
|
|
|
496
504
|
readonly prompt_cache_hit_tokens?: number | null | undefined;
|
|
497
505
|
readonly cache_read_input_tokens?: number | null | undefined;
|
|
498
506
|
readonly cache_created_input_tokens?: number | null | undefined;
|
|
507
|
+
readonly reasoning_tokens?: number | null | undefined;
|
|
499
508
|
readonly prompt_tokens_details?: {
|
|
500
509
|
readonly [x: string]: unknown;
|
|
501
510
|
readonly cached_tokens?: number | null | undefined;
|
|
@@ -518,6 +527,7 @@ export declare const protocol: Protocol<{
|
|
|
518
527
|
readonly prompt_cache_hit_tokens?: number | null | undefined;
|
|
519
528
|
readonly cache_read_input_tokens?: number | null | undefined;
|
|
520
529
|
readonly cache_created_input_tokens?: number | null | undefined;
|
|
530
|
+
readonly reasoning_tokens?: number | null | undefined;
|
|
521
531
|
readonly prompt_tokens_details?: {
|
|
522
532
|
readonly [x: string]: unknown;
|
|
523
533
|
readonly cached_tokens?: number | null | undefined;
|
|
@@ -636,6 +646,7 @@ export declare const route: Route<{
|
|
|
636
646
|
readonly reasoning?: string | undefined;
|
|
637
647
|
readonly reasoning_text?: string | undefined;
|
|
638
648
|
readonly reasoning_details?: unknown;
|
|
649
|
+
readonly reasoning_opaque?: string | undefined;
|
|
639
650
|
})[];
|
|
640
651
|
tools?: readonly ({
|
|
641
652
|
readonly type: "function";
|
|
@@ -1036,6 +1047,7 @@ export declare const routes: (Route<{
|
|
|
1036
1047
|
readonly reasoning?: string | undefined;
|
|
1037
1048
|
readonly reasoning_text?: string | undefined;
|
|
1038
1049
|
readonly reasoning_details?: unknown;
|
|
1050
|
+
readonly reasoning_opaque?: string | undefined;
|
|
1039
1051
|
})[];
|
|
1040
1052
|
tools?: readonly ({
|
|
1041
1053
|
readonly type: "function";
|
|
@@ -1131,24 +1143,31 @@ export declare const routes: (Route<{
|
|
|
1131
1143
|
export declare const configure: (input?: Config) => {
|
|
1132
1144
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
1133
1145
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1146
|
+
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1134
1147
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1135
1148
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1136
1149
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1150
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1137
1151
|
configure: typeof configure;
|
|
1138
1152
|
};
|
|
1139
1153
|
export declare const provider: {
|
|
1140
1154
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
1141
1155
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1156
|
+
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1142
1157
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1143
1158
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1144
1159
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1160
|
+
embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1145
1161
|
configure: typeof configure;
|
|
1146
1162
|
};
|
|
1147
1163
|
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1164
|
+
export declare const embedding: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1148
1165
|
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1166
|
+
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1149
1167
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1150
1168
|
export declare const model: ProviderPackage.Model<Settings, OpenRouterProviderOptionsInput>;
|
|
1151
1169
|
export declare const responsesModel: ProviderPackage.Model<Settings<OpenRouterResponsesProviderOptionsInput>, OpenRouterResponsesProviderOptionsInput>;
|
|
1152
1170
|
export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1153
1171
|
export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1172
|
+
export declare const embeddingModel: (modelID: string, settings?: Settings) => import("../embedding.js").EmbeddingModel<OpenRouterEmbeddingOptions>;
|
|
1154
1173
|
export * as OpenRouter from "./openrouter.js";
|
|
@@ -2,9 +2,9 @@ import { Effect, Schema } from "effect";
|
|
|
2
2
|
import { Route } from "../route/client.js";
|
|
3
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
4
4
|
import { Protocol } from "../route/protocol.js";
|
|
5
|
-
import {
|
|
6
|
-
import { ProviderID } from "../schema/index.js";
|
|
5
|
+
import { ProviderID, } from "../schema/index.js";
|
|
7
6
|
import { SystemOne } from "../protocols/system-one.js";
|
|
7
|
+
import { OpenAIEmbeddings } from "../protocols/openai-embeddings.js";
|
|
8
8
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
9
9
|
import { MediaRoute } from "../route/media.js";
|
|
10
10
|
import { HttpTransport } from "../route/transport/index.js";
|
|
@@ -12,6 +12,7 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
|
12
12
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
13
13
|
import { cacheControl } from "../protocols/utils/cache.js";
|
|
14
14
|
import { isRecord, JsonObject, lenient, ProviderShared } from "../protocols/shared.js";
|
|
15
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
15
16
|
export const id = ProviderID.make("openrouter");
|
|
16
17
|
const baseURL = "https://openrouter.ai/api/v1";
|
|
17
18
|
const ADAPTER = "openrouter";
|
|
@@ -56,7 +57,7 @@ export const protocol = Protocol.make({
|
|
|
56
57
|
reasoning_details: reasoningDetails,
|
|
57
58
|
};
|
|
58
59
|
},
|
|
59
|
-
}).pipe(Effect.map((body) => bodyOptions(body, request.providerOptions, request.
|
|
60
|
+
}).pipe(Effect.map((body) => bodyOptions(body, request.providerOptions, request.maxTokens))),
|
|
60
61
|
},
|
|
61
62
|
stream: OpenAIChat.protocol.stream,
|
|
62
63
|
});
|
|
@@ -130,24 +131,22 @@ const responsesRoute = Route.make({
|
|
|
130
131
|
protocol: responsesProtocol,
|
|
131
132
|
endpoint: Endpoint.path("/responses", { baseURL }),
|
|
132
133
|
transport: HttpTransport.sseJson.with(),
|
|
133
|
-
|
|
134
|
+
options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
|
|
134
135
|
});
|
|
135
136
|
export const routes = [route, responsesRoute];
|
|
136
137
|
export const configure = (input = {}) => {
|
|
137
|
-
const
|
|
138
|
-
const auth = AuthOptions.bearer(input, "OPENROUTER_API_KEY");
|
|
139
|
-
const options = { ...defaults, endpoint: { baseURL: endpoint ?? baseURL }, auth };
|
|
138
|
+
const options = bearerRouteDefaults(input, "OPENROUTER_API_KEY", baseURL);
|
|
140
139
|
const chatRoute = route.with(options);
|
|
141
140
|
const configuredResponses = responsesRoute.with(options);
|
|
142
141
|
const decisionRoute = SystemOne.route.with({
|
|
143
142
|
provider: id,
|
|
144
143
|
providerMetadataKey: "openrouter",
|
|
145
|
-
endpoint:
|
|
146
|
-
auth,
|
|
144
|
+
endpoint: options.endpoint,
|
|
145
|
+
auth: options.auth,
|
|
147
146
|
headers: input.headers,
|
|
148
147
|
http: input.http,
|
|
149
148
|
});
|
|
150
|
-
const media = MediaRoute.deployment({ ...input, baseURL:
|
|
149
|
+
const media = MediaRoute.deployment({ ...input, baseURL: options.endpoint.baseURL }, options.auth);
|
|
151
150
|
const image = (modelID, providerOptions) => OpenAIImages.model({
|
|
152
151
|
...media,
|
|
153
152
|
id: modelID,
|
|
@@ -161,36 +160,44 @@ export const configure = (input = {}) => {
|
|
|
161
160
|
compatibility: { mediaInput: "state" },
|
|
162
161
|
providerOptions,
|
|
163
162
|
});
|
|
163
|
+
const embeddingRoute = OpenAIEmbeddings.route.with({
|
|
164
|
+
provider: id,
|
|
165
|
+
endpoint: options.endpoint,
|
|
166
|
+
auth: options.auth,
|
|
167
|
+
headers: input.headers,
|
|
168
|
+
http: input.http,
|
|
169
|
+
});
|
|
170
|
+
const embedding = (modelID, providerOptions) => embeddingRoute.model({ id: modelID, providerOptions });
|
|
171
|
+
const chat = (modelID) => chatRoute.model({ id: modelID, capabilities: { promptCacheKey: true } });
|
|
164
172
|
return {
|
|
165
173
|
id,
|
|
166
|
-
model:
|
|
174
|
+
model: chat,
|
|
175
|
+
chat,
|
|
167
176
|
responses: (modelID) => configuredResponses.model({ id: modelID }),
|
|
168
177
|
image,
|
|
169
178
|
decision,
|
|
179
|
+
embedding,
|
|
170
180
|
configure,
|
|
171
181
|
};
|
|
172
182
|
};
|
|
173
183
|
export const provider = configure();
|
|
174
184
|
export const decision = provider.decision;
|
|
185
|
+
export const embedding = provider.embedding;
|
|
175
186
|
export const image = provider.image;
|
|
187
|
+
export const chat = provider.chat;
|
|
176
188
|
export const responses = provider.responses;
|
|
177
|
-
export const model = (modelID, settings) => configure(
|
|
178
|
-
export const responsesModel = (modelID, settings) => configure(
|
|
189
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
190
|
+
export const responsesModel = (modelID, settings) => configure(toConfig(settings)).responses(modelID);
|
|
179
191
|
export const imageModel = (modelID, settings) => {
|
|
180
|
-
const input =
|
|
192
|
+
const input = toConfig(settings);
|
|
181
193
|
return configure(input).image(modelID, input.providerOptions);
|
|
182
194
|
};
|
|
183
195
|
export const decisionModel = (modelID, settings) => {
|
|
184
|
-
const input =
|
|
196
|
+
const input = toConfig(settings);
|
|
185
197
|
return configure(input).decision(modelID, input.providerOptions);
|
|
186
198
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
headers,
|
|
192
|
-
http: body === undefined ? undefined : { body },
|
|
193
|
-
providerOptions,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
199
|
+
export const embeddingModel = (modelID, settings) => {
|
|
200
|
+
const input = toConfig(settings);
|
|
201
|
+
return configure(input).embedding(modelID, input.providerOptions);
|
|
202
|
+
};
|
|
196
203
|
export * as OpenRouter from "./openrouter.js";
|
|
@@ -5,7 +5,7 @@ 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 declare const configure: (input?: Config) => {
|
|
11
11
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|