@opencode/ai 0.0.0-beta-19422 → 0.0.0-beta-19500

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.
Files changed (80) hide show
  1. package/dist/protocols/anthropic-messages.js +4 -1
  2. package/dist/protocols/open-responses-channel.d.ts +2 -0
  3. package/dist/protocols/open-responses-channel.js +2 -2
  4. package/dist/protocols/open-responses-continuation.d.ts +7 -3
  5. package/dist/protocols/open-responses-continuation.js +8 -6
  6. package/dist/protocols/open-responses.d.ts +137 -2
  7. package/dist/protocols/open-responses.js +24 -5
  8. package/dist/provider-package.d.ts +4 -0
  9. package/dist/providers/alibaba.d.ts +1 -2
  10. package/dist/providers/alibaba.js +12 -4
  11. package/dist/providers/amazon-bedrock-mantle.d.ts +4 -62
  12. package/dist/providers/amazon-bedrock-mantle.js +23 -20
  13. package/dist/providers/amazon-bedrock.js +3 -3
  14. package/dist/providers/anthropic-compatible.d.ts +1 -2
  15. package/dist/providers/anthropic-compatible.js +18 -12
  16. package/dist/providers/anthropic.d.ts +1 -2
  17. package/dist/providers/anthropic.js +12 -9
  18. package/dist/providers/azure.d.ts +1 -2
  19. package/dist/providers/azure.js +14 -14
  20. package/dist/providers/baseten.d.ts +2 -3
  21. package/dist/providers/baseten.js +6 -6
  22. package/dist/providers/cerebras.d.ts +2 -3
  23. package/dist/providers/cerebras.js +6 -6
  24. package/dist/providers/cloudflare-ai-gateway.d.ts +1 -2
  25. package/dist/providers/cloudflare-ai-gateway.js +16 -10
  26. package/dist/providers/cloudflare-workers-ai.d.ts +1 -2
  27. package/dist/providers/cloudflare-workers-ai.js +15 -9
  28. package/dist/providers/deepinfra.d.ts +2 -3
  29. package/dist/providers/deepinfra.js +6 -6
  30. package/dist/providers/deepseek.d.ts +2 -3
  31. package/dist/providers/deepseek.js +6 -6
  32. package/dist/providers/fireworks.d.ts +2 -3
  33. package/dist/providers/fireworks.js +6 -6
  34. package/dist/providers/google-vertex-chat.d.ts +2 -3
  35. package/dist/providers/google-vertex-chat.js +12 -12
  36. package/dist/providers/google-vertex-messages.d.ts +2 -3
  37. package/dist/providers/google-vertex-messages.js +12 -12
  38. package/dist/providers/google-vertex-responses.d.ts +2 -3
  39. package/dist/providers/google-vertex-responses.js +12 -12
  40. package/dist/providers/google-vertex-shared.js +14 -3
  41. package/dist/providers/google-vertex.d.ts +1 -2
  42. package/dist/providers/google-vertex.js +18 -12
  43. package/dist/providers/google.d.ts +2 -3
  44. package/dist/providers/google.js +6 -6
  45. package/dist/providers/groq.d.ts +2 -3
  46. package/dist/providers/groq.js +6 -6
  47. package/dist/providers/meta.d.ts +2 -3
  48. package/dist/providers/meta.js +6 -6
  49. package/dist/providers/minimax/chat.js +6 -6
  50. package/dist/providers/minimax/responses.js +6 -6
  51. package/dist/providers/minimax.d.ts +2 -3
  52. package/dist/providers/minimax.js +6 -6
  53. package/dist/providers/mistral.d.ts +2 -3
  54. package/dist/providers/mistral.js +6 -6
  55. package/dist/providers/moonshot/messages.js +6 -6
  56. package/dist/providers/moonshot/responses.js +6 -6
  57. package/dist/providers/moonshot.d.ts +2 -3
  58. package/dist/providers/moonshot.js +6 -6
  59. package/dist/providers/openai-compatible-responses.d.ts +2 -3
  60. package/dist/providers/openai-compatible-responses.js +7 -7
  61. package/dist/providers/openai-compatible.d.ts +2 -3
  62. package/dist/providers/openai-compatible.js +7 -7
  63. package/dist/providers/openai.d.ts +2 -3
  64. package/dist/providers/openai.js +9 -9
  65. package/dist/providers/openrouter.d.ts +2 -3
  66. package/dist/providers/openrouter.js +6 -6
  67. package/dist/providers/togetherai.d.ts +2 -3
  68. package/dist/providers/togetherai.js +6 -6
  69. package/dist/providers/xai.d.ts +2 -3
  70. package/dist/providers/xai.js +10 -6
  71. package/dist/providers/zai-coding-plan/messages.js +6 -6
  72. package/dist/providers/zai-coding-plan/responses.js +6 -6
  73. package/dist/providers/zai-coding-plan.d.ts +2 -3
  74. package/dist/providers/zai-coding-plan.js +6 -6
  75. package/dist/providers/zai.d.ts +2 -3
  76. package/dist/providers/zai.js +6 -6
  77. package/dist/route/client.js +5 -2
  78. package/dist/schema/errors.d.ts +12 -0
  79. package/dist/schema/errors.js +11 -0
  80. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  import { AnthropicMessages } from "../protocols/anthropic-messages.js";
