@opencode/ai 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +283 -114
- package/dist/ai-client.d.ts +2 -2
- package/dist/ai-client.js +2 -1
- package/dist/cache-policy.d.ts +4 -0
- package/dist/cache-policy.js +20 -6
- package/dist/decision-client.d.ts +21 -0
- package/dist/decision-client.js +55 -0
- package/dist/decision.d.ts +472 -0
- package/dist/decision.js +158 -0
- package/dist/effect.d.ts +38 -0
- package/dist/effect.js +27 -0
- package/dist/effort-updates.d.ts +2 -2
- package/dist/experimental/cloudflare-run-extraction.d.ts +13 -0
- package/dist/experimental/cloudflare-run-extraction.js +83 -0
- package/dist/experimental/extraction.d.ts +183 -0
- package/dist/experimental/extraction.js +102 -0
- package/dist/experimental/realtime.d.ts +7 -2
- package/dist/experimental/realtime.js +5 -5
- package/dist/experimental.d.ts +2 -3
- package/dist/experimental.js +1 -2
- package/dist/image-client.d.ts +13 -22
- package/dist/image-client.js +0 -1
- package/dist/image.d.ts +154 -324
- package/dist/image.js +4 -11
- package/dist/index.d.ts +1426 -34
- package/dist/index.js +127 -24
- package/dist/llm.d.ts +16 -1
- package/dist/llm.js +34 -0
- package/dist/media-client.d.ts +2 -1
- package/dist/media-model.d.ts +3 -0
- package/dist/media-model.js +4 -1
- package/dist/media.d.ts +0 -7
- package/dist/media.js +0 -6
- package/dist/protocols/alibaba-chat.d.ts +32 -12
- package/dist/protocols/alibaba-images.d.ts +22 -0
- package/dist/protocols/alibaba-images.js +77 -0
- package/dist/protocols/alibaba-messages.d.ts +62 -27
- package/dist/protocols/alibaba-responses.d.ts +41 -38
- package/dist/protocols/anthropic-messages.d.ts +196 -94
- package/dist/protocols/anthropic-messages.js +47 -16
- package/dist/protocols/bedrock-converse.d.ts +140 -47
- package/dist/protocols/bedrock-converse.js +114 -18
- package/dist/protocols/bedrock-event-stream.js +1 -0
- package/dist/protocols/bfl-images.d.ts +9 -0
- package/dist/protocols/bfl-images.js +17 -15
- package/dist/protocols/cartesia-speech.d.ts +32 -50
- package/dist/protocols/cloudflare-run-decisions.d.ts +9 -0
- package/dist/protocols/cloudflare-run-decisions.js +36 -0
- package/dist/protocols/cloudflare-workers-ai-images.d.ts +23 -0
- package/dist/protocols/cloudflare-workers-ai-images.js +80 -0
- package/dist/protocols/cohere-chat.d.ts +7 -8
- package/dist/protocols/deepgram-speech.d.ts +32 -50
- package/dist/protocols/elevenlabs-speech.d.ts +32 -50
- package/dist/protocols/fal-images.d.ts +10 -1
- package/dist/protocols/fal-images.js +16 -25
- package/dist/protocols/fal-video.js +1 -1
- package/dist/protocols/gemini.d.ts +37 -34
- package/dist/protocols/gemini.js +13 -8
- package/dist/protocols/google-images.d.ts +2 -2
- package/dist/protocols/google-images.js +8 -37
- package/dist/protocols/google-interactions.d.ts +18 -14
- package/dist/protocols/google-interactions.js +14 -7
- package/dist/protocols/google-speech.d.ts +32 -50
- package/dist/protocols/google-speech.js +0 -1
- package/dist/protocols/google-transcription.d.ts +32 -50
- package/dist/protocols/google-transcription.js +0 -1
- package/dist/protocols/google-video.d.ts +1 -1
- package/dist/protocols/google-video.js +2 -7
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.js +3 -0
- package/dist/protocols/meta-images.d.ts +7 -1
- package/dist/protocols/meta-images.js +10 -8
- package/dist/protocols/meta-messages.d.ts +73 -38
- package/dist/protocols/meta-messages.js +14 -1
- package/dist/protocols/meta-responses.d.ts +84 -78
- package/dist/protocols/meta-responses.js +29 -1
- package/dist/protocols/mistral-chat.d.ts +81 -78
- package/dist/protocols/mistral-chat.js +2 -1
- package/dist/protocols/open-responses-channel.js +47 -46
- package/dist/protocols/open-responses-continuation.d.ts +8 -2
- package/dist/protocols/open-responses-continuation.js +3 -1
- package/dist/protocols/open-responses.d.ts +426 -396
- package/dist/protocols/open-responses.js +16 -25
- package/dist/protocols/openai-chat.d.ts +764 -52
- package/dist/protocols/openai-chat.js +38 -25
- package/dist/protocols/openai-compatible-chat.d.ts +35 -15
- package/dist/protocols/openai-compatible-responses.d.ts +44 -42
- package/dist/protocols/openai-decisions.d.ts +22 -0
- package/dist/protocols/openai-decisions.js +128 -0
- package/dist/protocols/openai-images.d.ts +53 -56
- package/dist/protocols/openai-images.js +100 -34
- package/dist/protocols/openai-responses.d.ts +322 -264
- package/dist/protocols/openai-responses.js +33 -3
- package/dist/protocols/openai-speech.d.ts +32 -50
- package/dist/protocols/openai-speech.js +15 -5
- package/dist/protocols/openai-transcription.d.ts +32 -50
- package/dist/protocols/openai-transcription.js +15 -11
- package/dist/protocols/replicate-images.js +1 -1
- package/dist/protocols/runway-video.d.ts +1 -1
- package/dist/protocols/runway-video.js +1 -1
- package/dist/protocols/shared.d.ts +9 -1
- package/dist/protocols/shared.js +13 -2
- package/dist/protocols/stability-images.d.ts +5 -0
- package/dist/protocols/stability-images.js +4 -9
- package/dist/protocols/system-one.d.ts +101 -0
- package/dist/protocols/system-one.js +230 -0
- package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
- package/dist/protocols/utils/bedrock-cache.js +7 -6
- package/dist/protocols/utils/cache.d.ts +14 -3
- package/dist/protocols/utils/cache.js +11 -4
- package/dist/protocols/utils/gemini-generate-content.d.ts +3 -3
- package/dist/protocols/utils/gemini-generate-content.js +10 -16
- package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
- package/dist/protocols/utils/gemini-json-schema.js +3 -3
- package/dist/protocols/utils/image-sizing.d.ts +31 -0
- package/dist/protocols/utils/image-sizing.js +73 -0
- package/dist/protocols/utils/media-input.d.ts +4 -5
- package/dist/protocols/utils/media-input.js +8 -5
- package/dist/protocols/utils/partial-json-options.d.ts +0 -1
- package/dist/protocols/utils/partial-json-options.js +0 -1
- package/dist/protocols/utils/speech-stream.d.ts +0 -1
- package/dist/protocols/utils/speech-stream.js +0 -1
- package/dist/protocols/utils/tool-schema.js +15 -5
- package/dist/protocols/utils/tool-stream.d.ts +10 -1
- package/dist/protocols/venice-chat.d.ts +71 -53
- package/dist/protocols/venice-chat.js +7 -6
- package/dist/protocols/xai-images.d.ts +1 -2
- package/dist/protocols/xai-images.js +9 -2
- package/dist/protocols/xai-responses.d.ts +88 -78
- package/dist/protocols/xai-responses.js +28 -2
- package/dist/protocols/xai-video.d.ts +1 -1
- package/dist/protocols/xai-video.js +11 -8
- package/dist/protocols/zai-chat.d.ts +54 -30
- package/dist/protocols/zai-chat.js +8 -3
- package/dist/protocols/zai-images.d.ts +3 -1
- package/dist/protocols/zai-images.js +12 -11
- package/dist/protocols/zai-messages.d.ts +72 -35
- package/dist/protocols/zai-messages.js +3 -2
- package/dist/provider-error.js +24 -7
- package/dist/providers/alibaba/images.d.ts +2 -0
- package/dist/providers/alibaba/images.js +1 -0
- package/dist/providers/alibaba.d.ts +146 -85
- package/dist/providers/alibaba.js +16 -8
- package/dist/providers/amazon-bedrock-mantle.d.ts +277 -218
- package/dist/providers/amazon-bedrock.d.ts +48 -28
- package/dist/providers/amazon-bedrock.js +11 -11
- package/dist/providers/anthropic-compatible.d.ts +64 -29
- package/dist/providers/anthropic.d.ts +64 -29
- package/dist/providers/azure/images.d.ts +2 -0
- package/dist/providers/azure/images.js +1 -0
- package/dist/providers/azure.d.ts +156 -115
- package/dist/providers/azure.js +19 -1
- package/dist/providers/baseten/decisions.d.ts +2 -0
- package/dist/providers/baseten/decisions.js +1 -0
- package/dist/providers/baseten.d.ts +75 -25
- package/dist/providers/baseten.js +41 -8
- package/dist/providers/cerebras.d.ts +66 -24
- package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
- package/dist/providers/cloudflare-ai-gateway.d.ts +409 -272
- package/dist/providers/cloudflare-ai-gateway.js +33 -6
- package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
- package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
- package/dist/providers/cloudflare-workers-ai/images.js +1 -0
- package/dist/providers/cloudflare-workers-ai.d.ts +79 -25
- package/dist/providers/cloudflare-workers-ai.js +45 -9
- package/dist/providers/cohere.d.ts +117 -75
- package/dist/providers/deepinfra.d.ts +66 -24
- package/dist/providers/deepseek.d.ts +66 -24
- package/dist/providers/digitalocean/decisions.d.ts +2 -0
- package/dist/providers/digitalocean/decisions.js +1 -0
- package/dist/providers/digitalocean/images.d.ts +2 -0
- package/dist/providers/digitalocean/images.js +1 -0
- package/dist/providers/digitalocean.d.ts +108 -37
- package/dist/providers/digitalocean.js +39 -8
- package/dist/providers/fireworks.d.ts +66 -24
- package/dist/providers/google/images.d.ts +2 -0
- package/dist/providers/google/images.js +1 -0
- package/dist/providers/google-vertex/images.d.ts +2 -0
- package/dist/providers/google-vertex/images.js +1 -0
- package/dist/providers/google-vertex-chat.d.ts +33 -12
- package/dist/providers/google-vertex-messages.d.ts +64 -29
- package/dist/providers/google-vertex-mistral.d.ts +17 -17
- package/dist/providers/google-vertex-responses.d.ts +38 -35
- package/dist/providers/google-vertex.d.ts +20 -18
- package/dist/providers/google-vertex.js +32 -15
- package/dist/providers/google.d.ts +22 -21
- package/dist/providers/google.js +15 -8
- package/dist/providers/groq.d.ts +66 -28
- package/dist/providers/groq.js +0 -6
- package/dist/providers/meta.d.ts +144 -85
- package/dist/providers/minimax.d.ts +145 -86
- package/dist/providers/mistral.d.ts +28 -28
- package/dist/providers/moonshot.d.ts +277 -218
- package/dist/providers/open-responses-options.d.ts +0 -1
- package/dist/providers/open-responses-options.js +1 -1
- package/dist/providers/openai/images.d.ts +2 -0
- package/dist/providers/openai/images.js +1 -0
- package/dist/providers/openai-compatible/images.d.ts +2 -0
- package/dist/providers/openai-compatible/images.js +1 -0
- package/dist/providers/openai-compatible-responses.d.ts +38 -35
- package/dist/providers/openai-compatible.d.ts +36 -13
- package/dist/providers/openai-compatible.js +22 -10
- package/dist/providers/openai-options.d.ts +3 -2
- package/dist/providers/openai-options.js +0 -1
- package/dist/providers/openai.d.ts +146 -109
- package/dist/providers/openai.js +20 -4
- package/dist/providers/opencode/decisions.d.ts +2 -0
- package/dist/providers/opencode/decisions.js +1 -0
- package/dist/providers/opencode.d.ts +9 -10
- package/dist/providers/opencode.js +10 -8
- package/dist/providers/openrouter/decisions.d.ts +2 -0
- package/dist/providers/openrouter/decisions.js +1 -0
- package/dist/providers/openrouter/images.d.ts +2 -0
- package/dist/providers/openrouter/images.js +1 -0
- package/dist/providers/openrouter.d.ts +128 -47
- package/dist/providers/openrouter.js +38 -16
- package/dist/providers/togetherai.d.ts +66 -24
- package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
- package/dist/providers/typesafe-ai/decisions.js +1 -0
- package/dist/providers/typesafe-ai.d.ts +9 -10
- package/dist/providers/typesafe-ai.js +10 -8
- package/dist/providers/venice.d.ts +214 -20
- package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
- package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
- package/dist/providers/vercel-ai-gateway/images.js +1 -0
- package/dist/providers/vercel-ai-gateway.d.ts +10 -16
- package/dist/providers/vercel-ai-gateway.js +31 -85
- package/dist/providers/xai/images.d.ts +2 -0
- package/dist/providers/xai/images.js +1 -0
- package/dist/providers/xai.d.ts +40 -17
- package/dist/providers/xai.js +15 -8
- package/dist/providers/zai/images.d.ts +2 -0
- package/dist/providers/zai/images.js +1 -0
- package/dist/providers/zai-coding-plan.d.ts +224 -85
- package/dist/providers/zai.d.ts +110 -23
- package/dist/providers/zai.js +15 -8
- package/dist/route/auth-options.d.ts +0 -3
- package/dist/route/auth.d.ts +0 -2
- package/dist/route/auth.js +0 -2
- package/dist/route/client.d.ts +2 -4
- package/dist/route/client.js +29 -8
- package/dist/route/decision.d.ts +58 -0
- package/dist/route/decision.js +75 -0
- package/dist/route/executor-service.js +1 -1
- package/dist/route/executor.d.ts +1 -1
- package/dist/route/framing.d.ts +2 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.js +3 -0
- package/dist/route/media-protocol.d.ts +1 -0
- package/dist/route/media-protocol.js +12 -8
- package/dist/route/media.d.ts +5 -1
- package/dist/route/media.js +6 -2
- package/dist/route/transport/http.js +1 -0
- package/dist/route/transport/index.d.ts +1 -0
- package/dist/schema/events.d.ts +148 -6
- package/dist/schema/events.js +20 -0
- package/dist/schema/messages.d.ts +6 -2
- package/dist/schema/messages.js +3 -0
- package/dist/schema/options.d.ts +5 -3
- package/dist/schema/options.js +8 -3
- package/dist/speech-client.d.ts +13 -22
- package/dist/speech-client.js +0 -1
- package/dist/speech.d.ts +148 -283
- package/dist/speech.js +2 -4
- package/dist/testing.d.ts +25 -24
- package/dist/testing.js +3 -21
- package/dist/transcription-client.d.ts +13 -22
- package/dist/transcription.d.ts +148 -283
- package/dist/transcription.js +1 -1
- package/dist/utils/media-type.js +22 -1
- package/dist/video-client.d.ts +13 -22
- package/dist/video-client.js +0 -1
- package/dist/video.d.ts +115 -250
- package/dist/video.js +3 -5
- package/package.json +516 -13
- package/dist/experimental/evaluation-client.d.ts +0 -21
- package/dist/experimental/evaluation-client.js +0 -64
- package/dist/experimental/evaluation.d.ts +0 -242
- package/dist/experimental/evaluation.js +0 -115
- package/dist/experimental/system-one.d.ts +0 -16
- package/dist/experimental/system-one.js +0 -135
- package/dist/promise.d.ts +0 -1021
- package/dist/promise.js +0 -101
- package/dist/provider.d.ts +0 -23
- package/dist/provider.js +0 -2
|
@@ -21,9 +21,26 @@ const XAIResponsesHostedToolItem = Schema.Union([
|
|
|
21
21
|
error: Schema.optional(Schema.Unknown),
|
|
22
22
|
}), [JsonObject]),
|
|
23
23
|
]);
|
|
24
|
+
const Options = Schema.Struct({
|
|
25
|
+
minP: Schema.optional(Schema.Number),
|
|
26
|
+
});
|
|
27
|
+
const Body = Schema.Struct({
|
|
28
|
+
...OpenResponses.OpenResponsesBody.fields,
|
|
29
|
+
top_k: Schema.optional(Schema.Number),
|
|
30
|
+
min_p: Schema.optional(Schema.Number),
|
|
31
|
+
});
|
|
24
32
|
const adapter = {
|
|
25
33
|
id: ADAPTER,
|
|
26
34
|
name: NAME,
|
|
35
|
+
lowerMedia: ({ part, media }) => {
|
|
36
|
+
if (part.media.kind !== "video")
|
|
37
|
+
return undefined;
|
|
38
|
+
const filename = part.filename ?? "file";
|
|
39
|
+
const url = ProviderShared.mediaUrl(part.media);
|
|
40
|
+
if (url)
|
|
41
|
+
return { type: "input_file", filename, file_url: url };
|
|
42
|
+
return media && { type: "input_file", filename, file_data: media.dataUrl };
|
|
43
|
+
},
|
|
27
44
|
restoreHostedToolItem: (item) => (Schema.is(XAIResponsesHostedToolItem)(item) ? item : undefined),
|
|
28
45
|
};
|
|
29
46
|
const fromRequest = Effect.fn("XAIResponses.fromRequest")(function* (request) {
|
|
@@ -34,7 +51,16 @@ const fromRequest = Effect.fn("XAIResponses.fromRequest")(function* (request) {
|
|
|
34
51
|
route: request.model.route.id,
|
|
35
52
|
message: "xAI requires explicit compaction through LLMClient.compact; automatic context management is not supported",
|
|
36
53
|
});
|
|
37
|
-
|
|
54
|
+
const options = yield* ProviderShared.validateWith(Schema.decodeUnknownEffect(Options))(request.providerOptions ?? {});
|
|
55
|
+
const body = yield* OpenResponses.fromRequestWithAdapter(request, adapter);
|
|
56
|
+
// xAI Responses does not support penalties (they are ignored), but does support top_k.
|
|
57
|
+
return {
|
|
58
|
+
...body,
|
|
59
|
+
presence_penalty: undefined,
|
|
60
|
+
frequency_penalty: undefined,
|
|
61
|
+
top_k: request.generation?.topK,
|
|
62
|
+
min_p: options.minP,
|
|
63
|
+
};
|
|
38
64
|
});
|
|
39
65
|
const HOSTED_TOOLS = {
|
|
40
66
|
web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
|
|
@@ -61,7 +87,7 @@ const step = (state, input) => {
|
|
|
61
87
|
export const protocol = Protocol.make({
|
|
62
88
|
id: ADAPTER,
|
|
63
89
|
body: {
|
|
64
|
-
schema:
|
|
90
|
+
schema: Body,
|
|
65
91
|
from: fromRequest,
|
|
66
92
|
},
|
|
67
93
|
stream: {
|
|
@@ -8,7 +8,7 @@ export declare const EDIT_PATH = "/videos/edits";
|
|
|
8
8
|
export declare const EXTEND_PATH = "/videos/extensions";
|
|
9
9
|
export declare const STATUS_PATH = "/videos";
|
|
10
10
|
/**
|
|
11
|
-
* Provider-native options. Common fields (`frames`, `references`, `video`, `durationSeconds`, `
|
|
11
|
+
* Provider-native options. Common fields (`frames`, `references`, `video`, `durationSeconds`, `aspect`,
|
|
12
12
|
* `resolution`, `audio`) live on the request. `mode` selects the endpoint a `video` input is sent to.
|
|
13
13
|
*/
|
|
14
14
|
export type XAIVideoOptions = {
|
|
@@ -65,7 +65,7 @@ const fromRequest = Effect.fn("XAIVideo.fromRequest")(function* (request) {
|
|
|
65
65
|
reference_images: references.length === 0 ? undefined : references,
|
|
66
66
|
video,
|
|
67
67
|
duration: request.durationSeconds,
|
|
68
|
-
aspect_ratio: request.
|
|
68
|
+
aspect_ratio: request.aspect,
|
|
69
69
|
resolution: request.resolution,
|
|
70
70
|
generate_audio: request.audio,
|
|
71
71
|
}, nativeOptions(request.providerOptions), request.http?.body) ?? {});
|
|
@@ -98,12 +98,10 @@ const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, con
|
|
|
98
98
|
}
|
|
99
99
|
if (status !== "completed")
|
|
100
100
|
return yield* output.ended("expired", `${route.name} request ${context.token.requestID} expired`);
|
|
101
|
-
// `respect_moderation: false` marks a filtered result; a URL may still be present, so
|
|
102
|
-
const
|
|
103
|
-
? [{ type: "moderated", message: `${route.name} flagged the generated video for moderation` }]
|
|
104
|
-
: undefined;
|
|
101
|
+
// `respect_moderation: false` marks a filtered result; a URL may still be present, so only a missing one fails.
|
|
102
|
+
const moderated = decoded.video?.respect_moderation === false;
|
|
105
103
|
const url = decoded.video?.url ?? undefined;
|
|
106
|
-
if (url === undefined &&
|
|
104
|
+
if (url === undefined && moderated)
|
|
107
105
|
return yield* output.contentPolicy(`${route.name} withheld the video for moderation`);
|
|
108
106
|
if (url === undefined)
|
|
109
107
|
return yield* output.invalid(`${route.name} completed without a video URL`);
|
|
@@ -115,8 +113,13 @@ const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, con
|
|
|
115
113
|
info: duration === undefined ? undefined : { durationSeconds: duration },
|
|
116
114
|
}),
|
|
117
115
|
],
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
providerMetadata: {
|
|
117
|
+
xai: {
|
|
118
|
+
requestId: context.token.requestID,
|
|
119
|
+
model: decoded.model ?? undefined,
|
|
120
|
+
respectModeration: decoded.video?.respect_moderation ?? undefined,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
120
123
|
});
|
|
121
124
|
});
|
|
122
125
|
// ---------------------------------------------------------------------------
|
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
1
2
|
import { Protocol } from "../route/protocol.js";
|
|
2
3
|
import { OpenAIChat } from "./openai-chat.js";
|
|
3
|
-
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
readonly
|
|
7
|
-
|
|
4
|
+
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
5
|
+
export type ReasoningEffort = OpenResponsesOptions.ReasoningEffort;
|
|
6
|
+
declare const Options: Schema.Struct<{
|
|
7
|
+
readonly reasoningEffort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
8
|
+
readonly thinking: Schema.optional<Schema.Struct<{
|
|
9
|
+
readonly type: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"disabled" | "enabled">, import("../schema/options.js").OpenString<"disabled" | "enabled">>>;
|
|
8
10
|
/** False retains historical reasoning; omission preserves the endpoint's default. */
|
|
9
|
-
readonly clear_thinking
|
|
10
|
-
}
|
|
11
|
-
readonly toolStream
|
|
12
|
-
readonly doSample
|
|
13
|
-
readonly responseFormat
|
|
14
|
-
readonly type: "
|
|
15
|
-
}
|
|
16
|
-
readonly requestID
|
|
17
|
-
readonly userID
|
|
18
|
-
}
|
|
11
|
+
readonly clear_thinking: Schema.optional<Schema.Boolean>;
|
|
12
|
+
}>>;
|
|
13
|
+
readonly toolStream: Schema.optional<Schema.Boolean>;
|
|
14
|
+
readonly doSample: Schema.optional<Schema.Boolean>;
|
|
15
|
+
readonly responseFormat: Schema.optional<Schema.Struct<{
|
|
16
|
+
readonly type: Schema.declare<import("../schema/options.js").OpenString<"json_object" | "text">, import("../schema/options.js").OpenString<"json_object" | "text">>;
|
|
17
|
+
}>>;
|
|
18
|
+
readonly requestID: Schema.optional<Schema.String>;
|
|
19
|
+
readonly userID: Schema.optional<Schema.String>;
|
|
20
|
+
}>;
|
|
21
|
+
export type OptionsInput = typeof Options.Type;
|
|
19
22
|
export declare const compatibility: {
|
|
20
23
|
maxTokensField: "max_tokens";
|
|
21
24
|
supportsStrictMode: false;
|
|
@@ -27,44 +30,54 @@ export declare const protocol: Protocol<{
|
|
|
27
30
|
readonly messages: readonly ({
|
|
28
31
|
readonly role: "system";
|
|
29
32
|
readonly content: string | readonly ({
|
|
30
|
-
readonly type: "text";
|
|
31
|
-
readonly text: string;
|
|
32
|
-
readonly cache_control?: {
|
|
33
|
-
readonly type: "ephemeral";
|
|
34
|
-
readonly ttl?: string | undefined;
|
|
35
|
-
} | undefined;
|
|
36
|
-
} | {
|
|
37
33
|
readonly type: "image_url";
|
|
38
34
|
readonly image_url: {
|
|
39
35
|
readonly url: string;
|
|
40
36
|
};
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: "video_url";
|
|
39
|
+
readonly video_url: {
|
|
40
|
+
readonly url: string;
|
|
41
|
+
};
|
|
41
42
|
} | {
|
|
42
43
|
readonly type: "file";
|
|
43
44
|
readonly file: {
|
|
44
45
|
readonly filename: string;
|
|
45
46
|
readonly file_data: string;
|
|
46
47
|
};
|
|
47
|
-
}
|
|
48
|
-
} | {
|
|
49
|
-
readonly role: "user";
|
|
50
|
-
readonly content: string | readonly ({
|
|
48
|
+
} | {
|
|
51
49
|
readonly type: "text";
|
|
52
50
|
readonly text: string;
|
|
53
51
|
readonly cache_control?: {
|
|
54
52
|
readonly type: "ephemeral";
|
|
55
53
|
readonly ttl?: string | undefined;
|
|
56
54
|
} | undefined;
|
|
57
|
-
}
|
|
55
|
+
})[];
|
|
56
|
+
} | {
|
|
57
|
+
readonly role: "user";
|
|
58
|
+
readonly content: string | readonly ({
|
|
58
59
|
readonly type: "image_url";
|
|
59
60
|
readonly image_url: {
|
|
60
61
|
readonly url: string;
|
|
61
62
|
};
|
|
63
|
+
} | {
|
|
64
|
+
readonly type: "video_url";
|
|
65
|
+
readonly video_url: {
|
|
66
|
+
readonly url: string;
|
|
67
|
+
};
|
|
62
68
|
} | {
|
|
63
69
|
readonly type: "file";
|
|
64
70
|
readonly file: {
|
|
65
71
|
readonly filename: string;
|
|
66
72
|
readonly file_data: string;
|
|
67
73
|
};
|
|
74
|
+
} | {
|
|
75
|
+
readonly type: "text";
|
|
76
|
+
readonly text: string;
|
|
77
|
+
readonly cache_control?: {
|
|
78
|
+
readonly type: "ephemeral";
|
|
79
|
+
readonly ttl?: string | undefined;
|
|
80
|
+
} | undefined;
|
|
68
81
|
})[];
|
|
69
82
|
} | {
|
|
70
83
|
readonly role: "tool";
|
|
@@ -133,7 +146,18 @@ export declare const protocol: Protocol<{
|
|
|
133
146
|
} | undefined;
|
|
134
147
|
readonly store?: boolean | undefined;
|
|
135
148
|
readonly prompt_cache_key?: string | undefined;
|
|
136
|
-
readonly
|
|
149
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
150
|
+
readonly prompt_cache_options?: {
|
|
151
|
+
readonly ttl?: string | undefined;
|
|
152
|
+
} | undefined;
|
|
153
|
+
readonly reasoning_effort?: OpenResponsesOptions.ReasoningEffort | undefined;
|
|
154
|
+
readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
|
|
155
|
+
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
|
|
156
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
157
|
+
readonly metadata?: {
|
|
158
|
+
readonly [x: string]: string;
|
|
159
|
+
} | undefined;
|
|
160
|
+
readonly safety_identifier?: string | undefined;
|
|
137
161
|
readonly tool_stream?: boolean | undefined;
|
|
138
162
|
readonly max_completion_tokens?: number | undefined;
|
|
139
163
|
readonly max_tokens?: number | undefined;
|
|
@@ -144,12 +168,12 @@ export declare const protocol: Protocol<{
|
|
|
144
168
|
readonly seed?: number | undefined;
|
|
145
169
|
readonly stop?: readonly string[] | undefined;
|
|
146
170
|
readonly thinking?: {
|
|
147
|
-
readonly type?:
|
|
171
|
+
readonly type?: import("../schema/options.js").OpenString<"disabled" | "enabled"> | undefined;
|
|
148
172
|
readonly clear_thinking?: boolean | undefined;
|
|
149
173
|
} | undefined;
|
|
150
174
|
readonly do_sample?: boolean | undefined;
|
|
151
175
|
readonly response_format?: {
|
|
152
|
-
readonly type:
|
|
176
|
+
readonly type: import("../schema/options.js").OpenString<"json_object" | "text">;
|
|
153
177
|
} | undefined;
|
|
154
178
|
readonly request_id?: string | undefined;
|
|
155
179
|
readonly user_id?: string | undefined;
|
|
@@ -2,12 +2,17 @@ import { Effect, Schema } from "effect";
|
|
|
2
2
|
import { Protocol } from "../route/protocol.js";
|
|
3
3
|
import { OpenAIChat } from "./openai-chat.js";
|
|
4
4
|
import { ProviderShared } from "./shared.js";
|
|
5
|
+
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
5
6
|
const Options = Schema.Struct({
|
|
6
|
-
reasoningEffort: Schema.optional(
|
|
7
|
-
thinking: Schema.optional(Schema.Struct({
|
|
7
|
+
reasoningEffort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
|
|
8
|
+
thinking: Schema.optional(Schema.Struct({
|
|
9
|
+
type: Schema.optional(ProviderShared.knownString()),
|
|
10
|
+
/** False retains historical reasoning; omission preserves the endpoint's default. */
|
|
11
|
+
clear_thinking: Schema.optional(Schema.Boolean),
|
|
12
|
+
})),
|
|
8
13
|
toolStream: Schema.optional(Schema.Boolean),
|
|
9
14
|
doSample: Schema.optional(Schema.Boolean),
|
|
10
|
-
responseFormat: Schema.optional(Schema.Struct({ type:
|
|
15
|
+
responseFormat: Schema.optional(Schema.Struct({ type: ProviderShared.knownString() })),
|
|
11
16
|
requestID: Schema.optional(Schema.String),
|
|
12
17
|
userID: Schema.optional(Schema.String),
|
|
13
18
|
});
|
|
@@ -4,8 +4,10 @@ import { MediaRoute } from "../route/media.js";
|
|
|
4
4
|
import { type OpenString } from "../schema/index.js";
|
|
5
5
|
export declare const DEFAULT_BASE_URL = "https://api.z.ai/api/paas/v4";
|
|
6
6
|
export declare const PATH = "/images/generations";
|
|
7
|
-
/** Provider-native options.
|
|
7
|
+
/** Provider-native options. Common `aspect` and `resolution` lower to `size`. */
|
|
8
8
|
export type ZAIImageOptions = {
|
|
9
|
+
/** Exact `WIDTHxHEIGHT`; it wins over `aspect` and `resolution`. */
|
|
10
|
+
readonly size?: string;
|
|
9
11
|
readonly quality?: OpenString<"hd" | "standard">;
|
|
10
12
|
readonly userID?: string;
|
|
11
13
|
} & Record<string, unknown>;
|
|
@@ -3,6 +3,7 @@ import { ImageModel, ImageResponse } from "../image.js";
|
|
|
3
3
|
import { MediaProtocol } from "../route/media-protocol.js";
|
|
4
4
|
import { MediaRoute } from "../route/media.js";
|
|
5
5
|
import { mergeJsonRecords } from "../schema/index.js";
|
|
6
|
+
import { ImageSizing } from "./utils/image-sizing.js";
|
|
6
7
|
const route = MediaProtocol.identity({ id: "zai-images", name: "Z.ai Images", provider: "zai" });
|
|
7
8
|
export const DEFAULT_BASE_URL = "https://api.z.ai/api/paas/v4";
|
|
8
9
|
export const PATH = "/images/generations";
|
|
@@ -29,8 +30,17 @@ const nativeOptions = (options) => {
|
|
|
29
30
|
const { userID, ...native } = options;
|
|
30
31
|
return { user_id: userID, ...native };
|
|
31
32
|
};
|
|
33
|
+
/** GLM-Image takes 1024–2048 px edges in steps of 32; CogView takes 512–2048 px in steps of 16. */
|
|
34
|
+
const limits = (model) => model.startsWith("glm-image")
|
|
35
|
+
? { multiple: 32, minEdge: 1024, maxEdge: 2048, maxPixels: 2 ** 22 }
|
|
36
|
+
: { multiple: 16, minEdge: 512, maxEdge: 2048, maxPixels: 2 ** 21 };
|
|
32
37
|
const fromRequest = Effect.fn("ZAIImages.fromRequest")(function* (request) {
|
|
33
|
-
|
|
38
|
+
const size = yield* ImageSizing.exact(route, request, limits(request.model.id));
|
|
39
|
+
return MediaProtocol.json(mergeJsonRecords({
|
|
40
|
+
model: request.model.id,
|
|
41
|
+
prompt: request.prompt,
|
|
42
|
+
size: size === undefined ? undefined : `${size.width}x${size.height}`,
|
|
43
|
+
}, nativeOptions(request.providerOptions), request.http?.body) ?? {});
|
|
34
44
|
});
|
|
35
45
|
// ---------------------------------------------------------------------------
|
|
36
46
|
// 6. Response decoding
|
|
@@ -41,18 +51,9 @@ const decodeResponse = Effect.fn("ZAIImages.decodeResponse")(function* (response
|
|
|
41
51
|
const decoded = output.value;
|
|
42
52
|
if (decoded.data.length === 0)
|
|
43
53
|
return yield* output.invalid(`${route.name} returned no images`);
|
|
44
|
-
const filters = decoded.content_filter ?? [];
|
|
45
54
|
return new ImageResponse({
|
|
46
55
|
// Z.ai returns only URLs and no content type; the media type resolves when the asset is materialized.
|
|
47
56
|
images: yield* Effect.forEach(decoded.data, (item) => MediaProtocol.expiringUrl(item.url, OUTPUT_RETENTION)),
|
|
48
|
-
// Z.ai reports applied content filters alongside a successful result; surface them instead of dropping them.
|
|
49
|
-
notices: filters.length === 0
|
|
50
|
-
? undefined
|
|
51
|
-
: filters.map((filter) => ({
|
|
52
|
-
type: "moderated",
|
|
53
|
-
message: `${route.name} applied a content filter${filter.role === undefined ? "" : ` for ${filter.role}`}${filter.level === undefined ? "" : ` at level ${filter.level}`}`,
|
|
54
|
-
providerMetadata: { zai: filter },
|
|
55
|
-
})),
|
|
56
57
|
providerMetadata: {
|
|
57
58
|
zai: {
|
|
58
59
|
created: decoded.created,
|
|
@@ -67,7 +68,7 @@ const decodeResponse = Effect.fn("ZAIImages.decodeResponse")(function* (response
|
|
|
67
68
|
// 7. Protocol and route
|
|
68
69
|
// ---------------------------------------------------------------------------
|
|
69
70
|
export const protocol = MediaProtocol.inline(route, {
|
|
70
|
-
unsupported: ["images", "
|
|
71
|
+
unsupported: ["images", "n"],
|
|
71
72
|
body: { from: fromRequest },
|
|
72
73
|
response: { decode: decodeResponse },
|
|
73
74
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
1
2
|
import { Protocol } from "../route/protocol.js";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
readonly effort
|
|
5
|
-
readonly thinking
|
|
6
|
-
readonly type: "
|
|
7
|
-
}
|
|
8
|
-
}
|
|
3
|
+
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
4
|
+
declare const Options: Schema.Struct<{
|
|
5
|
+
readonly effort: Schema.optional<Schema.declare<OpenResponsesOptions.ReasoningEffort, OpenResponsesOptions.ReasoningEffort>>;
|
|
6
|
+
readonly thinking: Schema.optional<Schema.Struct<{
|
|
7
|
+
readonly type: Schema.declare<import("../schema/options.js").OpenString<"adaptive" | "disabled" | "enabled">, import("../schema/options.js").OpenString<"adaptive" | "disabled" | "enabled">>;
|
|
8
|
+
}>>;
|
|
9
|
+
}>;
|
|
10
|
+
export type OptionsInput = typeof Options.Type;
|
|
9
11
|
export declare const protocol: Protocol<{
|
|
10
12
|
readonly context_management?: {
|
|
11
13
|
readonly edits: readonly {
|
|
@@ -24,7 +26,7 @@ export declare const protocol: Protocol<{
|
|
|
24
26
|
readonly text: string;
|
|
25
27
|
readonly cache_control?: {
|
|
26
28
|
readonly type: "ephemeral";
|
|
27
|
-
readonly ttl?:
|
|
29
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
28
30
|
} | undefined;
|
|
29
31
|
}[] | undefined;
|
|
30
32
|
readonly messages: readonly ({
|
|
@@ -34,7 +36,7 @@ export declare const protocol: Protocol<{
|
|
|
34
36
|
readonly text: string;
|
|
35
37
|
readonly cache_control?: {
|
|
36
38
|
readonly type: "ephemeral";
|
|
37
|
-
readonly ttl?:
|
|
39
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
38
40
|
} | undefined;
|
|
39
41
|
} | {
|
|
40
42
|
readonly type: "image";
|
|
@@ -51,11 +53,28 @@ export declare const protocol: Protocol<{
|
|
|
51
53
|
};
|
|
52
54
|
readonly cache_control?: {
|
|
53
55
|
readonly type: "ephemeral";
|
|
54
|
-
readonly ttl?:
|
|
56
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
55
57
|
} | undefined;
|
|
56
58
|
readonly transformations?: {
|
|
57
59
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
58
60
|
} | undefined;
|
|
61
|
+
} | {
|
|
62
|
+
readonly type: "video";
|
|
63
|
+
readonly source: {
|
|
64
|
+
readonly type: "base64";
|
|
65
|
+
readonly media_type: string;
|
|
66
|
+
readonly data: string;
|
|
67
|
+
} | {
|
|
68
|
+
readonly type: "url";
|
|
69
|
+
readonly url: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "file";
|
|
72
|
+
readonly file_id: string;
|
|
73
|
+
};
|
|
74
|
+
readonly cache_control?: {
|
|
75
|
+
readonly type: "ephemeral";
|
|
76
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
77
|
+
} | undefined;
|
|
59
78
|
} | {
|
|
60
79
|
readonly type: "document";
|
|
61
80
|
readonly source: {
|
|
@@ -75,7 +94,7 @@ export declare const protocol: Protocol<{
|
|
|
75
94
|
};
|
|
76
95
|
readonly cache_control?: {
|
|
77
96
|
readonly type: "ephemeral";
|
|
78
|
-
readonly ttl?:
|
|
97
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
79
98
|
} | undefined;
|
|
80
99
|
readonly title?: string | undefined;
|
|
81
100
|
readonly context?: string | undefined;
|
|
@@ -90,7 +109,7 @@ export declare const protocol: Protocol<{
|
|
|
90
109
|
readonly text: string;
|
|
91
110
|
readonly cache_control?: {
|
|
92
111
|
readonly type: "ephemeral";
|
|
93
|
-
readonly ttl?:
|
|
112
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
94
113
|
} | undefined;
|
|
95
114
|
} | {
|
|
96
115
|
readonly type: "image";
|
|
@@ -107,11 +126,28 @@ export declare const protocol: Protocol<{
|
|
|
107
126
|
};
|
|
108
127
|
readonly cache_control?: {
|
|
109
128
|
readonly type: "ephemeral";
|
|
110
|
-
readonly ttl?:
|
|
129
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
111
130
|
} | undefined;
|
|
112
131
|
readonly transformations?: {
|
|
113
132
|
readonly oversized_image?: "downsize" | "error" | undefined;
|
|
114
133
|
} | undefined;
|
|
134
|
+
} | {
|
|
135
|
+
readonly type: "video";
|
|
136
|
+
readonly source: {
|
|
137
|
+
readonly type: "base64";
|
|
138
|
+
readonly media_type: string;
|
|
139
|
+
readonly data: string;
|
|
140
|
+
} | {
|
|
141
|
+
readonly type: "url";
|
|
142
|
+
readonly url: string;
|
|
143
|
+
} | {
|
|
144
|
+
readonly type: "file";
|
|
145
|
+
readonly file_id: string;
|
|
146
|
+
};
|
|
147
|
+
readonly cache_control?: {
|
|
148
|
+
readonly type: "ephemeral";
|
|
149
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
150
|
+
} | undefined;
|
|
115
151
|
} | {
|
|
116
152
|
readonly type: "document";
|
|
117
153
|
readonly source: {
|
|
@@ -131,7 +167,7 @@ export declare const protocol: Protocol<{
|
|
|
131
167
|
};
|
|
132
168
|
readonly cache_control?: {
|
|
133
169
|
readonly type: "ephemeral";
|
|
134
|
-
readonly ttl?:
|
|
170
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
135
171
|
} | undefined;
|
|
136
172
|
readonly title?: string | undefined;
|
|
137
173
|
readonly context?: string | undefined;
|
|
@@ -142,43 +178,35 @@ export declare const protocol: Protocol<{
|
|
|
142
178
|
readonly is_error?: boolean | undefined;
|
|
143
179
|
readonly cache_control?: {
|
|
144
180
|
readonly type: "ephemeral";
|
|
145
|
-
readonly ttl?:
|
|
181
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
146
182
|
} | undefined;
|
|
147
183
|
})[];
|
|
148
184
|
} | {
|
|
149
185
|
readonly role: "assistant";
|
|
150
186
|
readonly content: readonly ({
|
|
187
|
+
readonly type: "compaction";
|
|
188
|
+
readonly content: string | null;
|
|
189
|
+
} | {
|
|
151
190
|
readonly type: "text";
|
|
152
191
|
readonly text: string;
|
|
153
192
|
readonly cache_control?: {
|
|
154
193
|
readonly type: "ephemeral";
|
|
155
|
-
readonly ttl?:
|
|
156
|
-
} | undefined;
|
|
157
|
-
} | {
|
|
158
|
-
readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
|
|
159
|
-
readonly tool_use_id: string;
|
|
160
|
-
readonly content: unknown;
|
|
161
|
-
readonly cache_control?: {
|
|
162
|
-
readonly type: "ephemeral";
|
|
163
|
-
readonly ttl?: "1h" | "5m" | undefined;
|
|
194
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
164
195
|
} | undefined;
|
|
165
|
-
} | {
|
|
166
|
-
readonly type: "compaction";
|
|
167
|
-
readonly content: string | null;
|
|
168
196
|
} | {
|
|
169
197
|
readonly type: "thinking";
|
|
170
198
|
readonly thinking: string;
|
|
171
199
|
readonly signature: string;
|
|
172
200
|
readonly cache_control?: {
|
|
173
201
|
readonly type: "ephemeral";
|
|
174
|
-
readonly ttl?:
|
|
202
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
175
203
|
} | undefined;
|
|
176
204
|
} | {
|
|
177
205
|
readonly type: "redacted_thinking";
|
|
178
206
|
readonly data: string;
|
|
179
207
|
readonly cache_control?: {
|
|
180
208
|
readonly type: "ephemeral";
|
|
181
|
-
readonly ttl?:
|
|
209
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
182
210
|
} | undefined;
|
|
183
211
|
} | {
|
|
184
212
|
readonly type: "tool_use";
|
|
@@ -187,7 +215,7 @@ export declare const protocol: Protocol<{
|
|
|
187
215
|
readonly input: unknown;
|
|
188
216
|
readonly cache_control?: {
|
|
189
217
|
readonly type: "ephemeral";
|
|
190
|
-
readonly ttl?:
|
|
218
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
191
219
|
} | undefined;
|
|
192
220
|
} | {
|
|
193
221
|
readonly type: "server_tool_use";
|
|
@@ -196,7 +224,15 @@ export declare const protocol: Protocol<{
|
|
|
196
224
|
readonly input: unknown;
|
|
197
225
|
readonly cache_control?: {
|
|
198
226
|
readonly type: "ephemeral";
|
|
199
|
-
readonly ttl?:
|
|
227
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
228
|
+
} | undefined;
|
|
229
|
+
} | {
|
|
230
|
+
readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
|
|
231
|
+
readonly tool_use_id: string;
|
|
232
|
+
readonly content: unknown;
|
|
233
|
+
readonly cache_control?: {
|
|
234
|
+
readonly type: "ephemeral";
|
|
235
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
200
236
|
} | undefined;
|
|
201
237
|
})[];
|
|
202
238
|
} | {
|
|
@@ -206,7 +242,7 @@ export declare const protocol: Protocol<{
|
|
|
206
242
|
readonly text: string;
|
|
207
243
|
readonly cache_control?: {
|
|
208
244
|
readonly type: "ephemeral";
|
|
209
|
-
readonly ttl?:
|
|
245
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
210
246
|
} | undefined;
|
|
211
247
|
}[];
|
|
212
248
|
readonly output_config?: {
|
|
@@ -221,7 +257,7 @@ export declare const protocol: Protocol<{
|
|
|
221
257
|
};
|
|
222
258
|
readonly cache_control?: {
|
|
223
259
|
readonly type: "ephemeral";
|
|
224
|
-
readonly ttl?:
|
|
260
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
225
261
|
} | undefined;
|
|
226
262
|
}[] | undefined;
|
|
227
263
|
readonly tool_choice?: {
|
|
@@ -249,7 +285,7 @@ export declare const protocol: Protocol<{
|
|
|
249
285
|
} | undefined;
|
|
250
286
|
readonly cache_control?: {
|
|
251
287
|
readonly type: "ephemeral";
|
|
252
|
-
readonly ttl?:
|
|
288
|
+
readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
|
|
253
289
|
} | undefined;
|
|
254
290
|
readonly container?: string | {
|
|
255
291
|
readonly id?: string | null | undefined;
|
|
@@ -262,8 +298,9 @@ export declare const protocol: Protocol<{
|
|
|
262
298
|
readonly user_id?: string | null | undefined;
|
|
263
299
|
} | undefined;
|
|
264
300
|
readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
|
|
301
|
+
readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
|
|
265
302
|
readonly thinking?: {
|
|
266
|
-
readonly type:
|
|
303
|
+
readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled" | "enabled">;
|
|
267
304
|
} | undefined;
|
|
268
305
|
}, string, {
|
|
269
306
|
readonly [x: string]: unknown;
|
|
@@ -3,9 +3,10 @@ import { Protocol } from "../route/protocol.js";
|
|
|
3
3
|
import { LLMRequest } from "../schema/index.js";
|
|
4
4
|
import { AnthropicMessages } from "./anthropic-messages.js";
|
|
5
5
|
import { ProviderShared } from "./shared.js";
|
|
6
|
+
import { OpenResponsesOptions } from "./utils/open-responses-options.js";
|
|
6
7
|
const Options = Schema.Struct({
|
|
7
|
-
effort: Schema.optional(
|
|
8
|
-
thinking: Schema.optional(Schema.Struct({ type:
|
|
8
|
+
effort: Schema.optional(OpenResponsesOptions.ReasoningEffort),
|
|
9
|
+
thinking: Schema.optional(Schema.Struct({ type: ProviderShared.knownString() })),
|
|
9
10
|
});
|
|
10
11
|
const Body = Schema.Struct({
|
|
11
12
|
...AnthropicMessages.AnthropicMessagesBody.fields,
|