@opencode/ai 0.0.0-dev-794 → 0.0.0-dev-821

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 (79) hide show
  1. package/dist/protocols/alibaba-chat.d.ts +5 -1
  2. package/dist/protocols/alibaba-chat.js +1 -1
  3. package/dist/protocols/anthropic-messages.js +6 -4
  4. package/dist/protocols/openai-chat.js +4 -4
  5. package/dist/protocols/openai-compatible-responses.js +1 -1
  6. package/dist/protocols/openai-responses.js +2 -2
  7. package/dist/protocols/shared.js +1 -1
  8. package/dist/protocols/venice-chat.d.ts +3 -1
  9. package/dist/protocols/venice-chat.js +2 -2
  10. package/dist/protocols/zai-chat.d.ts +5 -1
  11. package/dist/protocols/zai-chat.js +1 -1
  12. package/dist/providers/alibaba.d.ts +3 -3
  13. package/dist/providers/alibaba.js +3 -1
  14. package/dist/providers/amazon-bedrock-mantle.d.ts +3 -3
  15. package/dist/providers/amazon-bedrock-mantle.js +2 -2
  16. package/dist/providers/amazon-bedrock.d.ts +6 -7
  17. package/dist/providers/anthropic-compatible.d.ts +5 -6
  18. package/dist/providers/anthropic.d.ts +6 -7
  19. package/dist/providers/azure.d.ts +3 -3
  20. package/dist/providers/azure.js +2 -2
  21. package/dist/providers/baseten.d.ts +3 -3
  22. package/dist/providers/cerebras.d.ts +3 -3
  23. package/dist/providers/cerebras.js +1 -1
  24. package/dist/providers/cloudflare-ai-gateway.d.ts +12 -13
  25. package/dist/providers/cloudflare-workers-ai.d.ts +3 -3
  26. package/dist/providers/cohere.d.ts +3 -3
  27. package/dist/providers/cohere.js +1 -1
  28. package/dist/providers/deepinfra.d.ts +3 -3
  29. package/dist/providers/deepinfra.js +1 -1
  30. package/dist/providers/deepseek.d.ts +3 -3
  31. package/dist/providers/digitalocean.d.ts +3 -3
  32. package/dist/providers/digitalocean.js +2 -4
  33. package/dist/providers/fireworks.d.ts +3 -3
  34. package/dist/providers/fireworks.js +1 -1
  35. package/dist/providers/google-vertex-chat.d.ts +3 -3
  36. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  37. package/dist/providers/google-vertex-messages.d.ts +3 -3
  38. package/dist/providers/google-vertex-mistral.d.ts +3 -3
  39. package/dist/providers/google-vertex-responses.d.ts +3 -3
  40. package/dist/providers/google-vertex-responses.js +1 -1
  41. package/dist/providers/google-vertex-shared.d.ts +3 -2
  42. package/dist/providers/google-vertex.d.ts +3 -3
  43. package/dist/providers/google.d.ts +13 -14
  44. package/dist/providers/groq.d.ts +3 -3
  45. package/dist/providers/groq.js +1 -1
  46. package/dist/providers/meta.d.ts +3 -3
  47. package/dist/providers/meta.js +4 -3
  48. package/dist/providers/minimax.d.ts +3 -3
  49. package/dist/providers/minimax.js +2 -2
  50. package/dist/providers/mistral.d.ts +8 -9
  51. package/dist/providers/moonshot.d.ts +3 -3
  52. package/dist/providers/moonshot.js +1 -2
  53. package/dist/providers/openai-compatible-responses.d.ts +5 -6
  54. package/dist/providers/openai-compatible.d.ts +5 -6
  55. package/dist/providers/openai-compatible.js +1 -1
  56. package/dist/providers/openai.d.ts +3 -3
  57. package/dist/providers/openai.js +2 -2
  58. package/dist/providers/openrouter.d.ts +3 -3
  59. package/dist/providers/openrouter.js +3 -3
  60. package/dist/providers/settings.d.ts +1 -1
  61. package/dist/providers/togetherai.d.ts +3 -3
  62. package/dist/providers/togetherai.js +2 -1
  63. package/dist/providers/venice.d.ts +3 -3
  64. package/dist/providers/venice.js +6 -2
  65. package/dist/providers/vercel-ai-gateway.d.ts +3 -3
  66. package/dist/providers/vercel-ai-gateway.js +3 -3
  67. package/dist/providers/xai.d.ts +3 -3
  68. package/dist/providers/xai.js +1 -1
  69. package/dist/providers/zai-coding-plan.d.ts +3 -3
  70. package/dist/providers/zai-coding-plan.js +5 -1
  71. package/dist/providers/zai.d.ts +3 -3
  72. package/dist/providers/zai.js +5 -1
  73. package/dist/public.d.ts +1 -1
  74. package/dist/route/client.d.ts +8 -9
  75. package/dist/route/client.js +10 -18
  76. package/dist/route/index.d.ts +1 -1
  77. package/dist/schema/options.d.ts +70 -11
  78. package/dist/schema/options.js +18 -14
  79. package/package.json +3 -3
