@opencode/ai 0.0.0-dev-482 → 0.0.0-dev-513
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/effect.d.ts +1 -12
- package/dist/effect.js +1 -5
- package/dist/effort-updates.d.ts +2 -2
- package/dist/image-client.d.ts +4 -4
- package/dist/index.d.ts +1 -12
- package/dist/index.js +1 -5
- package/dist/protocols/alibaba-responses.js +8 -20
- package/dist/protocols/anthropic-messages.js +35 -89
- package/dist/protocols/bedrock-converse.js +2 -3
- package/dist/protocols/gemini.js +26 -40
- package/dist/protocols/meta-responses.js +1 -1
- 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.js +1 -3
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +2 -2
- package/dist/protocols/openai-responses.js +8 -26
- package/dist/protocols/utils/bedrock-cache.js +2 -5
- 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-hosted-tools.d.ts +97 -1
- package/dist/protocols/utils/responses-hosted-tools.js +31 -0
- package/dist/protocols/utils/tool-stream.d.ts +3 -209
- package/dist/protocols/utils/tool-stream.js +3 -13
- package/dist/protocols/xai-responses.js +4 -24
- package/dist/providers/baseten.d.ts +1 -1
- package/dist/providers/baseten.js +7 -21
- package/dist/providers/cerebras.d.ts +1 -1
- package/dist/providers/cerebras.js +3 -14
- package/dist/providers/cloudflare-ai-gateway.js +5 -25
- package/dist/providers/cloudflare-shared.d.ts +9 -0
- package/dist/providers/cloudflare-shared.js +25 -0
- package/dist/providers/cloudflare-workers-ai.js +4 -20
- package/dist/providers/cohere/chat.js +2 -7
- package/dist/providers/cohere.d.ts +1 -1
- package/dist/providers/cohere.js +5 -12
- package/dist/providers/deepinfra.d.ts +1 -1
- package/dist/providers/deepinfra.js +4 -12
- package/dist/providers/deepseek.d.ts +1 -1
- package/dist/providers/deepseek.js +3 -14
- package/dist/providers/digitalocean.d.ts +1 -1
- package/dist/providers/digitalocean.js +5 -7
- package/dist/providers/fireworks.d.ts +1 -1
- package/dist/providers/fireworks.js +3 -14
- package/dist/providers/google/interactions.js +2 -7
- package/dist/providers/google-vertex-chat.js +3 -29
- package/dist/providers/google-vertex-messages.js +3 -29
- package/dist/providers/google-vertex-mistral.js +3 -29
- package/dist/providers/google-vertex-responses.js +3 -29
- package/dist/providers/google-vertex-shared.d.ts +30 -0
- package/dist/providers/google-vertex-shared.js +25 -0
- package/dist/providers/google.js +3 -11
- package/dist/providers/groq.d.ts +1 -1
- package/dist/providers/groq.js +3 -14
- package/dist/providers/meta.d.ts +1 -1
- package/dist/providers/meta.js +6 -20
- package/dist/providers/minimax/chat.js +2 -7
- package/dist/providers/minimax/responses.js +2 -7
- package/dist/providers/minimax.d.ts +1 -1
- package/dist/providers/minimax.js +5 -20
- package/dist/providers/mistral.d.ts +1 -1
- 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 +1 -1
- package/dist/providers/moonshot.js +3 -14
- package/dist/providers/openai-compatible-responses.js +2 -8
- package/dist/providers/openai-compatible.js +3 -9
- package/dist/providers/opencode.d.ts +1 -1
- package/dist/providers/opencode.js +5 -1
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.js +9 -20
- package/dist/providers/settings.d.ts +40 -0
- package/dist/providers/settings.js +19 -0
- package/dist/providers/togetherai.d.ts +1 -1
- package/dist/providers/togetherai.js +3 -14
- package/dist/providers/typesafe-ai.d.ts +1 -1
- package/dist/providers/typesafe-ai.js +5 -1
- package/dist/providers/vercel-ai-gateway.d.ts +1 -1
- package/dist/providers/vercel-ai-gateway.js +8 -22
- package/dist/providers/xai.js +3 -11
- 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 +1 -1
- package/dist/providers/zai-coding-plan.js +3 -14
- package/dist/providers/zai.d.ts +1 -1
- package/dist/providers/zai.js +6 -22
- package/dist/public.d.ts +12 -0
- package/dist/public.js +5 -0
- package/dist/schema/events.js +31 -64
- package/dist/speech-client.d.ts +4 -4
- package/dist/transcription-client.d.ts +4 -4
- package/dist/video-client.d.ts +4 -4
- package/package.json +3 -3
|
@@ -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("cerebras");
|
|
7
7
|
const baseURL = "https://api.cerebras.ai/v1";
|
|
8
8
|
export const route = Route.make({
|
|
@@ -15,12 +15,7 @@ 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, "CEREBRAS_API_KEY"),
|
|
23
|
-
});
|
|
18
|
+
const configured = route.with(bearerRouteDefaults(input, "CEREBRAS_API_KEY", baseURL));
|
|
24
19
|
return {
|
|
25
20
|
id,
|
|
26
21
|
model: (modelID) => configured.model({
|
|
@@ -35,10 +30,4 @@ export const configure = (input = {}) => {
|
|
|
35
30
|
};
|
|
36
31
|
};
|
|
37
32
|
export const provider = configure();
|
|
38
|
-
export const model = (modelID,
|
|
39
|
-
apiKey,
|
|
40
|
-
baseURL,
|
|
41
|
-
headers,
|
|
42
|
-
http: body === undefined ? undefined : { body },
|
|
43
|
-
providerOptions,
|
|
44
|
-
}).model(modelID);
|
|
33
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
@@ -1,38 +1,18 @@
|
|
|
1
1
|
import { CloudflareRunDecisions } from "../protocols/cloudflare-run-decisions.js";
|
|
2
2
|
import { AnthropicMessages, OpenAIChat, OpenAIResponses } from "../protocols/index.js";
|
|
3
3
|
import { Auth } from "../route/auth.js";
|
|
4
|
-
import { Endpoint } from "../route/endpoint.js";
|
|
5
4
|
import { AuthOptions } from "../route/auth-options.js";
|
|
6
|
-
import {
|
|
5
|
+
import { ProviderID } from "../schema/index.js";
|
|
7
6
|
import { encodeJson } from "../utils/json.js";
|
|
7
|
+
import { CloudflareShared } from "./cloudflare-shared.js";
|
|
8
8
|
export const id = ProviderID.make("cloudflare-ai-gateway");
|
|
9
9
|
export const authEnvVars = ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKEN"];
|
|
10
|
-
export const baseURL = (input) =>
|
|
11
|
-
if (input.baseURL)
|
|
12
|
-
return input.baseURL;
|
|
13
|
-
return `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(requireAccountId(input))}/ai/v1`;
|
|
14
|
-
};
|
|
10
|
+
export const baseURL = (input) => CloudflareShared.baseURL(input, id, "CloudflareAIGateway");
|
|
15
11
|
/** The Run API (`/ai/run`) next to the OpenAI-compatible `/ai/v1` base. */
|
|
16
|
-
export const runBaseURL = (input) =>
|
|
17
|
-
const url = Endpoint.trimBaseUrl(baseURL(input));
|
|
18
|
-
if (!url.endsWith("/ai/v1"))
|
|
19
|
-
throw new ProviderConfigurationError({
|
|
20
|
-
provider: id,
|
|
21
|
-
message: "CloudflareAIGateway needs accountId or a baseURL ending in /ai/v1 to derive the Run API base",
|
|
22
|
-
});
|
|
23
|
-
return `${url.slice(0, -"/v1".length)}/run`;
|
|
24
|
-
};
|
|
12
|
+
export const runBaseURL = (input) => CloudflareShared.runBaseURL(input, id, "CloudflareAIGateway");
|
|
25
13
|
// Cloudflare's REST API rejects parts of the Anthropic Messages and OpenAI Responses request shapes, such as
|
|
26
14
|
// system prompt blocks and `minimal` reasoning effort, so these models use the provider-native gateway endpoints.
|
|
27
|
-
const passthroughURL = (input, provider) => `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(requireAccountId(input))}/${encodeURIComponent(gatewayId(input))}/${provider}`;
|
|
28
|
-
const requireAccountId = (input) => {
|
|
29
|
-
if (input.accountId)
|
|
30
|
-
return input.accountId;
|
|
31
|
-
throw new ProviderConfigurationError({
|
|
32
|
-
provider: id,
|
|
33
|
-
message: "CloudflareAIGateway.configure requires accountId unless baseURL is supplied",
|
|
34
|
-
});
|
|
35
|
-
};
|
|
15
|
+
const passthroughURL = (input, provider) => `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(CloudflareShared.requireAccountId(input, id, "CloudflareAIGateway"))}/${encodeURIComponent(gatewayId(input))}/${provider}`;
|
|
36
16
|
const gatewayId = (input) => input.gatewayId?.trim() || "default";
|
|
37
17
|
export const responsesRoute = OpenAIResponses.route.with({
|
|
38
18
|
id: "cloudflare-ai-gateway-responses",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ProviderID } from "../schema/index.js";
|
|
2
|
+
type AccountURL = {
|
|
3
|
+
readonly accountId?: string;
|
|
4
|
+
readonly baseURL?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const requireAccountId: (input: AccountURL, provider: ProviderID, name: string) => string;
|
|
7
|
+
export declare const baseURL: (input: AccountURL, provider: ProviderID, name: string) => string;
|
|
8
|
+
export declare const runBaseURL: (input: AccountURL, provider: ProviderID, name: string) => string;
|
|
9
|
+
export * as CloudflareShared from "./cloudflare-shared.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Endpoint } from "../route/endpoint.js";
|
|
2
|
+
import { ProviderConfigurationError } from "../schema/index.js";
|
|
3
|
+
export const requireAccountId = (input, provider, name) => {
|
|
4
|
+
if (input.accountId)
|
|
5
|
+
return input.accountId;
|
|
6
|
+
throw new ProviderConfigurationError({
|
|
7
|
+
provider,
|
|
8
|
+
message: `${name}.configure requires accountId unless baseURL is supplied`,
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export const baseURL = (input, provider, name) => {
|
|
12
|
+
if (input.baseURL)
|
|
13
|
+
return input.baseURL;
|
|
14
|
+
return `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(requireAccountId(input, provider, name))}/ai/v1`;
|
|
15
|
+
};
|
|
16
|
+
export const runBaseURL = (input, provider, name) => {
|
|
17
|
+
const url = Endpoint.trimBaseUrl(baseURL(input, provider, name));
|
|
18
|
+
if (!url.endsWith("/ai/v1"))
|
|
19
|
+
throw new ProviderConfigurationError({
|
|
20
|
+
provider,
|
|
21
|
+
message: `${name} needs accountId or a baseURL ending in /ai/v1 to derive the Run API base`,
|
|
22
|
+
});
|
|
23
|
+
return `${url.slice(0, -"/v1".length)}/run`;
|
|
24
|
+
};
|
|
25
|
+
export * as CloudflareShared from "./cloudflare-shared.js";
|
|
@@ -6,29 +6,13 @@ import { AuthOptions } from "../route/auth-options.js";
|
|
|
6
6
|
import { Route } from "../route/client.js";
|
|
7
7
|
import { Endpoint } from "../route/endpoint.js";
|
|
8
8
|
import { MediaRoute } from "../route/media.js";
|
|
9
|
-
import {
|
|
9
|
+
import { ProviderID } from "../schema/index.js";
|
|
10
|
+
import { CloudflareShared } from "./cloudflare-shared.js";
|
|
10
11
|
export const id = ProviderID.make("cloudflare-workers-ai");
|
|
11
12
|
export const authEnvVars = ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN", "CLOUDFLARE_API_TOKEN"];
|
|
12
|
-
export const baseURL = (input) =>
|
|
13
|
-
if (input.baseURL)
|
|
14
|
-
return input.baseURL;
|
|
15
|
-
if (!input.accountId)
|
|
16
|
-
throw new ProviderConfigurationError({
|
|
17
|
-
provider: id,
|
|
18
|
-
message: "CloudflareWorkersAI.configure requires accountId unless baseURL is supplied",
|
|
19
|
-
});
|
|
20
|
-
return `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(input.accountId)}/ai/v1`;
|
|
21
|
-
};
|
|
13
|
+
export const baseURL = (input) => CloudflareShared.baseURL(input, id, "CloudflareWorkersAI");
|
|
22
14
|
/** The Run API (`/ai/run`) next to the OpenAI-compatible `/ai/v1` base. */
|
|
23
|
-
export const runBaseURL = (input) =>
|
|
24
|
-
const url = Endpoint.trimBaseUrl(baseURL(input));
|
|
25
|
-
if (!url.endsWith("/ai/v1"))
|
|
26
|
-
throw new ProviderConfigurationError({
|
|
27
|
-
provider: id,
|
|
28
|
-
message: "CloudflareWorkersAI needs accountId or a baseURL ending in /ai/v1 to derive the Run API base",
|
|
29
|
-
});
|
|
30
|
-
return `${url.slice(0, -"/v1".length)}/run`;
|
|
31
|
-
};
|
|
15
|
+
export const runBaseURL = (input) => CloudflareShared.runBaseURL(input, id, "CloudflareWorkersAI");
|
|
32
16
|
export const route = Route.make({
|
|
33
17
|
id: "cloudflare-workers-ai",
|
|
34
18
|
provider: id,
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { Cohere } from "../cohere.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
baseURL,
|
|
5
|
-
headers,
|
|
6
|
-
http: body === undefined ? undefined : { body },
|
|
7
|
-
providerOptions,
|
|
8
|
-
}).chat(modelID);
|
|
2
|
+
import { toConfig } from "../settings.js";
|
|
3
|
+
export const model = (modelID, settings) => Cohere.configure(toConfig(settings)).chat(modelID);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CohereChat } from "../protocols/cohere-chat.js";
|
|
2
2
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import { type ModelID, type OpenString } from "../schema/index.js";
|
|
5
5
|
import type { ProviderPackage } from "../provider-package.js";
|
|
6
6
|
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
package/dist/providers/cohere.js
CHANGED
|
@@ -2,8 +2,8 @@ import { CohereChat } from "../protocols/cohere-chat.js";
|
|
|
2
2
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
3
3
|
import { Route } from "../route/client.js";
|
|
4
4
|
import { Endpoint } from "../route/endpoint.js";
|
|
5
|
-
import { AuthOptions } from "../route/auth-options.js";
|
|
6
5
|
import { ProviderID } from "../schema/index.js";
|
|
6
|
+
import { bearerRouteDefaults, toConfig } from "./settings.js";
|
|
7
7
|
export const id = ProviderID.make("cohere");
|
|
8
8
|
const COMPATIBILITY_BASE_URL = "https://api.cohere.ai/compatibility/v1";
|
|
9
9
|
export const route = CohereChat.route;
|
|
@@ -17,10 +17,9 @@ export const chatRoute = Route.make({
|
|
|
17
17
|
});
|
|
18
18
|
export const routes = [route, chatRoute];
|
|
19
19
|
export const configure = (input = {}) => {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const chat = chatRoute.with({ ...defaults, auth, endpoint: { baseURL: baseURL ?? COMPATIBILITY_BASE_URL } });
|
|
20
|
+
const options = bearerRouteDefaults(input, "COHERE_API_KEY", CohereChat.DEFAULT_BASE_URL);
|
|
21
|
+
const native = route.with(options);
|
|
22
|
+
const chat = chatRoute.with({ ...options, endpoint: { baseURL: input.baseURL ?? COMPATIBILITY_BASE_URL } });
|
|
24
23
|
return {
|
|
25
24
|
id,
|
|
26
25
|
model: (modelID) => native.model({ id: modelID }),
|
|
@@ -37,11 +36,5 @@ export const configure = (input = {}) => {
|
|
|
37
36
|
};
|
|
38
37
|
export const provider = configure();
|
|
39
38
|
export const chat = provider.chat;
|
|
40
|
-
export const model = (modelID,
|
|
41
|
-
apiKey,
|
|
42
|
-
baseURL,
|
|
43
|
-
headers,
|
|
44
|
-
http: body === undefined ? undefined : { body },
|
|
45
|
-
providerOptions,
|
|
46
|
-
}).model(modelID);
|
|
39
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
47
40
|
export * as Cohere from "./cohere.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
3
3
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
4
4
|
import { type ModelID } from "../schema/index.js";
|
|
5
5
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
@@ -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("deepinfra");
|
|
7
7
|
const baseURL = "https://api.deepinfra.com/v1/openai";
|
|
8
8
|
export const route = Route.make({
|
|
@@ -15,14 +15,12 @@ export const route = Route.make({
|
|
|
15
15
|
});
|
|
16
16
|
export const routes = [route];
|
|
17
17
|
export const configure = (input = {}) => {
|
|
18
|
-
const
|
|
19
|
-
const root = endpoint?.replace(/\/+$/, "");
|
|
18
|
+
const root = input.baseURL?.replace(/\/+$/, "");
|
|
20
19
|
const configured = route.with({
|
|
21
|
-
...
|
|
20
|
+
...bearerRouteDefaults(input, "DEEPINFRA_API_KEY"),
|
|
22
21
|
endpoint: {
|
|
23
22
|
baseURL: root === undefined ? baseURL : root.endsWith("/openai") ? root : `${root}/openai`,
|
|
24
23
|
},
|
|
25
|
-
auth: AuthOptions.bearer(input, "DEEPINFRA_API_KEY"),
|
|
26
24
|
});
|
|
27
25
|
return {
|
|
28
26
|
id,
|
|
@@ -38,10 +36,4 @@ export const configure = (input = {}) => {
|
|
|
38
36
|
};
|
|
39
37
|
};
|
|
40
38
|
export const provider = configure();
|
|
41
|
-
export const model = (modelID,
|
|
42
|
-
apiKey,
|
|
43
|
-
baseURL,
|
|
44
|
-
headers,
|
|
45
|
-
http: body === undefined ? undefined : { body },
|
|
46
|
-
providerOptions,
|
|
47
|
-
}).model(modelID);
|
|
39
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
3
3
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
4
4
|
import { type ModelID } from "../schema/index.js";
|
|
5
5
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
@@ -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("deepseek");
|
|
7
7
|
const baseURL = "https://api.deepseek.com/v1";
|
|
8
8
|
export const route = Route.make({
|
|
@@ -15,12 +15,7 @@ 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, "DEEPSEEK_API_KEY"),
|
|
23
|
-
});
|
|
18
|
+
const configured = route.with(bearerRouteDefaults(input, "DEEPSEEK_API_KEY", baseURL));
|
|
24
19
|
return {
|
|
25
20
|
id,
|
|
26
21
|
model: (modelID) => configured.model({
|
|
@@ -31,11 +26,5 @@ export const configure = (input = {}) => {
|
|
|
31
26
|
};
|
|
32
27
|
};
|
|
33
28
|
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);
|
|
29
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
41
30
|
export * as DeepSeek from "./deepseek.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
2
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
4
4
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
5
5
|
import { Protocol } from "../route/protocol.js";
|
|
6
6
|
import { type ModelID, type ProviderOptions } from "../schema/index.js";
|
|
@@ -3,12 +3,12 @@ import { OpenAIImages } from "../protocols/openai-images.js";
|
|
|
3
3
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
4
4
|
import { SystemOne } from "../protocols/system-one.js";
|
|
5
5
|
import { cacheControl } from "../protocols/utils/cache.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 { MediaRoute } from "../route/media.js";
|
|
10
9
|
import { Protocol } from "../route/protocol.js";
|
|
11
10
|
import { ProviderID } from "../schema/index.js";
|
|
11
|
+
import { bearerRouteDefaults } from "./settings.js";
|
|
12
12
|
export const id = ProviderID.make("digitalocean");
|
|
13
13
|
const baseURL = "https://inference.do-ai.run/v1";
|
|
14
14
|
export const protocol = Protocol.make({
|
|
@@ -38,22 +38,20 @@ const responsesRoute = Route.make({
|
|
|
38
38
|
});
|
|
39
39
|
export const routes = [route, responsesRoute];
|
|
40
40
|
export const configure = (input = {}) => {
|
|
41
|
-
const
|
|
42
|
-
const auth = AuthOptions.bearer(input, ["DIGITALOCEAN_ACCESS_TOKEN", "DIGITALOCEAN_API_KEY", "DO_INFERENCE_API_KEY"]);
|
|
43
|
-
const options = { ...defaults, endpoint: { baseURL: endpoint ?? baseURL }, auth };
|
|
41
|
+
const options = bearerRouteDefaults(input, ["DIGITALOCEAN_ACCESS_TOKEN", "DIGITALOCEAN_API_KEY", "DO_INFERENCE_API_KEY"], baseURL);
|
|
44
42
|
const configured = route.with(options);
|
|
45
43
|
const configuredResponses = responsesRoute.with(options);
|
|
46
44
|
const decisionRoute = SystemOne.route.with({
|
|
47
45
|
provider: id,
|
|
48
46
|
providerMetadataKey: "digitalocean",
|
|
49
|
-
endpoint:
|
|
50
|
-
auth,
|
|
47
|
+
endpoint: options.endpoint,
|
|
48
|
+
auth: options.auth,
|
|
51
49
|
// DigitalOcean serves TypeSafe's Jev, which needs this header for images.
|
|
52
50
|
headers: { "TypeSafe-Danger-Zone-Images": "true", ...input.headers },
|
|
53
51
|
http: input.http,
|
|
54
52
|
});
|
|
55
53
|
const decision = (modelID, providerOptions) => decisionRoute.model({ id: modelID, providerOptions });
|
|
56
|
-
const media = MediaRoute.deployment({ ...input, baseURL: endpoint
|
|
54
|
+
const media = MediaRoute.deployment({ ...input, baseURL: options.endpoint.baseURL }, options.auth);
|
|
57
55
|
const image = (modelID, providerOptions) => OpenAIImages.model({ ...media, id: modelID, provider: id, providerOptions });
|
|
58
56
|
const chat = (modelID) => configured.model({
|
|
59
57
|
id: modelID,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { ProviderAuthOption } from "../route/auth-options.js";
|
|
3
3
|
import { Route, type RouteDefaultsInput } from "../route/client.js";
|
|
4
4
|
import { type ModelID } from "../schema/index.js";
|
|
5
5
|
import type { OpenAIProviderOptionsInput } from "./openai-options.js";
|
|
@@ -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("fireworks");
|
|
7
7
|
const baseURL = "https://api.fireworks.ai/inference/v1";
|
|
8
8
|
export const route = Route.make({
|
|
@@ -15,12 +15,7 @@ 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, "FIREWORKS_API_KEY"),
|
|
23
|
-
});
|
|
18
|
+
const configured = route.with(bearerRouteDefaults(input, "FIREWORKS_API_KEY", baseURL));
|
|
24
19
|
return {
|
|
25
20
|
id,
|
|
26
21
|
model: (modelID) => configured.model({ id: modelID, compatibility: { supportsPromptCacheKey: true } }),
|
|
@@ -28,11 +23,5 @@ export const configure = (input = {}) => {
|
|
|
28
23
|
};
|
|
29
24
|
};
|
|
30
25
|
export const provider = configure();
|
|
31
|
-
export const model = (modelID,
|
|
32
|
-
apiKey,
|
|
33
|
-
baseURL,
|
|
34
|
-
headers,
|
|
35
|
-
http: body === undefined ? undefined : { body },
|
|
36
|
-
providerOptions,
|
|
37
|
-
}).model(modelID);
|
|
26
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
|
|
38
27
|
export * as Fireworks from "./fireworks.js";
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { configure } from "../google.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
baseURL,
|
|
5
|
-
headers,
|
|
6
|
-
http: body === undefined ? undefined : { body },
|
|
7
|
-
providerOptions,
|
|
8
|
-
}).interactions(modelID);
|
|
2
|
+
import { toConfig } from "../settings.js";
|
|
3
|
+
export const model = (modelID, settings) => configure(toConfig(settings)).interactions(modelID);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
2
2
|
import { Route } from "../route/client.js";
|
|
3
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ProviderID } from "../schema/index.js";
|
|
5
5
|
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
6
6
|
export const id = ProviderID.make("google-vertex");
|
|
7
7
|
const route = Route.make({
|
|
@@ -13,21 +13,7 @@ const route = Route.make({
|
|
|
13
13
|
framing: OpenAIChat.framing,
|
|
14
14
|
});
|
|
15
15
|
export const routes = [route];
|
|
16
|
-
const configuredRoute = (input) => {
|
|
17
|
-
if ("apiKey" in input && input.apiKey !== undefined)
|
|
18
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Chat does not support API keys" });
|
|
19
|
-
const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
|
|
20
|
-
const location = GoogleVertexShared.location(inputLocation);
|
|
21
|
-
const project = GoogleVertexShared.project(inputProject);
|
|
22
|
-
return route.with({
|
|
23
|
-
...rest,
|
|
24
|
-
endpoint: {
|
|
25
|
-
baseURL: baseURL ??
|
|
26
|
-
`https://aiplatform.googleapis.com/v1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}/endpoints/openapi`,
|
|
27
|
-
},
|
|
28
|
-
auth: GoogleVertexShared.oauth(input, project),
|
|
29
|
-
});
|
|
30
|
-
};
|
|
16
|
+
const configuredRoute = (input) => GoogleVertexShared.oauthRoute(route, "Chat", input, (project, location) => `https://aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/endpoints/openapi`);
|
|
31
17
|
export const configure = (input = {}) => {
|
|
32
18
|
const route = configuredRoute(input);
|
|
33
19
|
return {
|
|
@@ -40,16 +26,4 @@ export const provider = {
|
|
|
40
26
|
id,
|
|
41
27
|
configure,
|
|
42
28
|
};
|
|
43
|
-
export const model = (modelID,
|
|
44
|
-
if (apiKey !== undefined)
|
|
45
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Chat does not support API keys" });
|
|
46
|
-
return configure({
|
|
47
|
-
accessToken,
|
|
48
|
-
baseURL,
|
|
49
|
-
headers,
|
|
50
|
-
http: body === undefined ? undefined : { body },
|
|
51
|
-
location,
|
|
52
|
-
project,
|
|
53
|
-
providerOptions,
|
|
54
|
-
}).model(modelID);
|
|
55
|
-
};
|
|
29
|
+
export const model = (modelID, settings = {}) => configure(GoogleVertexShared.oauthSettings("Chat", settings)).model(modelID);
|
|
@@ -4,7 +4,7 @@ import { Auth } from "../route/auth.js";
|
|
|
4
4
|
import { Route } from "../route/client.js";
|
|
5
5
|
import { Endpoint } from "../route/endpoint.js";
|
|
6
6
|
import { Protocol } from "../route/protocol.js";
|
|
7
|
-
import {
|
|
7
|
+
import { ProviderID } from "../schema/index.js";
|
|
8
8
|
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
9
9
|
const VERSION = "vertex-2023-10-16";
|
|
10
10
|
const HEADER_VERSION = "2023-06-01";
|
|
@@ -34,21 +34,7 @@ const route = Route.make({
|
|
|
34
34
|
headers: () => ({ "anthropic-version": HEADER_VERSION }),
|
|
35
35
|
});
|
|
36
36
|
export const routes = [route];
|
|
37
|
-
const configuredRoute = (input) => {
|
|
38
|
-
if ("apiKey" in input && input.apiKey !== undefined)
|
|
39
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Messages does not support API keys" });
|
|
40
|
-
const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
|
|
41
|
-
const location = GoogleVertexShared.location(inputLocation);
|
|
42
|
-
const project = GoogleVertexShared.project(inputProject);
|
|
43
|
-
return route.with({
|
|
44
|
-
...rest,
|
|
45
|
-
endpoint: {
|
|
46
|
-
baseURL: baseURL ??
|
|
47
|
-
`https://${GoogleVertexShared.host(location)}/v1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}/publishers/anthropic/models`,
|
|
48
|
-
},
|
|
49
|
-
auth: GoogleVertexShared.oauth(input, project),
|
|
50
|
-
});
|
|
51
|
-
};
|
|
37
|
+
const configuredRoute = (input) => GoogleVertexShared.oauthRoute(route, "Messages", input, (project, location) => `https://${GoogleVertexShared.host(location)}/v1/projects/${project}/locations/${location}/publishers/anthropic/models`);
|
|
52
38
|
export const configure = (input = {}) => {
|
|
53
39
|
const route = configuredRoute(input);
|
|
54
40
|
return {
|
|
@@ -61,16 +47,4 @@ export const provider = {
|
|
|
61
47
|
id,
|
|
62
48
|
configure,
|
|
63
49
|
};
|
|
64
|
-
export const model = (modelID,
|
|
65
|
-
if (apiKey !== undefined)
|
|
66
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Messages does not support API keys" });
|
|
67
|
-
return configure({
|
|
68
|
-
accessToken,
|
|
69
|
-
baseURL,
|
|
70
|
-
headers,
|
|
71
|
-
http: body === undefined ? undefined : { body },
|
|
72
|
-
location,
|
|
73
|
-
project,
|
|
74
|
-
providerOptions,
|
|
75
|
-
}).model(modelID);
|
|
76
|
-
};
|
|
50
|
+
export const model = (modelID, settings = {}) => configure(GoogleVertexShared.oauthSettings("Messages", settings)).model(modelID);
|
|
@@ -5,7 +5,7 @@ import { Route } from "../route/client.js";
|
|
|
5
5
|
import { Endpoint } from "../route/endpoint.js";
|
|
6
6
|
import { Protocol } from "../route/protocol.js";
|
|
7
7
|
import { HttpTransport } from "../route/transport/index.js";
|
|
8
|
-
import {
|
|
8
|
+
import { ProviderID } from "../schema/index.js";
|
|
9
9
|
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
10
10
|
export const id = ProviderID.make("google-vertex");
|
|
11
11
|
// Mistral on Vertex takes the Mistral chat body, model included, through the publisher's streamRawPredict method.
|
|
@@ -27,21 +27,7 @@ const route = Route.make({
|
|
|
27
27
|
transport: HttpTransport.sseJson.with().with({ framing: MistralChat.framing }),
|
|
28
28
|
});
|
|
29
29
|
export const routes = [route];
|
|
30
|
-
const configuredRoute = (input) => {
|
|
31
|
-
if ("apiKey" in input && input.apiKey !== undefined)
|
|
32
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Mistral does not support API keys" });
|
|
33
|
-
const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
|
|
34
|
-
const location = GoogleVertexShared.location(inputLocation);
|
|
35
|
-
const project = GoogleVertexShared.project(inputProject);
|
|
36
|
-
return route.with({
|
|
37
|
-
...rest,
|
|
38
|
-
endpoint: {
|
|
39
|
-
baseURL: baseURL ??
|
|
40
|
-
`https://${GoogleVertexShared.host(location)}/v1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}/publishers/mistralai/models`,
|
|
41
|
-
},
|
|
42
|
-
auth: GoogleVertexShared.oauth(input, project),
|
|
43
|
-
});
|
|
44
|
-
};
|
|
30
|
+
const configuredRoute = (input) => GoogleVertexShared.oauthRoute(route, "Mistral", input, (project, location) => `https://${GoogleVertexShared.host(location)}/v1/projects/${project}/locations/${location}/publishers/mistralai/models`);
|
|
45
31
|
export const configure = (input = {}) => {
|
|
46
32
|
const route = configuredRoute(input);
|
|
47
33
|
return {
|
|
@@ -54,16 +40,4 @@ export const provider = {
|
|
|
54
40
|
id,
|
|
55
41
|
configure,
|
|
56
42
|
};
|
|
57
|
-
export const model = (modelID,
|
|
58
|
-
if (apiKey !== undefined)
|
|
59
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Mistral does not support API keys" });
|
|
60
|
-
return configure({
|
|
61
|
-
accessToken,
|
|
62
|
-
baseURL,
|
|
63
|
-
headers,
|
|
64
|
-
http: body === undefined ? undefined : { body },
|
|
65
|
-
location,
|
|
66
|
-
project,
|
|
67
|
-
providerOptions,
|
|
68
|
-
}).model(modelID);
|
|
69
|
-
};
|
|
43
|
+
export const model = (modelID, settings = {}) => configure(GoogleVertexShared.oauthSettings("Mistral", settings)).model(modelID);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OpenResponses } from "../protocols/open-responses.js";
|
|
2
2
|
import { Route } from "../route/client.js";
|
|
3
3
|
import { Endpoint } from "../route/endpoint.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ProviderID } from "../schema/index.js";
|
|
5
5
|
import { GoogleVertexShared } from "./google-vertex-shared.js";
|
|
6
6
|
export const id = ProviderID.make("google-vertex");
|
|
7
7
|
const route = Route.make({
|
|
@@ -14,21 +14,7 @@ const route = Route.make({
|
|
|
14
14
|
defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
|
|
15
15
|
});
|
|
16
16
|
export const routes = [route];
|
|
17
|
-
const configuredRoute = (input) => {
|
|
18
|
-
if ("apiKey" in input && input.apiKey !== undefined)
|
|
19
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Responses does not support API keys" });
|
|
20
|
-
const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
|
|
21
|
-
const location = GoogleVertexShared.location(inputLocation);
|
|
22
|
-
const project = GoogleVertexShared.project(inputProject);
|
|
23
|
-
return route.with({
|
|
24
|
-
...rest,
|
|
25
|
-
endpoint: {
|
|
26
|
-
baseURL: baseURL ??
|
|
27
|
-
`https://aiplatform.googleapis.com/v1/projects/${GoogleVertexShared.requireProject(project)}/locations/${location}/endpoints/openapi`,
|
|
28
|
-
},
|
|
29
|
-
auth: GoogleVertexShared.oauth(input, project),
|
|
30
|
-
});
|
|
31
|
-
};
|
|
17
|
+
const configuredRoute = (input) => GoogleVertexShared.oauthRoute(route, "Responses", input, (project, location) => `https://aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/endpoints/openapi`);
|
|
32
18
|
export const configure = (input = {}) => {
|
|
33
19
|
const route = configuredRoute(input);
|
|
34
20
|
return {
|
|
@@ -41,16 +27,4 @@ export const provider = {
|
|
|
41
27
|
id,
|
|
42
28
|
configure,
|
|
43
29
|
};
|
|
44
|
-
export const model = (modelID,
|
|
45
|
-
if (apiKey !== undefined)
|
|
46
|
-
throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Responses does not support API keys" });
|
|
47
|
-
return configure({
|
|
48
|
-
accessToken,
|
|
49
|
-
baseURL,
|
|
50
|
-
headers,
|
|
51
|
-
http: body === undefined ? undefined : { body },
|
|
52
|
-
location,
|
|
53
|
-
project,
|
|
54
|
-
providerOptions,
|
|
55
|
-
}).model(modelID);
|
|
56
|
-
};
|
|
30
|
+
export const model = (modelID, settings = {}) => configure(GoogleVertexShared.oauthSettings("Responses", settings)).model(modelID);
|