@opencode/ai 2.2.4 → 2.2.6
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 +133 -69
- 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 +20 -125
- package/dist/decision.js +25 -15
- package/dist/effect.d.ts +4 -15
- package/dist/effect.js +2 -6
- package/dist/effort-updates.d.ts +3 -3
- package/dist/effort-updates.js +2 -2
- 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 -464
- package/dist/image.js +17 -15
- package/dist/index.d.ts +28 -465
- package/dist/index.js +18 -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 +5 -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 -185
- package/dist/protocols/assemblyai-transcription.d.ts +2 -2
- package/dist/protocols/bedrock-converse.js +11 -22
- 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 +56 -89
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-interactions.d.ts +3 -4
- package/dist/protocols/google-interactions.js +54 -32
- package/dist/protocols/google-speech.d.ts +2 -2
- package/dist/protocols/google-transcription.d.ts +2 -2
- package/dist/protocols/google-video.d.ts +2 -2
- 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 +14 -20
- 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 +1 -21
- package/dist/protocols/open-responses.js +10 -15
- package/dist/protocols/openai-chat.d.ts +3 -23
- package/dist/protocols/openai-chat.js +26 -47
- package/dist/protocols/openai-compatible-chat.d.ts +1 -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 +1 -1
- 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 +1 -4
- package/dist/protocols/shared.js +13 -11
- package/dist/protocols/system-one.d.ts +4 -4
- 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 +3 -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 +5 -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 +9 -80
- package/dist/providers/alibaba.d.ts +67 -4
- package/dist/providers/alibaba.js +6 -1
- package/dist/providers/amazon-bedrock-mantle.d.ts +6 -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/messages.d.ts +2 -0
- package/dist/providers/azure/messages.js +1 -0
- package/dist/providers/azure.d.ts +322 -7
- package/dist/providers/azure.js +25 -9
- package/dist/providers/baseten.d.ts +5 -5
- package/dist/providers/baseten.js +7 -21
- package/dist/providers/cartesia.d.ts +1 -1
- package/dist/providers/cerebras.d.ts +5 -5
- package/dist/providers/cerebras.js +4 -15
- package/dist/providers/cloudflare-ai-gateway.d.ts +21 -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 +4 -4
- package/dist/providers/cloudflare-workers-ai.js +4 -20
- package/dist/providers/cohere/chat.js +2 -7
- package/dist/providers/cohere.d.ts +6 -5
- package/dist/providers/cohere.js +7 -13
- package/dist/providers/deepgram.d.ts +2 -2
- package/dist/providers/deepgram.js +2 -7
- package/dist/providers/deepinfra.d.ts +5 -5
- package/dist/providers/deepinfra.js +5 -13
- package/dist/providers/deepseek.d.ts +5 -5
- package/dist/providers/deepseek.js +3 -14
- package/dist/providers/digitalocean.d.ts +8 -5
- package/dist/providers/digitalocean.js +13 -14
- package/dist/providers/elevenlabs.d.ts +2 -2
- package/dist/providers/elevenlabs.js +2 -7
- package/dist/providers/fireworks.d.ts +5 -5
- package/dist/providers/fireworks.js +4 -15
- package/dist/providers/google/interactions.d.ts +1 -1
- package/dist/providers/google/interactions.js +2 -7
- package/dist/providers/google-vertex-chat.d.ts +3 -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 +3 -3
- package/dist/providers/google.d.ts +15 -13
- package/dist/providers/google.js +9 -19
- package/dist/providers/groq.d.ts +5 -5
- package/dist/providers/groq.js +4 -15
- package/dist/providers/meta.d.ts +5 -5
- package/dist/providers/meta.js +10 -24
- package/dist/providers/minimax/chat.js +2 -7
- package/dist/providers/minimax/responses.js +2 -7
- package/dist/providers/minimax.d.ts +5 -5
- package/dist/providers/minimax.js +11 -23
- 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 +5 -5
- package/dist/providers/moonshot.js +4 -16
- 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 +6 -7
- package/dist/providers/openai-compatible.js +4 -10
- package/dist/providers/openai.d.ts +4 -4
- package/dist/providers/openai.js +3 -3
- package/dist/providers/opencode.d.ts +4 -4
- package/dist/providers/opencode.js +6 -2
- package/dist/providers/openrouter.d.ts +8 -5
- package/dist/providers/openrouter.js +16 -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 +5 -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 +4 -4
- package/dist/providers/venice.js +6 -2
- package/dist/providers/vercel-ai-gateway.d.ts +5 -5
- package/dist/providers/vercel-ai-gateway.js +15 -28
- package/dist/providers/xai.d.ts +4 -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 +5 -5
- package/dist/providers/zai-coding-plan.js +8 -15
- package/dist/providers/zai.d.ts +5 -5
- package/dist/providers/zai.js +10 -22
- package/dist/public.d.ts +12 -0
- package/dist/public.js +5 -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/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 +9 -9
- 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
|
@@ -3,12 +3,12 @@ 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 { ProviderShared } from "../protocols/shared.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 { Protocol } from "../route/protocol.js";
|
|
11
10
|
import { ProviderID } from "../schema/index.js";
|
|
11
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
12
12
|
export const id = ProviderID.make("moonshotai");
|
|
13
13
|
const ChatOptions = Schema.Struct({
|
|
14
14
|
reasoningEffort: Schema.optional(Schema.String),
|
|
@@ -51,21 +51,15 @@ const responsesRoute = Route.make({
|
|
|
51
51
|
});
|
|
52
52
|
export const routes = [chatRoute, messagesRoute, responsesRoute];
|
|
53
53
|
export const configure = (input = {}) => {
|
|
54
|
-
const
|
|
55
|
-
const defaults = {
|
|
56
|
-
...rest,
|
|
57
|
-
endpoint: baseURL === undefined ? undefined : { baseURL },
|
|
58
|
-
auth: AuthOptions.bearer(input, ["MOONSHOT_API_KEY", "MOONSHOTAI_API_KEY"]),
|
|
59
|
-
};
|
|
54
|
+
const defaults = bearerRouteDefaults(input, ["MOONSHOT_API_KEY", "MOONSHOTAI_API_KEY"]);
|
|
60
55
|
const chat = (modelID) => chatRoute.with(defaults).model({
|
|
61
56
|
id: modelID,
|
|
62
57
|
compatibility: {
|
|
63
58
|
maxTokensField: "max_tokens",
|
|
64
|
-
supportsStrictMode: false,
|
|
65
|
-
supportsPromptCacheKey: true,
|
|
66
59
|
sanitizer: "moonshot",
|
|
67
60
|
reasoningField: "reasoning_content",
|
|
68
61
|
},
|
|
62
|
+
capabilities: { tools: { strict: false }, promptCacheKey: true },
|
|
69
63
|
});
|
|
70
64
|
const messages = (modelID) => messagesRoute.with(defaults).model({
|
|
71
65
|
id: modelID,
|
|
@@ -80,11 +74,5 @@ export const provider = configure();
|
|
|
80
74
|
export const chat = provider.chat;
|
|
81
75
|
export const messages = provider.messages;
|
|
82
76
|
export const responses = provider.responses;
|
|
83
|
-
export const model = (modelID,
|
|
84
|
-
apiKey,
|
|
85
|
-
baseURL,
|
|
86
|
-
headers,
|
|
87
|
-
http: body === undefined ? undefined : { body },
|
|
88
|
-
providerOptions,
|
|
89
|
-
}).model(modelID);
|
|
77
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
90
78
|
export * as Moonshot from "./moonshot.js";
|
|
@@ -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,19 @@
|
|
|
1
|
-
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
2
|
-
import type { RouteDefaultsInput } from "../route/client.js";
|
|
1
|
+
import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
|
|
3
2
|
import { type ProviderAuthOption } from "../route/auth-options.js";
|
|
4
3
|
import type { ProviderPackage } from "../provider-package.js";
|
|
5
4
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
6
5
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
-
export type Config = Omit<
|
|
6
|
+
export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
8
7
|
readonly provider?: string;
|
|
9
8
|
readonly baseURL: string;
|
|
10
9
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
11
10
|
};
|
|
12
11
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
13
|
-
readonly apiKey?: string;
|
|
12
|
+
readonly apiKey?: string | false;
|
|
14
13
|
readonly baseURL: string;
|
|
15
14
|
readonly provider?: string;
|
|
16
15
|
};
|
|
17
|
-
export declare const routes: import("../route
|
|
16
|
+
export declare const routes: import("../route.js").Route<{
|
|
18
17
|
readonly model: string;
|
|
19
18
|
readonly messages: readonly ({
|
|
20
19
|
readonly role: "system";
|
|
@@ -187,10 +186,10 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
187
186
|
readonly presence_penalty?: number | undefined;
|
|
188
187
|
readonly seed?: number | undefined;
|
|
189
188
|
readonly stop?: readonly string[] | undefined;
|
|
190
|
-
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route
|
|
189
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route.js").CompactionOperations | undefined>[];
|
|
191
190
|
export declare const configure: (input: Config) => {
|
|
192
191
|
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
|
|
192
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route.js").CompactionOperations | undefined>;
|
|
194
193
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
195
194
|
configure: typeof configure;
|
|
196
195
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
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
3
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
4
4
|
import { MediaRoute } from "../route/media.js";
|
|
5
5
|
import { AuthOptions } from "../route/auth-options.js";
|
|
6
|
+
import { toConfig } from "./settings.js";
|
|
6
7
|
export const id = ProviderID.make("openai-compatible");
|
|
7
8
|
export const routes = [OpenAICompatibleChat.route];
|
|
8
9
|
export const configure = (input) => {
|
|
@@ -39,14 +40,7 @@ export const imageModel = (modelID, settings) => {
|
|
|
39
40
|
const input = config(settings);
|
|
40
41
|
return configure(input).image(modelID, input.providerOptions);
|
|
41
42
|
};
|
|
42
|
-
function config({
|
|
43
|
-
return {
|
|
44
|
-
apiKey,
|
|
45
|
-
baseURL,
|
|
46
|
-
headers,
|
|
47
|
-
http: body === undefined ? undefined : { body },
|
|
48
|
-
provider,
|
|
49
|
-
providerOptions,
|
|
50
|
-
};
|
|
43
|
+
function config({ provider, ...settings }) {
|
|
44
|
+
return { ...toConfig(settings), provider };
|
|
51
45
|
}
|
|
52
46
|
export * as OpenAICompatible from "./openai-compatible.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
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";
|
|
@@ -417,7 +417,7 @@ export declare const routes: (Route<{
|
|
|
417
417
|
endpoint: import("../route/client.js").CompactOperation;
|
|
418
418
|
trigger: import("../route/client.js").TriggerCompactOperation;
|
|
419
419
|
}>)[];
|
|
420
|
-
export type Config =
|
|
420
|
+
export type Config = RequestOptions & ProviderAuthOption<"optional"> & {
|
|
421
421
|
readonly baseURL?: string;
|
|
422
422
|
readonly queryParams?: Record<string, string>;
|
|
423
423
|
readonly providerOptions?: OpenAIProviderOptionsInput;
|
|
@@ -434,7 +434,7 @@ export interface ImageGenerationOptions {
|
|
|
434
434
|
}
|
|
435
435
|
export declare const imageGeneration: (options?: ImageGenerationOptions) => ToolDefinition;
|
|
436
436
|
export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
|
|
437
|
-
readonly apiKey?: string;
|
|
437
|
+
readonly apiKey?: string | false;
|
|
438
438
|
readonly baseURL?: string;
|
|
439
439
|
readonly organization?: string;
|
|
440
440
|
readonly project?: string;
|
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";
|
|
@@ -44,12 +44,12 @@ export const configure = (input = {}) => {
|
|
|
44
44
|
const responses = (id) => responsesRoute.with(withOpenAIOptions(id, modelDefaults)).model({ id });
|
|
45
45
|
const chat = (id) => chatRoute.with(withOpenAIOptions(id, modelDefaults)).model({
|
|
46
46
|
id,
|
|
47
|
-
|
|
47
|
+
capabilities: { promptCacheKey: true },
|
|
48
48
|
});
|
|
49
49
|
const deployment = MediaRoute.deployment(input, auth(input));
|
|
50
50
|
const media = {
|
|
51
51
|
...deployment,
|
|
52
|
-
http:
|
|
52
|
+
http: { ...deployment.http, query: { ...deployment.http?.query, ...input.queryParams } },
|
|
53
53
|
};
|
|
54
54
|
// The ChatGPT backend (ChatGPT sign-in) rejects multipart image edits with "Unsupported content type".
|
|
55
55
|
const imageInput = media.baseURL?.startsWith("https://chatgpt.com/") ? "json-edits" : undefined;
|
|
@@ -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";
|
|
@@ -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,12 @@ export interface OpenRouterDecisionOptions {
|
|
|
82
82
|
readonly trace?: Readonly<Record<string, unknown>>;
|
|
83
83
|
readonly user?: string;
|
|
84
84
|
}
|
|
85
|
-
export type Config = Omit<
|
|
85
|
+
export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
86
86
|
readonly baseURL?: string;
|
|
87
87
|
readonly providerOptions?: OpenRouterProviderOptionsInput | OpenRouterResponsesProviderOptionsInput;
|
|
88
88
|
};
|
|
89
89
|
export type Settings<Options = OpenRouterProviderOptionsInput> = ProviderPackage.Settings & Options & {
|
|
90
|
-
readonly apiKey?: string;
|
|
90
|
+
readonly apiKey?: string | false;
|
|
91
91
|
readonly baseURL?: string;
|
|
92
92
|
};
|
|
93
93
|
declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
|
|
@@ -1131,6 +1131,7 @@ export declare const routes: (Route<{
|
|
|
1131
1131
|
export declare const configure: (input?: Config) => {
|
|
1132
1132
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
1133
1133
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1134
|
+
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1134
1135
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1135
1136
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1136
1137
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
@@ -1139,6 +1140,7 @@ export declare const configure: (input?: Config) => {
|
|
|
1139
1140
|
export declare const provider: {
|
|
1140
1141
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
1141
1142
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1143
|
+
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1142
1144
|
responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1143
1145
|
image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1144
1146
|
decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
@@ -1146,6 +1148,7 @@ export declare const provider: {
|
|
|
1146
1148
|
};
|
|
1147
1149
|
export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
|
|
1148
1150
|
export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
|
|
1151
|
+
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
|
|
1149
1152
|
export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
1150
1153
|
export declare const model: ProviderPackage.Model<Settings, OpenRouterProviderOptionsInput>;
|
|
1151
1154
|
export declare const responsesModel: ProviderPackage.Model<Settings<OpenRouterResponsesProviderOptionsInput>, OpenRouterResponsesProviderOptionsInput>;
|
|
@@ -2,8 +2,7 @@ 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";
|
|
8
7
|
import { OpenAIImages } from "../protocols/openai-images.js";
|
|
9
8
|
import { MediaRoute } from "../route/media.js";
|
|
@@ -12,6 +11,7 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
|
12
11
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
13
12
|
import { cacheControl } from "../protocols/utils/cache.js";
|
|
14
13
|
import { isRecord, JsonObject, lenient, ProviderShared } from "../protocols/shared.js";
|
|
14
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
15
15
|
export const id = ProviderID.make("openrouter");
|
|
16
16
|
const baseURL = "https://openrouter.ai/api/v1";
|
|
17
17
|
const ADAPTER = "openrouter";
|
|
@@ -56,7 +56,7 @@ export const protocol = Protocol.make({
|
|
|
56
56
|
reasoning_details: reasoningDetails,
|
|
57
57
|
};
|
|
58
58
|
},
|
|
59
|
-
}).pipe(Effect.map((body) => bodyOptions(body, request.providerOptions, request.
|
|
59
|
+
}).pipe(Effect.map((body) => bodyOptions(body, request.providerOptions, request.maxTokens))),
|
|
60
60
|
},
|
|
61
61
|
stream: OpenAIChat.protocol.stream,
|
|
62
62
|
});
|
|
@@ -130,24 +130,22 @@ const responsesRoute = Route.make({
|
|
|
130
130
|
protocol: responsesProtocol,
|
|
131
131
|
endpoint: Endpoint.path("/responses", { baseURL }),
|
|
132
132
|
transport: HttpTransport.sseJson.with(),
|
|
133
|
-
|
|
133
|
+
options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
|
|
134
134
|
});
|
|
135
135
|
export const routes = [route, responsesRoute];
|
|
136
136
|
export const configure = (input = {}) => {
|
|
137
|
-
const
|
|
138
|
-
const auth = AuthOptions.bearer(input, "OPENROUTER_API_KEY");
|
|
139
|
-
const options = { ...defaults, endpoint: { baseURL: endpoint ?? baseURL }, auth };
|
|
137
|
+
const options = bearerRouteDefaults(input, "OPENROUTER_API_KEY", baseURL);
|
|
140
138
|
const chatRoute = route.with(options);
|
|
141
139
|
const configuredResponses = responsesRoute.with(options);
|
|
142
140
|
const decisionRoute = SystemOne.route.with({
|
|
143
141
|
provider: id,
|
|
144
142
|
providerMetadataKey: "openrouter",
|
|
145
|
-
endpoint:
|
|
146
|
-
auth,
|
|
143
|
+
endpoint: options.endpoint,
|
|
144
|
+
auth: options.auth,
|
|
147
145
|
headers: input.headers,
|
|
148
146
|
http: input.http,
|
|
149
147
|
});
|
|
150
|
-
const media = MediaRoute.deployment({ ...input, baseURL:
|
|
148
|
+
const media = MediaRoute.deployment({ ...input, baseURL: options.endpoint.baseURL }, options.auth);
|
|
151
149
|
const image = (modelID, providerOptions) => OpenAIImages.model({
|
|
152
150
|
...media,
|
|
153
151
|
id: modelID,
|
|
@@ -161,9 +159,11 @@ export const configure = (input = {}) => {
|
|
|
161
159
|
compatibility: { mediaInput: "state" },
|
|
162
160
|
providerOptions,
|
|
163
161
|
});
|
|
162
|
+
const chat = (modelID) => chatRoute.model({ id: modelID, capabilities: { promptCacheKey: true } });
|
|
164
163
|
return {
|
|
165
164
|
id,
|
|
166
|
-
model:
|
|
165
|
+
model: chat,
|
|
166
|
+
chat,
|
|
167
167
|
responses: (modelID) => configuredResponses.model({ id: modelID }),
|
|
168
168
|
image,
|
|
169
169
|
decision,
|
|
@@ -173,24 +173,16 @@ export const configure = (input = {}) => {
|
|
|
173
173
|
export const provider = configure();
|
|
174
174
|
export const decision = provider.decision;
|
|
175
175
|
export const image = provider.image;
|
|
176
|
+
export const chat = provider.chat;
|
|
176
177
|
export const responses = provider.responses;
|
|
177
|
-
export const model = (modelID, settings) => configure(
|
|
178
|
-
export const responsesModel = (modelID, settings) => configure(
|
|
178
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
179
|
+
export const responsesModel = (modelID, settings) => configure(toConfig(settings)).responses(modelID);
|
|
179
180
|
export const imageModel = (modelID, settings) => {
|
|
180
|
-
const input =
|
|
181
|
+
const input = toConfig(settings);
|
|
181
182
|
return configure(input).image(modelID, input.providerOptions);
|
|
182
183
|
};
|
|
183
184
|
export const decisionModel = (modelID, settings) => {
|
|
184
|
-
const input =
|
|
185
|
+
const input = toConfig(settings);
|
|
185
186
|
return configure(input).decision(modelID, input.providerOptions);
|
|
186
187
|
};
|
|
187
|
-
function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
|
|
188
|
-
return {
|
|
189
|
-
apiKey,
|
|
190
|
-
baseURL,
|
|
191
|
-
headers,
|
|
192
|
-
http: body === undefined ? undefined : { body },
|
|
193
|
-
providerOptions,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
188
|
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">;
|
|
@@ -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<{
|
|
@@ -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
|
};
|