@@ -1,10 +1,9 @@
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<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
6
+ export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
8
7
  readonly provider?: string;
9
8
  readonly baseURL: string;
10
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
@@ -14,7 +13,7 @@ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
14
13
  readonly baseURL: string;
15
14
  readonly provider?: string;
16
15
  };
17
- export declare const routes: import("../route/client.js").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/client.js").CompactionOperations | undefined>[];
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/client.js").CompactionOperations | undefined>;
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,4 +1,4 @@
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";
@@ -1,7 +1,7 @@
1
1
  import { type ProviderAuthOption } from "../route/auth-options.js";
2
- import type { Route, RouteDefaultsInput, CompactionOperations } from "../route/client.js";
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 = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
420
+ export type Config = RequestOptions & ProviderAuthOption<"optional"> & {
421
421
  readonly baseURL?: string;
422
422
  readonly queryParams?: Record<string, string>;
423
423
  readonly providerOptions?: OpenAIProviderOptionsInput;
@@ -1,6 +1,6 @@
1
1
  import { AuthOptions } from "../route/auth-options.js";
2
2
  import { MediaRoute } from "../route/media.js";
3
- import { ProviderID, ToolDefinition } from "../schema/index.js";
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,7 +44,7 @@ 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
- compatibility: { supportsPromptCacheKey: true },
47
+ capabilities: { promptCacheKey: true },
48
48
  });
49
49
  const deployment = MediaRoute.deployment(input, auth(input));
50
50
  const media = {
@@ -1,8 +1,8 @@
1
1
  import { Schema } from "effect";
2
- import { Route, type RouteDefaultsInput } from "../route/client.js";
2
+ import { Route } from "../route/client.js";
3
3
  import { Protocol } from "../route/protocol.js";
4
4
  import type { ProviderAuthOption } from "../route/auth-options.js";
5
- import { type ModelID, type OpenString, type ProviderOptions } from "../schema/index.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,7 +82,7 @@ export interface OpenRouterDecisionOptions {
82
82
  readonly trace?: Readonly<Record<string, unknown>>;
83
83
  readonly user?: string;
84
84
  }
85
- export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
85
+ export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
86
86
  readonly baseURL?: string;
87
87
  readonly providerOptions?: OpenRouterProviderOptionsInput | OpenRouterResponsesProviderOptionsInput;
88
88
  };
@@ -2,7 +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 { ProviderID } from "../schema/index.js";
5
+ import { ProviderID, } from "../schema/index.js";
6
6
  import { SystemOne } from "../protocols/system-one.js";
7
7
  import { OpenAIImages } from "../protocols/openai-images.js";
8
8
  import { MediaRoute } from "../route/media.js";
@@ -130,7 +130,7 @@ const responsesRoute = Route.make({
130
130
  protocol: responsesProtocol,
131
131
  endpoint: Endpoint.path("/responses", { baseURL }),
132
132
  transport: HttpTransport.sseJson.with(),
133
- defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
133
+ options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
134
134
  });
135
135
  export const routes = [route, responsesRoute];
136
136
  export const configure = (input = {}) => {
@@ -159,7 +159,7 @@ export const configure = (input = {}) => {
159
159
  compatibility: { mediaInput: "state" },
160
160
  providerOptions,
161
161
  });