2
2
  import { Auth } from "../route/auth.js";
3
- import { ProviderID } from "../schema/index.js";
3
+ import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
4
4
  export const id = ProviderID.make("anthropic-compatible");
5
5
  export const routes = [AnthropicMessages.route];
6
6
  const auth = (input) => {
@@ -9,9 +9,12 @@ const auth = (input) => {
9
9
  return Auth.optional("apiKey" in input ? input.apiKey : undefined, "apiKey").pipe(Auth.header("x-api-key"));
10
10
  };
11
11
  export const configure = (input) => {
12
- if (!input.baseURL)
13
- throw new Error("Anthropic-compatible providers require a baseURL");
14
12
  const provider = input.provider ?? "anthropic-compatible";
13
+ if (!input.baseURL)
14
+ throw new ProviderConfigurationError({
15
+ provider: ProviderID.make(provider),
16
+ message: "Anthropic-compatible providers require a baseURL",
17
+ });
15
18
  const { provider: _, baseURL, apiKey: _apiKey, auth: _auth, ...rest } = input;
16
19
  const route = AnthropicMessages.route.with({
17
20
  ...rest,
@@ -29,16 +32,19 @@ export const provider = {
29
32
  id,
30
33
  configure,
31
34
  };
32
- export const model = (modelID, settings) => {
33
- if (settings.apiKey !== undefined && settings.authToken !== undefined)
34
- throw new Error("Anthropic-compatible apiKey cannot be combined with authToken");
35
+ export const model = (modelID, { apiKey, authToken, baseURL, body, headers, provider, ...providerOptions }) => {
36
+ if (apiKey !== undefined && authToken !== undefined)
37
+ throw new ProviderConfigurationError({
38
+ provider: ProviderID.make(provider ?? id),
39
+ message: "Anthropic-compatible apiKey cannot be combined with authToken",
40
+ });
35
41
  return configure({
36
- ...(settings.authToken === undefined ? { apiKey: settings.apiKey } : { auth: Auth.bearer(settings.authToken) }),
37
- baseURL: settings.baseURL,
38
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
39
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
40
- provider: settings.provider,
41
- providerOptions: settings.providerOptions,
42
+ ...(authToken === undefined ? { apiKey: apiKey } : { auth: Auth.bearer(authToken) }),
43
+ baseURL,
44
+ headers: headers === undefined ? undefined : { ...headers },
45
+ http: body === undefined ? undefined : { body: { ...body } },
46
+ provider,
47
+ providerOptions,
42
48
  }).model(modelID);
43
49
  };
44
50
  export * as AnthropicCompatible from "./anthropic-compatible.js";
@@ -281,7 +281,7 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
281
281
  readonly baseURL?: string;
282
282
  readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
283
283
  };
284
- export type Settings = ProviderPackage.Settings & ({
284
+ export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOptionsInput & ({
285
285
  readonly apiKey?: string;
286
286
  readonly authToken?: never;
287
287
  } | {
@@ -289,7 +289,6 @@ export type Settings = ProviderPackage.Settings & ({
289
289
  readonly authToken?: string;
290
290
  }) & {
291
291
  readonly baseURL?: string;
292
- readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
293
292
  };
294
293
  export declare const configure: (input?: Config) => {
295
294
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -1,5 +1,5 @@
1
1
  import { Auth } from "../route/auth.js";
2
- import { ProviderID } from "../schema/index.js";
2
+ import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
3
3
  import { AnthropicMessages } from "../protocols/anthropic-messages.js";
4
4
  import { AnthropicCompatible } from "./anthropic-compatible.js";
5
5
  export const id = ProviderID.make("anthropic");
@@ -26,14 +26,17 @@ export const configure = (input = {}) => {
26
26
  };
27
27
  };
28
28
  export const provider = configure();
29
- export const model = (modelID, settings) => {
30
- if (settings.apiKey !== undefined && settings.authToken !== undefined)
31
- throw new Error("Anthropic apiKey cannot be combined with authToken");
29
+ export const model = (modelID, { apiKey, authToken, baseURL, body, headers, ...providerOptions }) => {
30
+ if (apiKey !== undefined && authToken !== undefined)
31
+ throw new ProviderConfigurationError({
32
+ provider: id,
33
+ message: "Anthropic apiKey cannot be combined with authToken",
34
+ });
32
35
  return configure({
33
- ...(settings.authToken === undefined ? { apiKey: settings.apiKey } : { auth: Auth.bearer(settings.authToken) }),
34
- baseURL: settings.baseURL,
35
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
36
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
37
- providerOptions: settings.providerOptions,
36
+ ...(authToken === undefined ? { apiKey: apiKey } : { auth: Auth.bearer(authToken) }),
37
+ baseURL,
38
+ headers: headers === undefined ? undefined : { ...headers },
39
+ http: body === undefined ? undefined : { body: { ...body } },
40
+ providerOptions,
38
41
  }).model(modelID);
39
42
  };
@@ -15,12 +15,11 @@ export type LanguageModelOptions = AzureURL & RouteDefaultsInput & ProviderAuthO
15
15
  readonly providerOptions?: OpenAIProviderOptionsInput;
16
16
  };
17
17
  export type Config = LanguageModelOptions;
18
- export type Settings = ProviderPackage.Settings & AzureURL & {
18
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & AzureURL & {
19
19
  readonly apiKey?: string;
20
20
  readonly apiVersion?: string;
21
21
  readonly queryParams?: Readonly<Record<string, string>>;
22
22
  readonly useDeploymentBasedUrls?: boolean;
23
- readonly providerOptions?: OpenAIProviderOptionsInput;
24
23
  };
25
24
  declare const responsesRoute: Route<{
26
25
  readonly input: readonly ({
@@ -1,7 +1,7 @@
1
1
  import { Headers } from "effect/unstable/http";
2
2
  import { Auth } from "../route/auth.js";
3
3
  import {} from "../route/auth-options.js";
4
- import { ProviderID } from "../schema/index.js";
4
+ import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
5
5
  import * as OpenAIChat from "../protocols/openai-chat.js";
6
6
  import * as OpenAIResponses from "../protocols/openai-responses.js";
7
7
  import { ProviderShared } from "../protocols/shared.js";
@@ -94,21 +94,21 @@ export const provider = {
94
94
  id,
95
95
  configure,
96
96
  };
97
- const config = (settings) => {
97
+ const config = ({ apiKey, apiVersion, baseURL, body, headers, queryParams, resourceName, useDeploymentBasedUrls, ...providerOptions }) => {
98
98
  const common = {
99
- apiKey: settings.apiKey,
100
- apiVersion: settings.apiVersion,
101
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
102
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
103
- providerOptions: settings.providerOptions,
104
- queryParams: settings.queryParams === undefined ? undefined : { ...settings.queryParams },
105
- useDeploymentBasedUrls: settings.useDeploymentBasedUrls,
99
+ apiKey,
100
+ apiVersion,
101
+ headers: headers === undefined ? undefined : { ...headers },
102
+ http: body === undefined ? undefined : { body: { ...body } },
103
+ providerOptions,
104
+ queryParams: queryParams === undefined ? undefined : { ...queryParams },
105
+ useDeploymentBasedUrls,
106
106
  };
107
- if (settings.baseURL !== undefined)
108
- return { ...common, baseURL: settings.baseURL };
109
- if (settings.resourceName !== undefined)
110
- return { ...common, resourceName: settings.resourceName };
111
- throw new Error("Azure requires resourceName or baseURL");
107
+ if (baseURL !== undefined)
108
+ return { ...common, baseURL };
109
+ if (resourceName !== undefined)
110
+ return { ...common, resourceName };
111
+ throw new ProviderConfigurationError({ provider: id, message: "Azure requires resourceName or baseURL" });
112
112
  };
113
113
  export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
114
114
  export const chatModel = (modelID, settings) => configure(config(settings)).chat(modelID);
@@ -8,11 +8,10 @@ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> &
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
- export interface Settings extends ProviderPackage.Settings {
11
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
12
12
  readonly apiKey?: string;
13
13
  readonly baseURL?: string;
14
- readonly providerOptions?: OpenAIProviderOptionsInput;
15
- }
14
+ };
16
15
  export declare const route: Route<{
17
16
  readonly model: string;
18
17
  readonly messages: readonly ({
@@ -28,11 +28,11 @@ export const configure = (input = {}) => {
28
28
  };
29
29
  };
30
30
  export const provider = configure();
31
- export const model = (modelID, settings) => configure({
32
- apiKey: settings.apiKey,
33
- baseURL: settings.baseURL,
34
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
35
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
36
- providerOptions: settings.providerOptions,
31
+ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
32
+ apiKey,
33
+ baseURL,
34
+ headers: headers === undefined ? undefined : { ...headers },
35
+ http: body === undefined ? undefined : { body: { ...body } },
36
+ providerOptions,
37
37
  }).model(modelID);
38
38
  export * as Baseten from "./baseten.js";
@@ -8,11 +8,10 @@ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> &
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
- export interface Settings extends ProviderPackage.Settings {
11
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
12
12
  readonly apiKey?: string;
13
13
  readonly baseURL?: string;
14
- readonly providerOptions?: OpenAIProviderOptionsInput;
15
- }
14
+ };
16
15
  export declare const route: Route<{
17
16
  readonly model: string;
18
17
  readonly messages: readonly ({
@@ -31,10 +31,10 @@ export const configure = (input = {}) => {
31
31
  };
32
32
  };
33
33
  export const provider = configure();
34
- export const model = (modelID, settings) => configure({
35
- apiKey: settings.apiKey,
36
- baseURL: settings.baseURL,
37
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
38
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
39
- providerOptions: settings.providerOptions,
34
+ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
35
+ apiKey,
36
+ baseURL,
37
+ headers: headers === undefined ? undefined : { ...headers },
38
+ http: body === undefined ? undefined : { body: { ...body } },
39
+ providerOptions,
40
40
  }).model(modelID);
@@ -17,10 +17,9 @@ export type LanguageModelOptions = GatewayURL & Omit<RouteDefaultsInput, "provid
17
17
  readonly gatewayApiKey?: string | Redacted.Redacted | Config.Config<string | Redacted.Redacted>;
18
18
  readonly providerOptions?: OpenAIProviderOptionsInput;
19
19
  };
20
- export type Settings = ProviderPackage.Settings & GatewayURL & {
20
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & GatewayURL & {
21
21
  readonly apiKey?: string;
22
22
  readonly gatewayApiKey?: string;
23
- readonly providerOptions?: OpenAIProviderOptionsInput;
24
23
  };
25
24
  export declare const baseURL: (input: GatewayURL) => string;
26
25
  export declare const route: Route<{
@@ -2,14 +2,17 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
2
2
  import { Auth } from "../route/auth.js";
3
3
  import { Route } from "../route/client.js";
4
4
  import { Endpoint } from "../route/endpoint.js";
5
- import { ProviderID } from "../schema/index.js";
5
+ import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
6
6
  export const id = ProviderID.make("cloudflare-ai-gateway");
7
7
  export const authEnvVars = ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKEN"];
8
8
  export const baseURL = (input) => {
9
9
  if (input.baseURL)
10
10
  return input.baseURL;
11
11
  if (!input.accountId)
12
- throw new Error("CloudflareAIGateway.configure requires accountId unless baseURL is supplied");
12
+ throw new ProviderConfigurationError({
13
+ provider: id,
14
+ message: "CloudflareAIGateway.configure requires accountId unless baseURL is supplied",
15
+ });
13
16
  return `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(input.accountId)}/${encodeURIComponent(input.gatewayId?.trim() || "default")}/compat`;
14
17
  };
15
18
  const auth = (input) => {
@@ -48,12 +51,15 @@ export const configure = (input) => {
48
51
  };
49
52
  };
50
53
  export const provider = { id, configure };
51
- export const model = (modelID, settings) => configure({
52
- apiKey: settings.apiKey,
53
- gatewayApiKey: settings.gatewayApiKey,
54
- baseURL: baseURL(settings),
55
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
56
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
57
- providerOptions: settings.providerOptions,
58
- }).model(modelID);
54
+ export const model = (modelID, settings) => {
55
+ const { accountId: _, apiKey, baseURL: _url, body, gatewayApiKey, gatewayId: _id, headers, ...providerOptions } = settings;
56
+ return configure({
57
+ apiKey,
58
+ gatewayApiKey,
59
+ baseURL: baseURL(settings),
60
+ headers: headers === undefined ? undefined : { ...headers },
61
+ http: body === undefined ? undefined : { body: { ...body } },
62
+ providerOptions,
63
+ }).model(modelID);
64
+ };
59
65
  export * as CloudflareAIGateway from "./cloudflare-ai-gateway.js";
@@ -12,9 +12,8 @@ type WorkersAIURL = AtLeastOne<{
12
12
  export type LanguageModelOptions = WorkersAIURL & Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
13
13
  readonly providerOptions?: OpenAIProviderOptionsInput;
14
14
  };
15
- export type Settings = ProviderPackage.Settings & WorkersAIURL & {
15
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & WorkersAIURL & {
16
16
  readonly apiKey?: string;
17
- readonly providerOptions?: OpenAIProviderOptionsInput;
18
17
  };
19
18
  export declare const baseURL: (input: WorkersAIURL) => string;
20
19
  export declare const route: Route<{
@@ -2,14 +2,17 @@ import { OpenAIChat } from "../protocols/openai-chat.js";
2
2
  import { AuthOptions } from "../route/auth-options.js";
3
3
  import { Route } from "../route/client.js";
4
4
  import { Endpoint } from "../route/endpoint.js";
5
- import { ProviderID } from "../schema/index.js";
5
+ import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
6
6
  export const id = ProviderID.make("cloudflare-workers-ai");
7
7
  export const authEnvVars = ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN"];
8
8
  export const baseURL = (input) => {
9
9
  if (input.baseURL)
10
10
  return input.baseURL;
11
11
  if (!input.accountId)
12
- throw new Error("CloudflareWorkersAI.configure requires accountId unless baseURL is supplied");
12
+ throw new ProviderConfigurationError({
13
+ provider: id,
14
+ message: "CloudflareWorkersAI.configure requires accountId unless baseURL is supplied",
15
+ });
13
16
  return `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(input.accountId)}/ai/v1`;
14
17
  };
15
18
  export const route = Route.make({
@@ -35,11 +38,14 @@ export const configure = (input) => {
35
38
  };
36
39
  };
37
40
  export const provider = { id, configure };
38
- export const model = (modelID, settings) => configure({
39
- apiKey: settings.apiKey,
40
- baseURL: baseURL(settings),
41
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
42
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
43
- providerOptions: settings.providerOptions,
44
- }).model(modelID);
41
+ export const model = (modelID, settings) => {
42
+ const { accountId: _, apiKey, baseURL: _url, body, headers, ...providerOptions } = settings;
43
+ return configure({
44
+ apiKey,
45
+ baseURL: baseURL(settings),
46
+ headers: headers === undefined ? undefined : { ...headers },
47
+ http: body === undefined ? undefined : { body: { ...body } },
48
+ providerOptions,
49
+ }).model(modelID);
50
+ };
45
51
  export * as CloudflareWorkersAI from "./cloudflare-workers-ai.js";
@@ -8,11 +8,10 @@ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> &
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
- export interface Settings extends ProviderPackage.Settings {
11
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
12
12
  readonly apiKey?: string;
13
13
  readonly baseURL?: string;
14
- readonly providerOptions?: OpenAIProviderOptionsInput;
15
- }
14
+ };
16
15
  export declare const route: Route<{
17
16
  readonly model: string;
18
17
  readonly messages: readonly ({
@@ -34,10 +34,10 @@ export const configure = (input = {}) => {
34
34
  };
35
35
  };
36
36
  export const provider = configure();
37
- export const model = (modelID, settings) => configure({
38
- apiKey: settings.apiKey,
39
- baseURL: settings.baseURL,
40
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
41
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
42
- providerOptions: settings.providerOptions,
37
+ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
38
+ apiKey,
39
+ baseURL,
40
+ headers: headers === undefined ? undefined : { ...headers },
41
+ http: body === undefined ? undefined : { body: { ...body } },
42
+ providerOptions,
43
43
  }).model(modelID);
@@ -8,11 +8,10 @@ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> &
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
- export interface Settings extends ProviderPackage.Settings {
11
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
12
12
  readonly apiKey?: string;
13
13
  readonly baseURL?: string;
14
- readonly providerOptions?: OpenAIProviderOptionsInput;
15
- }
14
+ };
16
15
  export declare const route: Route<{
17
16
  readonly model: string;
18
17
  readonly messages: readonly ({
@@ -31,11 +31,11 @@ export const configure = (input = {}) => {
31
31
  };
32
32
  };
33
33
  export const provider = configure();
34
- export const model = (modelID, settings) => configure({
35
- apiKey: settings.apiKey,
36
- baseURL: settings.baseURL,
37
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
38
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
39
- providerOptions: settings.providerOptions,
34
+ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
35
+ apiKey,
36
+ baseURL,
37
+ headers: headers === undefined ? undefined : { ...headers },
38
+ http: body === undefined ? undefined : { body: { ...body } },
39
+ providerOptions,
40
40
  }).model(modelID);
41
41
  export * as DeepSeek from "./deepseek.js";
@@ -8,11 +8,10 @@ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> &
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
- export interface Settings extends ProviderPackage.Settings {
11
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
12
12
  readonly apiKey?: string;
13
13
  readonly baseURL?: string;
14
- readonly providerOptions?: OpenAIProviderOptionsInput;
15
- }
14
+ };
16
15
  export declare const route: Route<{
17
16
  readonly model: string;
18
17
  readonly messages: readonly ({
@@ -28,11 +28,11 @@ export const configure = (input = {}) => {
28
28
  };
29
29
  };
30
30
  export const provider = configure();
31
- export const model = (modelID, settings) => configure({
32
- apiKey: settings.apiKey,
33
- baseURL: settings.baseURL,
34
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
35
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
36
- providerOptions: settings.providerOptions,
31
+ export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions }) => configure({
32
+ apiKey,
33
+ baseURL,
34
+ headers: headers === undefined ? undefined : { ...headers },
35
+ http: body === undefined ? undefined : { body: { ...body } },
36
+ providerOptions,
37
37
  }).model(modelID);
38
38
  export * as Fireworks from "./fireworks.js";
@@ -10,14 +10,13 @@ export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & {
10
10
  readonly project?: string;
11
11
  readonly providerOptions?: OpenAIProviderOptionsInput;
12
12
  };
13
- export interface Settings extends ProviderPackage.Settings {
13
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
14
14
  readonly accessToken?: string;
15
15
  readonly apiKey?: never;
16
16
  readonly baseURL?: string;
17
17
  readonly location?: string;
18
18
  readonly project?: string;
19
- readonly providerOptions?: OpenAIProviderOptionsInput;
20
- }
19
+ };
21
20
  export declare const routes: Route<{
22
21
  readonly model: string;
23
22
  readonly messages: readonly ({
@@ -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 { ProviderID } from "../schema/index.js";
4
+ import { ProviderConfigurationError, 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({
@@ -15,7 +15,7 @@ const route = Route.make({
15
15
  export const routes = [route];
16
16
  const configuredRoute = (input) => {
17
17
  if ("apiKey" in input && input.apiKey !== undefined)
18
- throw new Error("Google Vertex Chat does not support API keys");
18
+ throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Chat does not support API keys" });
19
19
  const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
20
20
  const location = GoogleVertexShared.location(inputLocation, "global");
21
21
  const project = GoogleVertexShared.project(inputProject);
@@ -40,16 +40,16 @@ export const provider = {
40
40
  id,
41
41
  configure,
42
42
  };
43
- export const model = (modelID, settings) => {
44
- if (settings.apiKey !== undefined)
45
- throw new Error("Google Vertex Chat does not support API keys");
43
+ export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }) => {
44
+ if (apiKey !== undefined)
45
+ throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Chat does not support API keys" });
46
46
  return configure({
47
- accessToken: settings.accessToken,
48
- baseURL: settings.baseURL,
49
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
50
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
51
- location: settings.location,
52
- project: settings.project,
53
- providerOptions: settings.providerOptions,
47
+ accessToken,
48
+ baseURL,
49
+ headers: headers === undefined ? undefined : { ...headers },
50
+ http: body === undefined ? undefined : { body: { ...body } },
51
+ location,
52
+ project,
53
+ providerOptions,
54
54
  }).model(modelID);
55
55
  };
@@ -13,14 +13,13 @@ export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & {
13
13
  readonly project?: string;
14
14
  readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
15
15
  };
16
- export interface Settings extends ProviderPackage.Settings {
16
+ export type Settings = ProviderPackage.Settings & AnthropicMessages.ProviderOptionsInput & {
17
17
  readonly accessToken?: string;
18
18
  readonly apiKey?: never;
19
19
  readonly baseURL?: string;
20
20
  readonly location?: string;
21
21
  readonly project?: string;
22
- readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
23
- }
22
+ };
24
23
  export declare const routes: Route<{
25
24
  anthropic_version: "vertex-2023-10-16";
26
25
  metadata?: {
@@ -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 { ProviderID } from "../schema/index.js";
7
+ import { ProviderConfigurationError, 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";
@@ -35,7 +35,7 @@ const route = Route.make({
35
35
  export const routes = [route];
36
36
  const configuredRoute = (input) => {
37
37
  if ("apiKey" in input && input.apiKey !== undefined)
38
- throw new Error("Google Vertex Messages does not support API keys");
38
+ throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Messages does not support API keys" });
39
39
  const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
40
40
  const location = GoogleVertexShared.location(inputLocation, "global");
41
41
  const project = GoogleVertexShared.project(inputProject);
@@ -60,16 +60,16 @@ export const provider = {
60
60
  id,
61
61
  configure,
62
62
  };
63
- export const model = (modelID, settings) => {
64
- if (settings.apiKey !== undefined)
65
- throw new Error("Google Vertex Messages does not support API keys");
63
+ export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }) => {
64
+ if (apiKey !== undefined)
65
+ throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Messages does not support API keys" });
66
66
  return configure({
67
- accessToken: settings.accessToken,
68
- baseURL: settings.baseURL,
69
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
70
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
71
- location: settings.location,
72
- project: settings.project,
73
- providerOptions: settings.providerOptions,
67
+ accessToken,
68
+ baseURL,
69
+ headers: headers === undefined ? undefined : { ...headers },
70
+ http: body === undefined ? undefined : { body: { ...body } },
71
+ location,
72
+ project,
73
+ providerOptions,
74
74
  }).model(modelID);
75
75
  };
@@ -10,14 +10,13 @@ export type Config = RouteDefaultsInput & GoogleVertexShared.OAuthOptions & {
10
10
  readonly project?: string;
11
11
  readonly providerOptions?: OpenResponsesProviderOptionsInput;
12
12
  };
13
- export interface Settings extends ProviderPackage.Settings {
13
+ export type Settings = ProviderPackage.Settings & OpenResponsesProviderOptionsInput & {
14
14
  readonly accessToken?: string;
15
15
  readonly apiKey?: never;
16
16
  readonly baseURL?: string;
17
17
  readonly location?: string;
18
18
  readonly project?: string;
19
- readonly providerOptions?: OpenResponsesProviderOptionsInput;
20
- }
19
+ };
21
20
  export declare const routes: Route<{
22
21
  readonly input: readonly ({
23
22
  readonly [x: string]: unknown;
@@ -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 { ProviderID } from "../schema/index.js";
4
+ import { ProviderConfigurationError, 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({
@@ -16,7 +16,7 @@ const route = Route.make({
16
16
  export const routes = [route];
17
17
  const configuredRoute = (input) => {
18
18
  if ("apiKey" in input && input.apiKey !== undefined)
19
- throw new Error("Google Vertex Responses does not support API keys");
19
+ throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Responses does not support API keys" });
20
20
  const { accessToken: _accessToken, auth: _auth, baseURL, location: inputLocation, project: inputProject, ...rest } = input;
21
21
  const location = GoogleVertexShared.location(inputLocation, "global");
22
22
  const project = GoogleVertexShared.project(inputProject);
@@ -41,16 +41,16 @@ export const provider = {
41
41
  id,
42
42
  configure,
43
43
  };
44
- export const model = (modelID, settings) => {
45
- if (settings.apiKey !== undefined)
46
- throw new Error("Google Vertex Responses does not support API keys");
44
+ export const model = (modelID, { accessToken, apiKey, baseURL, body, headers, location, project, ...providerOptions }) => {
45
+ if (apiKey !== undefined)
46
+ throw new ProviderConfigurationError({ provider: id, message: "Google Vertex Responses does not support API keys" });
47
47
  return configure({
48
- accessToken: settings.accessToken,
49
- baseURL: settings.baseURL,
50
- headers: settings.headers === undefined ? undefined : { ...settings.headers },
51
- http: settings.body === undefined ? undefined : { body: { ...settings.body } },
52
- location: settings.location,
53
- project: settings.project,
54
- providerOptions: settings.providerOptions,
48
+ accessToken,
49
+ baseURL,
50
+ headers: headers === undefined ? undefined : { ...headers },
51
+ http: body === undefined ? undefined : { body: { ...body } },
52
+ location,
53
+ project,
54
+ providerOptions,
55
55
  }).model(modelID);
56
56
  };