162
- const chat = (modelID) => chatRoute.model({ id: modelID, compatibility: { supportsPromptCacheKey: true } });
162
+ const chat = (modelID) => chatRoute.model({ id: modelID, capabilities: { promptCacheKey: true } });
163
163
  return {
164
164
  id,
165
165
  model: chat,
@@ -22,7 +22,7 @@ type BearerInput = ProviderAuthOption<"optional"> & {
22
22
  readonly baseURL?: string;
23
23
  };
24
24
  /**
25
- * Turns provider config into route defaults with `Authorization: Bearer` auth. The endpoint falls back to
25
+ * Turns provider config into route options with `Authorization: Bearer` auth. The endpoint falls back to
26
26
  * `baseURL` when given, otherwise it is left to the route.
27
27
  */
28
28
  export declare function bearerRouteDefaults<Input extends BearerInput>(input: Input, envVar: string | ReadonlyArray<string>, baseURL: string): Omit<Input, "apiKey" | "auth" | "baseURL"> & {
@@ -1,10 +1,10 @@
1
1
  import type { ProviderPackage } from "../provider-package.js";
2
2
  import type { ProviderAuthOption } from "../route/auth-options.js";
3
- import { Route, type RouteDefaultsInput } from "../route/client.js";
4
- import { type ModelID } from "../schema/index.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<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
7
+ export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
@@ -20,7 +20,8 @@ export const configure = (input = {}) => {
20
20
  id,
21
21
  model: (modelID) => configured.model({
22
22
  id: modelID,
23
- compatibility: { maxTokensField: "max_tokens", supportsStrictMode: false },
23
+ compatibility: { maxTokensField: "max_tokens" },
24
+ capabilities: { tools: { strict: false } },
24
25
  }),
25
26
  configure,
26
27
  };
@@ -1,12 +1,12 @@
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, type RouteDefaultsInput } from "../route/client.js";
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<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
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;
@@ -22,7 +22,7 @@ const responsesRoute = Route.make({
22
22
  protocol: OpenResponses.protocol,
23
23
  endpoint: Endpoint.path("/responses", { baseURL }),
24
24
  transport: OpenResponses.httpTransport,
25
- defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
25
+ options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
26
26
  });
27
27
  export const routes = [route, responsesRoute];
28
28
  export const configure = (input = {}) => {
@@ -32,7 +32,11 @@ export const configure = (input = {}) => {
32
32
  endpoint: { baseURL: endpoint ?? baseURL, query: queryParams },
33
33
  auth: AuthOptions.bearer(input, "VENICE_API_KEY"),
34
34
  };
35
- const chat = (modelID) => route.with(options).model({ id: modelID, compatibility: VeniceChat.compatibility });
35
+ const chat = (modelID) => route.with(options).model({
36
+ id: modelID,
37
+ compatibility: VeniceChat.compatibility,
38
+ capabilities: VeniceChat.capabilities,
39
+ });
36
40
  const responses = (modelID) => responsesRoute.with(options).model({ id: modelID });
37
41
  return { id, model: chat, chat, responses, configure };
38
42
  };
@@ -1,8 +1,8 @@
1
1
  import { AnthropicMessages } from "../protocols/anthropic-messages.js";
2
2
  import type { ProviderPackage } from "../provider-package.js";
3
3
  import type { ProviderAuthOption } from "../route/auth-options.js";
4
- import { Route, type RouteDefaultsInput } from "../route/client.js";
5
- import { ModelID, type ProviderOptions } from "../schema/index.js";
4
+ import { Route } from "../route/client.js";
5
+ import { ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
6
6
  import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
7
7
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
8
8
  export interface GatewayOptions {
@@ -63,7 +63,7 @@ export type ProviderOptionsInput = OpenResponsesProviderOptionsInput & Omit<Anth
63
63
  /** Responses API count of stable input items to anchor for caching, sent as top-level `cache_anchor_items`. */
64
64
  readonly cacheAnchorItems?: number;
65
65
  };
66
- export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
66
+ export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
67
67
  readonly baseURL?: string;
68
68
  readonly providerOptions?: ProviderOptionsInput;
69
69
  };
@@ -82,7 +82,7 @@ const route = (input) => Route.make({
82
82
  endpoint: Endpoint.path(input.path, { baseURL }),
83
83
  framing: input.framing,
84
84
  headers: ({ request }) => request.promptCacheKey ? { "x-session-affinity": request.promptCacheKey } : {},
85
- defaults: input.defaults,
85
+ options: input.options,
86
86
  });
87
87
  const messagesRoute = route({
88
88
  id: "vercel-ai-gateway-messages",
@@ -90,7 +90,7 @@ const messagesRoute = route({
90
90
  api: "messages",
91
91
  path: "/messages",
92
92
  framing: AnthropicMessages.framing,
93
- defaults: { headers: { "anthropic-version": "2023-06-01" } },
93
+ options: { headers: { "anthropic-version": "2023-06-01" } },
94
94
  });
95
95
  const responsesRoute = route({
96
96
  id: "vercel-ai-gateway-responses",
@@ -98,7 +98,7 @@ const responsesRoute = route({
98
98
  api: "responses",
99
99
  path: "/responses",
100
100
  framing: Framing.sse,
101
- defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
101
+ options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
102
102
  });
103
103
  const chatRoute = route({
104
104
  id: "vercel-ai-gateway-chat",
@@ -1,6 +1,6 @@
1
1
  import { type ProviderAuthOption } from "../route/auth-options.js";
2
- import { Route, type RouteDefaultsInput } from "../route/client.js";
3
- import { type ModelID, type ProviderOptions } from "../schema/index.js";
2
+ import { Route } from "../route/client.js";
3
+ import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
4
4
  import { XAIResponses } from "../protocols/xai-responses.js";
5
5
  import type { OpenAIOptionsInput } from "./openai-options.js";
6
6
  import type { ProviderPackage } from "../provider-package.js";
@@ -8,7 +8,7 @@ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
8
8
  export type XAIProviderOptionsInput = OpenAIOptionsInput & XAIResponses.OptionsInput & {
9
9
  readonly contextManagement?: never;
10
10
  };
11
- export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
11
+ export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
12
12
  readonly baseURL?: string;
13
13
  readonly providerOptions?: XAIProviderOptionsInput;
14
14
  };
@@ -28,7 +28,7 @@ const responsesRoute = Route.make({
28
28
  // rejects `instructions` next to `previous_response_id` and keeps the instructions of the response it continues.
29
29
  continuation: ({ instructions: _instructions, ...request }) => (request.store === false ? undefined : request),
30
30
  }),
31
- defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
31
+ options: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
32
32
  });
33
33
  const chatRoute = Route.make({
34
34
  id: "xai-chat",
@@ -2,15 +2,15 @@ import type { ProviderPackage } from "../provider-package.js";
2
2
  import { ZAIChat } from "../protocols/zai-chat.js";
3
3
  import { ZAIMessages } from "../protocols/zai-messages.js";
4
4
  import type { ProviderAuthOption } from "../route/auth-options.js";
5
- import { Route, type RouteDefaultsInput } from "../route/client.js";
6
- import { type ModelID } from "../schema/index.js";
5
+ import { Route } from "../route/client.js";
6
+ import { type ModelID, type RequestOptions } from "../schema/index.js";
7
7
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
8
8
  export type ChatOptionsInput = ZAIChat.OptionsInput;
9
9
  export type MessagesOptionsInput = ZAIMessages.OptionsInput;
10
10
  export type ResponsesOptionsInput = {
11
11
  readonly reasoningEffort?: ZAIChat.ReasoningEffort;
12
12
  };
13
- export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
13
+ export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
14
14
  /** Overrides the selected API's complete base URL. */
15
15
  readonly baseURL?: string;
16
16
  readonly providerOptions?: ChatOptionsInput | MessagesOptionsInput | ResponsesOptionsInput;
@@ -37,7 +37,11 @@ const responsesRoute = Route.make({
37
37
  export const routes = [chatRoute, messagesRoute, responsesRoute];
38
38
  export const configure = (input = {}) => {
39
39
  const defaults = bearerRouteDefaults(input, "ZAI_API_KEY");
40
- const chat = (modelID) => chatRoute.with(defaults).model({ id: modelID, compatibility: ZAIChat.compatibility });
40
+ const chat = (modelID) => chatRoute.with(defaults).model({
41
+ id: modelID,
42
+ compatibility: ZAIChat.compatibility,
43
+ capabilities: ZAIChat.capabilities,
44
+ });
41
45
  const messages = (modelID) => messagesRoute
42
46
  .with(defaults)
43
47
  .model({ id: modelID, compatibility: { requireSignature: false } });
@@ -1,11 +1,11 @@
1
1
  import type { ProviderPackage } from "../provider-package.js";
2
2
  import { ZAIChat } from "../protocols/zai-chat.js";
3
3
  import type { ProviderAuthOption } from "../route/auth-options.js";
4
- import { Route, type RouteDefaultsInput } from "../route/client.js";
5
- import { type ModelID, type ProviderOptions } from "../schema/index.js";
4
+ import { Route } from "../route/client.js";
5
+ import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
6
6
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
7
  export type ChatOptionsInput = ZAIChat.OptionsInput;
8
- export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
8
+ export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
9
9
  readonly baseURL?: string;
10
10
  readonly providerOptions?: ChatOptionsInput;
11
11
  };
@@ -18,7 +18,11 @@ const chatRoute = Route.make({
18
18
  export const routes = [chatRoute];
19
19
  export const configure = (input = {}) => {
20
20
  const defaults = bearerRouteDefaults(input, "ZAI_API_KEY");
21
- const chat = (modelID) => chatRoute.with(defaults).model({ id: modelID, compatibility: ZAIChat.compatibility });
21
+ const chat = (modelID) => chatRoute.with(defaults).model({
22
+ id: modelID,
23
+ compatibility: ZAIChat.compatibility,
24
+ capabilities: ZAIChat.capabilities,
25
+ });
22
26
  const media = MediaRoute.deployment(input, defaults.auth);
23
27
  const image = (modelID, providerOptions) => ZAIImages.model({ ...media, id: modelID, providerOptions });
24
28
  return {
package/dist/public.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./provider-error.js";
2
2
  export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, GENERATION_KEYS, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, SystemMessage, UserMessage, AssistantMessage, ToolMessage, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, FinishReasonDetails, StepFinish, Finish, MediaEvent, RawEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
3
- export type { BaseRequest, ContentPartInput, GenerationOptionsFields, HttpOptions, LanguageModelDefaults, LanguageModelInput, LanguageModelProviderOptions, LLMRequest, MediaPartInput, RequestTimeout, TimeoutConfig, ToolDefinitionInput, ToolNamespaceInput, ToolNamespaceEntryInput, ToolEntryInput, TransportOptions, UsageInput, } from "./schema/index.js";
3
+ export type { BaseRequest, ContentPartInput, GenerationOptionsFields, HttpOptions, RequestOptions, LanguageModelInput, LanguageModelProviderOptions, LLMRequest, MediaPartInput, RequestTimeout, TimeoutConfig, ToolDefinitionInput, ToolNamespaceInput, ToolNamespaceEntryInput, ToolEntryInput, TransportOptions, UsageInput, } from "./schema/index.js";
4
4
  export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageResponse } from "./image.js";
5
5
  export type { ImageModelOptions, ImageOptions, ImageRequest, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
6
6
  export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
@@ -8,7 +8,7 @@ import type { HttpMiddleware, Transport, TransportRuntime, WebSocketChannelExecu
8
8
  import type { Protocol } from "./protocol.js";
9
9
  import type { LanguageModelSanitizerCompatibility, ProtocolID, ProviderOptions } from "../schema/index.js";
10
10
  import type { LLMRequestInput } from "../llm.js";
11
- import { AIError, CompactionResponse, CompactionCheckpointResponse, LLMResponse, LanguageModel, LLMEvent, ProviderID, type LLMRequest, type LanguageModelDefaults } from "../schema/index.js";
11
+ import { AIError, CompactionResponse, CompactionCheckpointResponse, LLMResponse, LanguageModel, LLMEvent, ProviderID, type LLMRequest, type RequestOptions } from "../schema/index.js";
12
12
  export interface RouteBody<Body> {
13
13
  /** Schema for the validated provider-native body sent as the JSON request. */
14
14
  readonly schema: Schema.Codec<Body, unknown>;
@@ -29,7 +29,8 @@ export interface Route<Body, Prepared = unknown, Compact extends CompactionOpera
29
29
  readonly request: LLMRequest;
30
30
  }) => Record<string, string>;
31
31
  readonly transport: Transport<Body, Prepared, unknown>;
32
- readonly defaults: RouteDefaults;
32
+ /** Options every model built on this route starts from. */
33
+ readonly options?: RequestOptions;
33
34
  readonly body: RouteBody<Body>;
34
35
  readonly supportsEffortUpdates?: (request: LLMRequest) => boolean;
35
36
  readonly sanitizer?: LanguageModelSanitizerCompatibility;
@@ -49,9 +50,7 @@ export interface Route<Body, Prepared = unknown, Compact extends CompactionOpera
49
50
  export type AnyRoute<Compact extends CompactionOperations | undefined = CompactionOperations | undefined> = Route<any, any, Compact>;
50
51
  export type RouteLanguageModelInput = Omit<LanguageModel.Input, "provider" | "route">;
51
52
  export type RouteRoutedLanguageModelInput = Omit<LanguageModel.Input, "route">;
52
- export type RouteDefaults = LanguageModelDefaults;
53
- export type RouteDefaultsInput = LanguageModelDefaults;
54
- export interface RoutePatch<Body, Prepared> extends RouteDefaultsInput {
53
+ export interface RoutePatch<Body, Prepared> extends RequestOptions {
55
54
  readonly compact?: CompactionOperations;
56
55
  readonly id?: string;
57
56
  readonly provider?: string | ProviderID;
@@ -158,8 +157,8 @@ export interface MakeInput<Body, Frame, Event, State> {
158
157
  readonly headers?: (input: {
159
158
  readonly request: LLMRequest;
160
159
  }) => Record<string, string>;
161
- /** Route/request defaults used when compiling requests for this route. */
162
- readonly defaults?: RouteDefaultsInput;
160
+ /** Options every model built on this route starts from. */
161
+ readonly options?: RequestOptions;
163
162
  }
164
163
  export interface MakeTransportInput<Body, Prepared, Frame, Event, State> {
165
164
  readonly compact?: CompactionOperations;
@@ -181,8 +180,8 @@ export interface MakeTransportInput<Body, Prepared, Frame, Event, State> {
181
180
  }) => Record<string, string>;
182
181
  /** Runnable transport route. */
183
182
  readonly transport: Transport<Body, Prepared, Frame>;
184
- /** Route/request defaults used when compiling requests for this route. */
185
- readonly defaults?: RouteDefaultsInput;
183
+ /** Options every model built on this route starts from. */
184
+ readonly options?: RequestOptions;
186
185
  }
187
186
  export declare function make<Body, Prepared, Frame, Event, State, Compact extends CompactionOperations>(input: MakeTransportInput<Body, Prepared, Frame, Event, State> & {
188
187
  readonly compact: Compact;
@@ -10,7 +10,7 @@ import { normalizeToolHistory } from "../tool-history.js";
10
10
  import { sanitizeSurrogates } from "../utils/sanitize.js";
11
11
  import * as ProviderShared from "../protocols/shared.js";
12
12
  import { ToolSchemaProjection } from "../protocols/utils/tool-schema.js";
13
- import { AIError, CompactionResponse, CompactionCheckpointResponse, AIErrorReason, LLMResponse, ResponseFold, LanguageModel, Message, LLMEvent, InvalidProviderOutputError, ProviderConfigurationError, ProviderID, ToolChoice, ToolEntry, mergeGeneration, mergeProviderOptions, mergeTransport, withPartial, } from "../schema/index.js";
13
+ import { AIError, CompactionResponse, CompactionCheckpointResponse, AIErrorReason, LLMResponse, ResponseFold, LanguageModel, Message, LLMEvent, InvalidProviderOutputError, ProviderConfigurationError, ProviderID, ToolChoice, ToolEntry, mergeGeneration, mergeRequestOptions, mergeProviderOptions, mergeTransport, withPartial, } from "../schema/index.js";
14
14
  const makeRouteLanguageModel = (route, mapped) => {
15
15
  const provider = route.provider ?? ("provider" in mapped ? mapped.provider : undefined);
16
16
  if (!provider)
@@ -26,13 +26,6 @@ const makeRouteLanguageModel = (route, mapped) => {
26
26
  route,
27
27
  });
28
28
  };
29
- const mergeRouteDefaults = (base, patch) => ({
30
- ...base,
31
- ...patch,
32
- ...mergeTransport(base, patch),
33
- ...mergeGeneration(base, patch),
34
- providerOptions: mergeProviderOptions(base?.providerOptions, patch.providerOptions),
35
- });
36
29
  export function canCompact(target, options) {
37
30
  const model = target instanceof LanguageModel ? target : target.model;
38
31
  if (options?.mechanism === "trigger")
@@ -57,13 +50,12 @@ export const Service = LLMClientService;
57
50
  const resolveRequestOptions = (request) => {
58
51
  const messages = normalizeToolHistory(request.messages);
59
52
  const normalized = messages === request.messages ? request : { ...request, messages };
60
- const routeDefaults = normalized.model.route.defaults;
61
- const modelDefaults = normalized.model.defaults;
53
+ const options = normalized.model.options;
62
54
  return {
63
55
  ...normalized,
64
- ...mergeGeneration(routeDefaults, modelDefaults, normalized),
65
- providerOptions: mergeProviderOptions(routeDefaults.providerOptions, modelDefaults?.providerOptions, normalized.providerOptions),
66
- ...mergeTransport(routeDefaults, modelDefaults, normalized),
56
+ ...mergeGeneration(options, normalized),
57
+ providerOptions: mergeProviderOptions(options?.providerOptions, normalized.providerOptions),
58
+ ...mergeTransport(options, normalized),
67
59
  };
68
60
  };
69
61
  const streamError = (route, message, cause) => {
@@ -113,12 +105,12 @@ function makeFromTransport(input) {
113
105
  auth: routeInput.auth ?? Auth.none,
114
106
  headers: routeInput.headers,
115
107
  transport: routeInput.transport,
116
- defaults: routeInput.defaults ?? {},
108
+ options: routeInput.options,
117
109
  body: protocol.body,
118
110
  supportsEffortUpdates: protocol.supportsEffortUpdates,
119
111
  sanitizer: protocol.sanitizer,
120
112
  with: (patch) => {
121
- const { compact, id, provider, providerMetadataKey, auth, transport, endpoint, ...defaults } = patch;
113
+ const { compact, id, provider, providerMetadataKey, auth, transport, endpoint, ...options } = patch;
122
114
  return build({
123
115
  ...routeInput,
124
116
  compact: "compact" in patch ? compact : routeInput.compact,
@@ -129,7 +121,7 @@ function makeFromTransport(input) {
129
121
  auth: auth ?? routeInput.auth,
130
122
  endpoint: endpoint ? Endpoint.merge(routeInput.endpoint, endpoint) : routeInput.endpoint,
131
123
  transport: transport ?? routeInput.transport,
132
- defaults: mergeRouteDefaults(route.defaults, defaults),
124
+ options: mergeRequestOptions(route.options, options),
133
125
  });
134
126
  },
135
127
  model: (input) => makeRouteLanguageModel(route, input),
@@ -185,7 +177,7 @@ function makeFromTransport(input) {
185
177
  };
186
178
  return route;
187
179
  };
188
- return build({ ...input, defaults: mergeRouteDefaults(undefined, input.defaults ?? {}) });
180
+ return build({ ...input, options: mergeRequestOptions(input.options) });
189
181
  }
190
182
  export function make(input) {
191
183
  if ("transport" in input)
@@ -201,7 +193,7 @@ export function make(input) {
201
193
  auth: input.auth,
202
194
  headers: input.headers,
203
195
  transport: HttpTransport.httpJson({ framing: input.framing }),
204
- defaults: input.defaults,
196
+ options: input.options,
205
197
  });
206
198
  }
207
199
  const prepareRequest = (request) => {
@@ -1,5 +1,5 @@
1
1
  export { Route, LLMClient } from "./client.js";
2
- export type { RouteLanguageModelInput, RouteRoutedLanguageModelInput, RouteDefaults, RouteDefaultsInput, AnyRoute, LLMClientService, StreamOptions, CompactMethod, CompactionOperations, CompactionRequest, CheckpointRequest, EndpointCompactOptions, TriggerCompactOptions, } from "./client.js";
2
+ export type { RouteLanguageModelInput, RouteRoutedLanguageModelInput, AnyRoute, LLMClientService, StreamOptions, CompactMethod, CompactionOperations, CompactionRequest, CheckpointRequest, EndpointCompactOptions, TriggerCompactOptions, } from "./client.js";
3
3
  export * from "./executor.js";
4
4
  export { Auth } from "./auth.js";
5
5
  export { AuthOptions } from "./auth-options.js";
@@ -74,10 +74,12 @@ export interface GenerationOptionsFields {
74
74
  export declare const GENERATION_KEYS: ReadonlySet<string>;
75
75
  /** Pick the generation knobs out of each item; later items win per knob. */
76
76
  export declare const mergeGeneration: (...items: ReadonlyArray<GenerationOptionsFields | undefined>) => GenerationOptionsFields;
77
- /** Request defaults a selected model applies under each request. */
78
- export interface LanguageModelDefaults extends TransportOptions, GenerationOptionsFields {
77
+ /** Request options a model applies under each request: the same keys as a request, and the request wins. */
78
+ export interface RequestOptions extends TransportOptions, GenerationOptionsFields {
79
79
  readonly providerOptions?: ProviderOptions;
80
80
  }
81
+ /** Merge model options; later items win per key. Empty results are `undefined`. */
82
+ export declare const mergeRequestOptions: (...items: ReadonlyArray<RequestOptions | undefined>) => RequestOptions | undefined;
81
83
  /** Provider-defined string enum: known values for autocomplete, any string accepted. */
82
84
  export type OpenString<Known extends string> = Known | (string & {});
83
85
  export declare const ReasoningEfforts: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
@@ -98,19 +100,12 @@ declare const LanguageModelCompatibility_base: Schema.Class<LanguageModelCompati
98
100
  readonly maxTokensField: Schema.optional<Schema.Literals<readonly ["max_completion_tokens", "max_tokens"]>>;
99
101
  readonly requireFinishReason: Schema.optional<Schema.Boolean>;
100
102
  readonly requireAssistantAfterTool: Schema.optional<Schema.Boolean>;
101
- readonly supportsStore: Schema.optional<Schema.Boolean>;
102
- /** Request usage in the stream with `stream_options.include_usage`. Defaults to true. */
103
- readonly streamUsage: Schema.optional<Schema.Boolean>;
104
- readonly supportsStrictMode: Schema.optional<Schema.Boolean>;
105
- readonly supportsPromptCacheKey: Schema.optional<Schema.Boolean>;
106
103
  /** Prompt-cache marker syntax the endpoint accepts. Overrides the route default; both send `cache_control`, and `alibaba` skips tool definitions. */
107
104
  readonly cacheFormat: Schema.optional<Schema.Literals<readonly ["anthropic", "alibaba"]>>;
108
105
  readonly zaiToolStream: Schema.optional<Schema.Boolean>;
109
106
  readonly requireSignature: Schema.optional<Schema.Boolean>;
110
107
  /** Supports Anthropic's thinking-prefix mismatch controls. Overrides model-ID detection. */
111
108
  readonly supportsThinkingBlockBinding: Schema.optional<Schema.Boolean>;
112
- /** Supports per-message effort updates. Overrides model-ID detection. */
113
- readonly supportsEffortUpdates: Schema.optional<Schema.Boolean>;
114
109
  }>, {}>;
115
110
  export declare class LanguageModelCompatibility extends LanguageModelCompatibility_base {
116
111
  }
@@ -119,12 +114,75 @@ export declare namespace LanguageModelCompatibility {
119
114
  /** Normalize model/upstream compatibility metadata without projecting requests. */
120
115
  const make: (input: Input) => LanguageModelCompatibility;
121
116
  }
117
+ /**
118
+ * What the model accepts on its API: models.dev v2 `capabilities` in camelCase, with the API's own overrides merged in.
119
+ * Unset fields keep the protocol default, which may still guess from the provider, base URL or model ID.
120
+ */
121
+ export interface Capabilities {
122
+ readonly tools?: {
123
+ readonly supported?: boolean;
124
+ /** Accepts `strict` on function tools. OpenAI Chat detects it from the provider when unset. */
125
+ readonly strict?: boolean;
126
+ readonly choice?: ReadonlyArray<"auto" | "none" | "required" | "tool">;
127
+ readonly search?: boolean;
128
+ /** Input formats accepted by custom (free-form) tools. */
129
+ readonly freeform?: ReadonlyArray<"text" | "lark" | "regex">;
130
+ /** Accepts a changed tool list mid-conversation. */
131
+ readonly updates?: boolean;
132
+ };
133
+ readonly reasoning?: {
134
+ readonly supported?: boolean;
135
+ readonly default?: {
136
+ readonly type: "toggle";
137
+ readonly value: boolean;
138
+ } | {
139
+ readonly type: "effort";
140
+ readonly value: ReasoningEffort;
141
+ } | {
142
+ readonly type: "budget";
143
+ readonly value: number;
144
+ };
145
+ readonly toggle?: boolean;
146
+ readonly effort?: ReadonlyArray<ReasoningEffort>;
147
+ readonly budget?: {
148
+ readonly min?: number;
149
+ readonly max?: number;
150
+ };
151
+ /** Accepts per-message effort updates. Detected from the model ID when unset. */
152
+ readonly updates?: boolean;
153
+ };
154
+ readonly cache?: false | {
155
+ readonly implicit?: true | {
156
+ readonly ttl?: ReadonlyArray<CacheTTL>;
157
+ readonly minTokens?: number;
158
+ };
159
+ readonly explicit?: true | {
160
+ readonly ttl?: ReadonlyArray<CacheTTL>;
161
+ readonly maxBreakpoints?: number;
162
+ readonly targets?: ReadonlyArray<"tools" | "system" | "messages">;
163
+ readonly minTokens?: number;
164
+ };
165
+ };
166
+ readonly structuredOutput?: boolean;
167
+ readonly temperature?: boolean;
168
+ readonly topP?: boolean;
169
+ readonly topK?: boolean;
170
+ /** Accepts mid-conversation system messages. Anthropic Messages detects it from the model ID when unset. */
171
+ readonly systemUpdates?: boolean;
172
+ /** Accepts `store`. OpenAI Chat detects it from the provider when unset. */
173
+ readonly store?: boolean;
174
+ /** Accepts `stream_options.include_usage`. OpenAI Chat defaults to true. */
175
+ readonly streamUsage?: boolean;
176
+ readonly promptCacheKey?: boolean;
177
+ readonly serviceTier?: ReadonlyArray<OpenString<"flex" | "priority" | "fast" | "ultrafast" | "standby">>;
178
+ }
122
179
  export declare class LanguageModel<Options extends ProviderOptions = ProviderOptions, Compact extends CompactionOperations | undefined = CompactionOperations | undefined> {
123
180
  protected readonly _ProviderOptions: Options;
124
181
  readonly id: ModelID;
125
182
  readonly provider: ProviderID;
126
183
  readonly route: AnyRoute<Compact>;
127
- readonly defaults?: LanguageModelDefaults;
184
+ readonly options?: RequestOptions;
185
+ readonly capabilities?: Capabilities;
128
186
  readonly compatibility?: LanguageModelCompatibility;
129
187
  constructor(input: LanguageModel.ConstructorInput<Compact>);
130
188
  static make<Options extends ProviderOptions = ProviderOptions, Compact extends CompactionOperations | undefined = CompactionOperations | undefined>(input: LanguageModel.Input<Compact>): LanguageModel<Options, Compact>;
@@ -142,7 +200,8 @@ export declare namespace LanguageModel {
142
200
  readonly id: ModelID;
143
201
  readonly provider: ProviderID;
144
202
  readonly route: AnyRoute<Compact>;
145
- readonly defaults?: LanguageModelDefaults;
203
+ readonly options?: RequestOptions;
204
+ readonly capabilities?: Capabilities;
146
205
  readonly compatibility?: LanguageModelCompatibility;
147
206
  };
148
207
  type Input<Compact extends CompactionOperations | undefined = CompactionOperations | undefined> = Omit<ConstructorInput<Compact>, "id" | "provider" | "compatibility"> & {