@opencode/ai 2.0.21 → 2.0.23
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 +61 -1
- package/dist/cache-policy.js +10 -2
- package/dist/llm.d.ts +4 -0
- package/dist/promise.d.ts +8 -0
- package/dist/protocols/alibaba-chat.d.ts +7 -3
- package/dist/protocols/alibaba-chat.js +2 -1
- package/dist/protocols/alibaba-responses.d.ts +16 -12
- package/dist/protocols/alibaba-responses.js +3 -5
- package/dist/protocols/anthropic-messages.js +58 -51
- package/dist/protocols/bedrock-converse.js +33 -4
- package/dist/protocols/cartesia-speech.js +3 -3
- package/dist/protocols/cohere-chat.d.ts +178 -0
- package/dist/protocols/cohere-chat.js +299 -0
- package/dist/protocols/elevenlabs-speech.js +3 -3
- package/dist/protocols/gemini.d.ts +2 -2
- package/dist/protocols/gemini.js +3 -3
- package/dist/protocols/google-interactions.d.ts +236 -0
- package/dist/protocols/google-interactions.js +478 -0
- package/dist/protocols/google-speech.js +1 -1
- package/dist/protocols/google-transcription.js +1 -1
- package/dist/protocols/index.d.ts +2 -0
- package/dist/protocols/index.js +2 -0
- package/dist/protocols/meta-responses.d.ts +31 -58
- package/dist/protocols/meta-responses.js +8 -27
- package/dist/protocols/mistral-chat.d.ts +24 -9
- package/dist/protocols/mistral-chat.js +22 -10
- package/dist/protocols/open-responses.d.ts +410 -91
- package/dist/protocols/open-responses.js +25 -15
- package/dist/protocols/openai-chat.d.ts +409 -5
- package/dist/protocols/openai-chat.js +27 -26
- package/dist/protocols/openai-compatible-chat.d.ts +1 -1
- package/dist/protocols/openai-compatible-responses.d.ts +16 -4
- package/dist/protocols/openai-images.js +2 -2
- package/dist/protocols/openai-responses.d.ts +87 -223
- package/dist/protocols/openai-responses.js +10 -16
- package/dist/protocols/openai-speech.js +1 -1
- package/dist/protocols/openai-transcription.js +1 -1
- package/dist/protocols/shared.js +2 -2
- package/dist/protocols/stability-images.js +1 -1
- package/dist/protocols/utils/bedrock-media.js +2 -2
- package/dist/protocols/utils/cache.d.ts +5 -0
- package/dist/protocols/utils/cache.js +9 -1
- package/dist/protocols/utils/responses-checkpoint.js +2 -2
- package/dist/protocols/utils/responses-hosted-tools.js +1 -1
- package/dist/protocols/utils/tool-stream.d.ts +12 -0
- package/dist/protocols/utils/tool-stream.js +15 -7
- package/dist/protocols/venice-chat.d.ts +280 -0
- package/dist/protocols/venice-chat.js +283 -0
- package/dist/protocols/xai-responses.d.ts +18 -21
- package/dist/protocols/xai-responses.js +2 -8
- package/dist/protocols/zai-chat.d.ts +7 -3
- package/dist/protocols/zai-chat.js +6 -3
- package/dist/provider-error.js +27 -7
- package/dist/providers/alibaba.d.ts +17 -13
- package/dist/providers/amazon-bedrock/mantle/messages.d.ts +2 -0
- package/dist/providers/amazon-bedrock/mantle/messages.js +1 -0
- package/dist/providers/amazon-bedrock-mantle.d.ts +301 -9
- package/dist/providers/amazon-bedrock-mantle.js +28 -3
- package/dist/providers/azure.d.ts +13 -61
- package/dist/providers/baseten.d.ts +2 -2
- package/dist/providers/cerebras.d.ts +2 -2
- package/dist/providers/cloudflare-ai-gateway.d.ts +14 -62
- package/dist/providers/cloudflare-workers-ai.d.ts +2 -2
- package/dist/providers/cohere/chat.d.ts +4 -0
- package/dist/providers/cohere/chat.js +8 -0
- package/dist/providers/cohere.d.ts +395 -0
- package/dist/providers/cohere.js +48 -0
- package/dist/providers/deepinfra.d.ts +2 -2
- package/dist/providers/deepseek.d.ts +2 -2
- package/dist/providers/digitalocean.d.ts +469 -0
- package/dist/providers/digitalocean.js +53 -0
- package/dist/providers/fireworks.d.ts +2 -2
- package/dist/providers/google/interactions.d.ts +7 -0
- package/dist/providers/google/interactions.js +8 -0
- package/dist/providers/google-vertex-chat.d.ts +1 -1
- package/dist/providers/google-vertex-messages.js +1 -1
- package/dist/providers/google-vertex-responses.d.ts +16 -4
- package/dist/providers/google-vertex.d.ts +1 -1
- package/dist/providers/google.d.ts +95 -4
- package/dist/providers/google.js +8 -1
- package/dist/providers/groq.d.ts +8 -4
- package/dist/providers/groq.js +1 -1
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.js +3 -0
- package/dist/providers/meta.d.ts +15 -28
- package/dist/providers/minimax.d.ts +17 -5
- package/dist/providers/mistral.d.ts +10 -4
- package/dist/providers/moonshot.d.ts +17 -5
- package/dist/providers/openai-compatible-responses.d.ts +16 -4
- package/dist/providers/openai-compatible.d.ts +1 -1
- package/dist/providers/openai-options.d.ts +1 -1
- package/dist/providers/openai.d.ts +7 -31
- package/dist/providers/openrouter.d.ts +9 -5
- package/dist/providers/openrouter.js +1 -13
- package/dist/providers/togetherai.d.ts +2 -2
- package/dist/providers/venice.d.ts +183 -0
- package/dist/providers/venice.js +38 -0
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/zai-coding-plan.d.ts +17 -5
- package/dist/providers/zai.d.ts +1 -1
- package/dist/route/client.d.ts +4 -0
- package/dist/route/client.js +2 -5
- package/dist/route/executor.js +13 -6
- package/dist/route/framing.js +23 -23
- package/dist/route/transport/http.d.ts +2 -1
- package/dist/route/transport/http.js +28 -6
- package/dist/schema/events.d.ts +176 -0
- package/dist/schema/events.js +4 -0
- package/dist/schema/options.d.ts +11 -0
- package/dist/schema/options.js +15 -2
- package/dist/testing.d.ts +32 -0
- package/dist/tool-history.js +17 -3
- package/package.json +3 -3
|
@@ -13,7 +13,7 @@ export type OpenAIProviderOptionsInput = OpenAIOptionsInput;
|
|
|
13
13
|
export declare const gpt5DefaultOptions: (modelID: string) => ProviderOptions | undefined;
|
|
14
14
|
export declare const openAIDefaultOptions: (modelID: string) => ProviderOptions | undefined;
|
|
15
15
|
export declare const withOpenAIOptions: <Options extends {
|
|
16
|
-
readonly providerOptions?:
|
|
16
|
+
readonly providerOptions?: ProviderOptions;
|
|
17
17
|
}>(modelID: string, options: Options) => Omit<Options, "providerOptions"> & {
|
|
18
18
|
readonly providerOptions?: ProviderOptions;
|
|
19
19
|
};
|
|
@@ -123,9 +123,9 @@ export declare const routes: (Route<{
|
|
|
123
123
|
readonly top_p?: number | undefined;
|
|
124
124
|
readonly frequency_penalty?: number | undefined;
|
|
125
125
|
readonly presence_penalty?: number | undefined;
|
|
126
|
+
readonly store?: boolean | undefined;
|
|
126
127
|
readonly prompt_cache_key?: string | undefined;
|
|
127
128
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
128
|
-
readonly store?: boolean | undefined;
|
|
129
129
|
readonly stream_options?: {
|
|
130
130
|
readonly include_usage: boolean;
|
|
131
131
|
} | undefined;
|
|
@@ -173,6 +173,10 @@ export declare const routes: (Route<{
|
|
|
173
173
|
readonly reasoning: {
|
|
174
174
|
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
175
175
|
};
|
|
176
|
+
} | {
|
|
177
|
+
readonly [x: string]: unknown;
|
|
178
|
+
readonly type: string;
|
|
179
|
+
readonly id: string;
|
|
176
180
|
} | {
|
|
177
181
|
readonly type: "reasoning";
|
|
178
182
|
readonly summary: readonly {
|
|
@@ -249,34 +253,6 @@ export declare const routes: (Route<{
|
|
|
249
253
|
readonly type: "input_video";
|
|
250
254
|
readonly video_url: string;
|
|
251
255
|
})[];
|
|
252
|
-
} | {
|
|
253
|
-
readonly [x: string]: unknown;
|
|
254
|
-
readonly id: string;
|
|
255
|
-
readonly type: "computer_call";
|
|
256
|
-
readonly status?: string | undefined;
|
|
257
|
-
readonly action?: {
|
|
258
|
-
readonly [x: string]: unknown;
|
|
259
|
-
} | null | undefined;
|
|
260
|
-
readonly call_id?: string | undefined;
|
|
261
|
-
readonly pending_safety_checks?: readonly {
|
|
262
|
-
readonly [x: string]: unknown;
|
|
263
|
-
}[] | undefined;
|
|
264
|
-
} | {
|
|
265
|
-
readonly [x: string]: unknown;
|
|
266
|
-
readonly id: string;
|
|
267
|
-
readonly type: "web_search_preview_call";
|
|
268
|
-
readonly status?: string | undefined;
|
|
269
|
-
readonly action?: {
|
|
270
|
-
readonly [x: string]: unknown;
|
|
271
|
-
} | null | undefined;
|
|
272
|
-
} | {
|
|
273
|
-
readonly [x: string]: unknown;
|
|
274
|
-
readonly id: string;
|
|
275
|
-
readonly type: "image_generation_call";
|
|
276
|
-
readonly status?: string | undefined;
|
|
277
|
-
readonly result?: string | null | undefined;
|
|
278
|
-
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
279
|
-
readonly revised_prompt?: string | null | undefined;
|
|
280
256
|
})[];
|
|
281
257
|
readonly model: string;
|
|
282
258
|
readonly stream: true;
|
|
@@ -345,9 +321,10 @@ export declare const routes: (Route<{
|
|
|
345
321
|
readonly top_p?: number | undefined;
|
|
346
322
|
readonly frequency_penalty?: number | undefined;
|
|
347
323
|
readonly presence_penalty?: number | undefined;
|
|
324
|
+
readonly store?: boolean | undefined;
|
|
325
|
+
readonly max_output_tokens?: number | undefined;
|
|
348
326
|
readonly prompt_cache_key?: string | undefined;
|
|
349
327
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
350
|
-
readonly store?: boolean | undefined;
|
|
351
328
|
readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
352
329
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
353
330
|
readonly stream_options?: {
|
|
@@ -355,7 +332,6 @@ export declare const routes: (Route<{
|
|
|
355
332
|
} | undefined;
|
|
356
333
|
readonly safety_identifier?: string | undefined;
|
|
357
334
|
readonly top_logprobs?: number | undefined;
|
|
358
|
-
readonly max_output_tokens?: number | undefined;
|
|
359
335
|
readonly max_tool_calls?: number | undefined;
|
|
360
336
|
}, import("../protocols/open-responses-channel.js").Prepared, {
|
|
361
337
|
endpoint: import("../route/client.js").CompactOperation;
|
|
@@ -322,9 +322,9 @@ export declare const protocol: Protocol<{
|
|
|
322
322
|
readonly top_p?: number | undefined;
|
|
323
323
|
readonly frequency_penalty?: number | undefined;
|
|
324
324
|
readonly presence_penalty?: number | undefined;
|
|
325
|
+
readonly store?: boolean | undefined;
|
|
325
326
|
readonly prompt_cache_key?: string | undefined;
|
|
326
327
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
327
|
-
readonly store?: boolean | undefined;
|
|
328
328
|
readonly stream_options?: {
|
|
329
329
|
readonly include_usage: boolean;
|
|
330
330
|
} | undefined;
|
|
@@ -338,16 +338,18 @@ export declare const protocol: Protocol<{
|
|
|
338
338
|
} | null | undefined;
|
|
339
339
|
readonly usage?: {
|
|
340
340
|
readonly [x: string]: unknown;
|
|
341
|
+
readonly cache_read_input_tokens?: number | null | undefined;
|
|
341
342
|
readonly cached_tokens?: number | null | undefined;
|
|
343
|
+
readonly total_tokens?: number | null | undefined;
|
|
342
344
|
readonly prompt_tokens?: number | null | undefined;
|
|
343
345
|
readonly completion_tokens?: number | null | undefined;
|
|
344
|
-
readonly total_tokens?: number | null | undefined;
|
|
345
346
|
readonly prompt_tokens_details?: {
|
|
346
347
|
readonly [x: string]: unknown;
|
|
347
348
|
readonly cached_tokens?: number | null | undefined;
|
|
348
349
|
readonly cache_write_tokens?: number | null | undefined;
|
|
349
350
|
} | null | undefined;
|
|
350
351
|
readonly prompt_cache_hit_tokens?: number | null | undefined;
|
|
352
|
+
readonly cache_created_input_tokens?: number | null | undefined;
|
|
351
353
|
readonly completion_tokens_details?: {
|
|
352
354
|
readonly [x: string]: unknown;
|
|
353
355
|
readonly reasoning_tokens?: number | null | undefined;
|
|
@@ -377,16 +379,18 @@ export declare const protocol: Protocol<{
|
|
|
377
379
|
} | null | undefined;
|
|
378
380
|
readonly usage?: {
|
|
379
381
|
readonly [x: string]: unknown;
|
|
382
|
+
readonly cache_read_input_tokens?: number | null | undefined;
|
|
380
383
|
readonly cached_tokens?: number | null | undefined;
|
|
384
|
+
readonly total_tokens?: number | null | undefined;
|
|
381
385
|
readonly prompt_tokens?: number | null | undefined;
|
|
382
386
|
readonly completion_tokens?: number | null | undefined;
|
|
383
|
-
readonly total_tokens?: number | null | undefined;
|
|
384
387
|
readonly prompt_tokens_details?: {
|
|
385
388
|
readonly [x: string]: unknown;
|
|
386
389
|
readonly cached_tokens?: number | null | undefined;
|
|
387
390
|
readonly cache_write_tokens?: number | null | undefined;
|
|
388
391
|
} | null | undefined;
|
|
389
392
|
readonly prompt_cache_hit_tokens?: number | null | undefined;
|
|
393
|
+
readonly cache_created_input_tokens?: number | null | undefined;
|
|
390
394
|
readonly completion_tokens_details?: {
|
|
391
395
|
readonly [x: string]: unknown;
|
|
392
396
|
readonly reasoning_tokens?: number | null | undefined;
|
|
@@ -513,9 +517,9 @@ export declare const route: Route<{
|
|
|
513
517
|
readonly top_p?: number | undefined;
|
|
514
518
|
readonly frequency_penalty?: number | undefined;
|
|
515
519
|
readonly presence_penalty?: number | undefined;
|
|
520
|
+
readonly store?: boolean | undefined;
|
|
516
521
|
readonly prompt_cache_key?: string | undefined;
|
|
517
522
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
518
|
-
readonly store?: boolean | undefined;
|
|
519
523
|
readonly stream_options?: {
|
|
520
524
|
readonly include_usage: boolean;
|
|
521
525
|
} | undefined;
|
|
@@ -636,9 +640,9 @@ export declare const routes: Route<{
|
|
|
636
640
|
readonly top_p?: number | undefined;
|
|
637
641
|
readonly frequency_penalty?: number | undefined;
|
|
638
642
|
readonly presence_penalty?: number | undefined;
|
|
643
|
+
readonly store?: boolean | undefined;
|
|
639
644
|
readonly prompt_cache_key?: string | undefined;
|
|
640
645
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
641
|
-
readonly store?: boolean | undefined;
|
|
642
646
|
readonly stream_options?: {
|
|
643
647
|
readonly include_usage: boolean;
|
|
644
648
|
} | undefined;
|
|
@@ -6,7 +6,7 @@ import { AuthOptions } from "../route/auth-options.js";
|
|
|
6
6
|
import { HttpOptions, ProviderID } from "../schema/index.js";
|
|
7
7
|
import { SystemOne } from "../experimental/system-one.js";
|
|
8
8
|
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
9
|
-
import {
|
|
9
|
+
import { cacheControl } from "../protocols/utils/cache.js";
|
|
10
10
|
import { isRecord, ProviderShared } from "../protocols/shared.js";
|
|
11
11
|
export const id = ProviderID.make("openrouter");
|
|
12
12
|
const baseURL = "https://openrouter.ai/api/v1";
|
|
@@ -47,18 +47,6 @@ export const protocol = Protocol.make({
|
|
|
47
47
|
},
|
|
48
48
|
stream: OpenAIChat.protocol.stream,
|
|
49
49
|
});
|
|
50
|
-
const cacheControl = () => {
|
|
51
|
-
const breakpoints = newBreakpoints(4);
|
|
52
|
-
return (cache) => {
|
|
53
|
-
if (cache === undefined || breakpoints.remaining === 0)
|
|
54
|
-
return undefined;
|
|
55
|
-
breakpoints.remaining -= 1;
|
|
56
|
-
return {
|
|
57
|
-
type: "ephemeral",
|
|
58
|
-
...(ttlBucket(cache.ttlSeconds) === "1h" ? { ttl: "1h" } : {}),
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
50
|
// OpenRouter forwards `reasoning.max_tokens` as the upstream thinking budget. Upstreams such as Anthropic and Alibaba
|
|
63
51
|
// reject one that is not below the output limit; 1,024 is Anthropic's minimum budget.
|
|
64
52
|
const fitReasoning = (reasoning, maxTokens) => typeof reasoning.max_tokens === "number"
|
|
@@ -126,9 +126,9 @@ export declare const route: Route<{
|
|
|
126
126
|
readonly top_p?: number | undefined;
|
|
127
127
|
readonly frequency_penalty?: number | undefined;
|
|
128
128
|
readonly presence_penalty?: number | undefined;
|
|
129
|
+
readonly store?: boolean | undefined;
|
|
129
130
|
readonly prompt_cache_key?: string | undefined;
|
|
130
131
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
131
|
-
readonly store?: boolean | undefined;
|
|
132
132
|
readonly stream_options?: {
|
|
133
133
|
readonly include_usage: boolean;
|
|
134
134
|
} | undefined;
|
|
@@ -248,9 +248,9 @@ export declare const routes: Route<{
|
|
|
248
248
|
readonly top_p?: number | undefined;
|
|
249
249
|
readonly frequency_penalty?: number | undefined;
|
|
250
250
|
readonly presence_penalty?: number | undefined;
|
|
251
|
+
readonly store?: boolean | undefined;
|
|
251
252
|
readonly prompt_cache_key?: string | undefined;
|
|
252
253
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
253
|
-
readonly store?: boolean | undefined;
|
|
254
254
|
readonly stream_options?: {
|
|
255
255
|
readonly include_usage: boolean;
|
|
256
256
|
} | undefined;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { ProviderPackage } from "../provider-package.js";
|
|
2
|
+
import { VeniceChat } from "../protocols/venice-chat.js";
|
|
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";
|
|
6
|
+
export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
7
|
+
export type ChatOptionsInput = VeniceChat.OptionsInput;
|
|
8
|
+
export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
|
|
9
|
+
readonly baseURL?: string;
|
|
10
|
+
readonly queryParams?: Readonly<Record<string, string>>;
|
|
11
|
+
readonly providerOptions?: ChatOptionsInput;
|
|
12
|
+
};
|
|
13
|
+
export type Settings = ProviderPackage.Settings & ChatOptionsInput & {
|
|
14
|
+
readonly apiKey?: string;
|
|
15
|
+
readonly baseURL?: string;
|
|
16
|
+
readonly queryParams?: Readonly<Record<string, string>>;
|
|
17
|
+
};
|
|
18
|
+
export declare const routes: Route<{
|
|
19
|
+
readonly model: string;
|
|
20
|
+
readonly messages: readonly ({
|
|
21
|
+
readonly role: "system";
|
|
22
|
+
readonly content: string | readonly ({
|
|
23
|
+
readonly type: "text";
|
|
24
|
+
readonly text: string;
|
|
25
|
+
readonly cache_control?: {
|
|
26
|
+
readonly type: "ephemeral";
|
|
27
|
+
readonly ttl?: string | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "image_url";
|
|
31
|
+
readonly image_url: {
|
|
32
|
+
readonly url: string;
|
|
33
|
+
};
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "file";
|
|
36
|
+
readonly file: {
|
|
37
|
+
readonly filename: string;
|
|
38
|
+
readonly file_data: string;
|
|
39
|
+
};
|
|
40
|
+
})[];
|
|
41
|
+
} | {
|
|
42
|
+
readonly role: "user";
|
|
43
|
+
readonly content: string | readonly ({
|
|
44
|
+
readonly type: "text";
|
|
45
|
+
readonly text: string;
|
|
46
|
+
readonly cache_control?: {
|
|
47
|
+
readonly type: "ephemeral";
|
|
48
|
+
readonly ttl?: string | undefined;
|
|
49
|
+
} | undefined;
|
|
50
|
+
} | {
|
|
51
|
+
readonly type: "image_url";
|
|
52
|
+
readonly image_url: {
|
|
53
|
+
readonly url: string;
|
|
54
|
+
};
|
|
55
|
+
} | {
|
|
56
|
+
readonly type: "file";
|
|
57
|
+
readonly file: {
|
|
58
|
+
readonly filename: string;
|
|
59
|
+
readonly file_data: string;
|
|
60
|
+
};
|
|
61
|
+
})[];
|
|
62
|
+
} | {
|
|
63
|
+
readonly role: "tool";
|
|
64
|
+
readonly tool_call_id: string;
|
|
65
|
+
readonly content: string | readonly {
|
|
66
|
+
readonly type: "text";
|
|
67
|
+
readonly text: string;
|
|
68
|
+
readonly cache_control?: {
|
|
69
|
+
readonly type: "ephemeral";
|
|
70
|
+
readonly ttl?: string | undefined;
|
|
71
|
+
} | undefined;
|
|
72
|
+
}[];
|
|
73
|
+
} | {
|
|
74
|
+
readonly [x: string]: unknown;
|
|
75
|
+
readonly content: string | readonly {
|
|
76
|
+
readonly type: "text";
|
|
77
|
+
readonly text: string;
|
|
78
|
+
readonly cache_control?: {
|
|
79
|
+
readonly type: "ephemeral";
|
|
80
|
+
readonly ttl?: string | undefined;
|
|
81
|
+
} | undefined;
|
|
82
|
+
}[] | null;
|
|
83
|
+
readonly role: "assistant";
|
|
84
|
+
readonly reasoning?: string | undefined;
|
|
85
|
+
readonly reasoning_content?: string | undefined;
|
|
86
|
+
readonly reasoning_text?: string | undefined;
|
|
87
|
+
readonly tool_calls?: readonly {
|
|
88
|
+
readonly function: {
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly arguments: string;
|
|
91
|
+
};
|
|
92
|
+
readonly id: string;
|
|
93
|
+
readonly type: "function";
|
|
94
|
+
readonly thought_signature?: string | undefined;
|
|
95
|
+
readonly extra_content?: {
|
|
96
|
+
readonly google: {
|
|
97
|
+
readonly thought_signature: string;
|
|
98
|
+
};
|
|
99
|
+
} | undefined;
|
|
100
|
+
}[] | undefined;
|
|
101
|
+
readonly thought_signature?: string | undefined;
|
|
102
|
+
readonly reasoning_details?: unknown;
|
|
103
|
+
})[];
|
|
104
|
+
readonly stream: true;
|
|
105
|
+
readonly venice_parameters: {
|
|
106
|
+
readonly [x: string]: string | boolean;
|
|
107
|
+
};
|
|
108
|
+
readonly reasoning?: {
|
|
109
|
+
readonly enabled?: boolean | undefined;
|
|
110
|
+
readonly summary?: string | undefined;
|
|
111
|
+
readonly effort?: string | undefined;
|
|
112
|
+
} | undefined;
|
|
113
|
+
readonly max_completion_tokens?: number | undefined;
|
|
114
|
+
readonly max_tokens?: number | undefined;
|
|
115
|
+
readonly tools?: readonly {
|
|
116
|
+
readonly function: {
|
|
117
|
+
readonly description: string;
|
|
118
|
+
readonly name: string;
|
|
119
|
+
readonly parameters: {
|
|
120
|
+
readonly [x: string]: unknown;
|
|
121
|
+
};
|
|
122
|
+
readonly strict?: boolean | undefined;
|
|
123
|
+
};
|
|
124
|
+
readonly type: "function";
|
|
125
|
+
readonly cache_control?: {
|
|
126
|
+
readonly type: "ephemeral";
|
|
127
|
+
readonly ttl?: string | undefined;
|
|
128
|
+
} | undefined;
|
|
129
|
+
}[] | undefined;
|
|
130
|
+
readonly stop?: readonly string[] | undefined;
|
|
131
|
+
readonly user?: string | undefined;
|
|
132
|
+
readonly temperature?: number | undefined;
|
|
133
|
+
readonly seed?: number | undefined;
|
|
134
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
135
|
+
readonly type: "function";
|
|
136
|
+
readonly function: {
|
|
137
|
+
readonly name: string;
|
|
138
|
+
};
|
|
139
|
+
} | undefined;
|
|
140
|
+
readonly top_p?: number | undefined;
|
|
141
|
+
readonly top_k?: number | undefined;
|
|
142
|
+
readonly frequency_penalty?: number | undefined;
|
|
143
|
+
readonly presence_penalty?: number | undefined;
|
|
144
|
+
readonly store?: boolean | undefined;
|
|
145
|
+
readonly prompt_cache_key?: string | undefined;
|
|
146
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
147
|
+
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
148
|
+
readonly stream_options?: {
|
|
149
|
+
readonly include_usage: boolean;
|
|
150
|
+
} | undefined;
|
|
151
|
+
readonly tool_stream?: boolean | undefined;
|
|
152
|
+
readonly top_logprobs?: number | undefined;
|
|
153
|
+
readonly prompt_cache_retention?: string | undefined;
|
|
154
|
+
readonly repetition_penalty?: number | undefined;
|
|
155
|
+
readonly response_format?: {
|
|
156
|
+
readonly [x: string]: unknown;
|
|
157
|
+
} | undefined;
|
|
158
|
+
readonly logprobs?: boolean | undefined;
|
|
159
|
+
readonly min_p?: number | undefined;
|
|
160
|
+
readonly stop_token_ids?: readonly number[] | undefined;
|
|
161
|
+
readonly max_temp?: number | undefined;
|
|
162
|
+
readonly min_temp?: number | undefined;
|
|
163
|
+
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
|
|
164
|
+
export declare const configure: (input?: Config) => {
|
|
165
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
166
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
167
|
+
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
168
|
+
configure: (input?: Config) => /*elided*/ any;
|
|
169
|
+
};
|
|
170
|
+
export declare const provider: {
|
|
171
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
172
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
173
|
+
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
174
|
+
configure: (input?: Config) => {
|
|
175
|
+
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
176
|
+
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
177
|
+
chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
178
|
+
configure: /*elided*/ any;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<VeniceChat.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
|
|
182
|
+
export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
|
|
183
|
+
export * as Venice from "./venice.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { VeniceChat } from "../protocols/venice-chat.js";
|
|
2
|
+
import { OpenAIChat } from "../protocols/openai-chat.js";
|
|
3
|
+
import { AuthOptions } from "../route/auth-options.js";
|
|
4
|
+
import { Route } from "../route/client.js";
|
|
5
|
+
import { Endpoint } from "../route/endpoint.js";
|
|
6
|
+
import { ProviderID } from "../schema/index.js";
|
|
7
|
+
export const id = ProviderID.make("venice");
|
|
8
|
+
const route = Route.make({
|
|
9
|
+
id: "venice-chat",
|
|
10
|
+
provider: id,
|
|
11
|
+
providerMetadataKey: "venice",
|
|
12
|
+
protocol: VeniceChat.protocol,
|
|
13
|
+
endpoint: Endpoint.path("/chat/completions", { baseURL: "https://api.venice.ai/api/v1" }),
|
|
14
|
+
framing: OpenAIChat.framing,
|
|
15
|
+
});
|
|
16
|
+
export const routes = [route];
|
|
17
|
+
export const configure = (input = {}) => {
|
|
18
|
+
const { apiKey: _apiKey, auth: _auth, baseURL, queryParams, ...rest } = input;
|
|
19
|
+
const chat = (modelID) => route
|
|
20
|
+
.with({
|
|
21
|
+
...rest,
|
|
22
|
+
endpoint: { baseURL: baseURL ?? route.endpoint.baseURL, query: queryParams },
|
|
23
|
+
auth: AuthOptions.bearer(input, "VENICE_API_KEY"),
|
|
24
|
+
})
|
|
25
|
+
.model({ id: modelID, compatibility: VeniceChat.compatibility });
|
|
26
|
+
return { id, model: chat, chat, configure };
|
|
27
|
+
};
|
|
28
|
+
export const provider = configure();
|
|
29
|
+
export const chat = provider.chat;
|
|
30
|
+
export const model = (modelID, { apiKey, baseURL, queryParams, body, headers, ...providerOptions }) => configure({
|
|
31
|
+
apiKey,
|
|
32
|
+
baseURL,
|
|
33
|
+
queryParams,
|
|
34
|
+
headers,
|
|
35
|
+
http: body === undefined ? undefined : { body: { ...body } },
|
|
36
|
+
providerOptions,
|
|
37
|
+
}).model(modelID);
|
|
38
|
+
export * as Venice from "./venice.js";
|
package/dist/providers/xai.d.ts
CHANGED
|
@@ -134,9 +134,9 @@ export declare const routes: (Route<{
|
|
|
134
134
|
readonly top_p?: number | undefined;
|
|
135
135
|
readonly frequency_penalty?: number | undefined;
|
|
136
136
|
readonly presence_penalty?: number | undefined;
|
|
137
|
+
readonly store?: boolean | undefined;
|
|
137
138
|
readonly prompt_cache_key?: string | undefined;
|
|
138
139
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
139
|
-
readonly store?: boolean | undefined;
|
|
140
140
|
readonly stream_options?: {
|
|
141
141
|
readonly include_usage: boolean;
|
|
142
142
|
} | undefined;
|
|
@@ -57,6 +57,15 @@ export declare const routes: (Route<{
|
|
|
57
57
|
readonly error?: unknown;
|
|
58
58
|
readonly arguments?: string | undefined;
|
|
59
59
|
readonly server_label?: string | undefined;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: "configuration_update";
|
|
62
|
+
readonly reasoning: {
|
|
63
|
+
readonly effort: import("../schema/options.js").ReasoningEffort;
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
readonly [x: string]: unknown;
|
|
67
|
+
readonly type: string;
|
|
68
|
+
readonly id: string;
|
|
60
69
|
} | {
|
|
61
70
|
readonly type: "reasoning";
|
|
62
71
|
readonly summary: readonly {
|
|
@@ -144,7 +153,10 @@ export declare const routes: (Route<{
|
|
|
144
153
|
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
145
154
|
readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
146
155
|
} | undefined;
|
|
147
|
-
readonly tools?: readonly {
|
|
156
|
+
readonly tools?: readonly ({
|
|
157
|
+
readonly [x: string]: unknown;
|
|
158
|
+
readonly type: string;
|
|
159
|
+
} | {
|
|
148
160
|
readonly type: "function";
|
|
149
161
|
readonly description: string;
|
|
150
162
|
readonly name: string;
|
|
@@ -152,7 +164,7 @@ export declare const routes: (Route<{
|
|
|
152
164
|
readonly [x: string]: unknown;
|
|
153
165
|
};
|
|
154
166
|
readonly strict?: boolean | undefined;
|
|
155
|
-
}[] | undefined;
|
|
167
|
+
})[] | undefined;
|
|
156
168
|
readonly text?: {
|
|
157
169
|
readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
|
|
158
170
|
} | undefined;
|
|
@@ -172,9 +184,10 @@ export declare const routes: (Route<{
|
|
|
172
184
|
readonly top_p?: number | undefined;
|
|
173
185
|
readonly frequency_penalty?: number | undefined;
|
|
174
186
|
readonly presence_penalty?: number | undefined;
|
|
187
|
+
readonly store?: boolean | undefined;
|
|
188
|
+
readonly max_output_tokens?: number | undefined;
|
|
175
189
|
readonly prompt_cache_key?: string | undefined;
|
|
176
190
|
readonly parallel_tool_calls?: boolean | undefined;
|
|
177
|
-
readonly store?: boolean | undefined;
|
|
178
191
|
readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
179
192
|
readonly truncation?: "auto" | "disabled" | undefined;
|
|
180
193
|
readonly stream_options?: {
|
|
@@ -182,7 +195,6 @@ export declare const routes: (Route<{
|
|
|
182
195
|
} | undefined;
|
|
183
196
|
readonly safety_identifier?: string | undefined;
|
|
184
197
|
readonly top_logprobs?: number | undefined;
|
|
185
|
-
readonly max_output_tokens?: number | undefined;
|
|
186
198
|
readonly max_tool_calls?: number | undefined;
|
|
187
199
|
}, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
|
|
188
200
|
readonly model: string;
|
|
@@ -303,9 +315,9 @@ export declare const routes: (Route<{
|
|
|
303
315
|
readonly top_p?: number | undefined;
|
|
304
316
|
readonly frequency_penalty?: number | undefined;
|
|
305
317
|
readonly presence_penalty?: number | undefined;
|
|
318
|
+
readonly store?: boolean | undefined;
|
|
306
319
|
readonly prompt_cache_key?: string | undefined;
|
|
307
320
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
308
|
-
readonly store?: boolean | undefined;
|
|
309
321
|
readonly stream_options?: {
|
|
310
322
|
readonly include_usage: boolean;
|
|
311
323
|
} | undefined;
|
package/dist/providers/zai.d.ts
CHANGED
|
@@ -133,9 +133,9 @@ export declare const routes: Route<{
|
|
|
133
133
|
readonly top_p?: number | undefined;
|
|
134
134
|
readonly frequency_penalty?: number | undefined;
|
|
135
135
|
readonly presence_penalty?: number | undefined;
|
|
136
|
+
readonly store?: boolean | undefined;
|
|
136
137
|
readonly prompt_cache_key?: string | undefined;
|
|
137
138
|
readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
|
|
138
|
-
readonly store?: boolean | undefined;
|
|
139
139
|
readonly stream_options?: {
|
|
140
140
|
readonly include_usage: boolean;
|
|
141
141
|
} | undefined;
|
package/dist/route/client.d.ts
CHANGED
|
@@ -396,6 +396,8 @@ export declare const streamRequest: (request: LLMRequest, options?: StreamOption
|
|
|
396
396
|
readonly reason: {
|
|
397
397
|
readonly normalized: "length" | "stop" | "tool-calls" | "content-filter" | "error" | "unknown";
|
|
398
398
|
readonly raw?: string | undefined;
|
|
399
|
+
readonly category?: string | undefined;
|
|
400
|
+
readonly explanation?: string | undefined;
|
|
399
401
|
};
|
|
400
402
|
readonly index: number;
|
|
401
403
|
readonly providerMetadata?: {
|
|
@@ -409,6 +411,8 @@ export declare const streamRequest: (request: LLMRequest, options?: StreamOption
|
|
|
409
411
|
readonly reason: {
|
|
410
412
|
readonly normalized: "length" | "stop" | "tool-calls" | "content-filter" | "error" | "unknown";
|
|
411
413
|
readonly raw?: string | undefined;
|
|
414
|
+
readonly category?: string | undefined;
|
|
415
|
+
readonly explanation?: string | undefined;
|
|
412
416
|
};
|
|
413
417
|
readonly providerMetadata?: {
|
|
414
418
|
readonly [x: string]: {
|
package/dist/route/client.js
CHANGED
|
@@ -102,7 +102,6 @@ const requireTerminalEvent = (route) => (events) => Stream.suspend(() => {
|
|
|
102
102
|
});
|
|
103
103
|
function makeFromTransport(input) {
|
|
104
104
|
const protocol = input.protocol;
|
|
105
|
-
const encodeBody = Schema.encodeSync(Schema.fromJsonString(protocol.body.schema));
|
|
106
105
|
const decodeEventEffect = Schema.decodeUnknownEffect(protocol.stream.event);
|
|
107
106
|
const decodeEvent = (route) => (frame) => decodeEventEffect(frame).pipe(Effect.mapError((cause) => ProviderShared.eventError(input.id, `Invalid ${route} stream event`, typeof frame === "string" ? frame : ProviderShared.encodeJson(frame), cause)));
|
|
108
107
|
const build = (routeInput) => {
|
|
@@ -143,7 +142,7 @@ function makeFromTransport(input) {
|
|
|
143
142
|
request,
|
|
144
143
|
endpoint: routeInput.endpoint,
|
|
145
144
|
auth: routeInput.auth ?? Auth.none,
|
|
146
|
-
encodeBody,
|
|
145
|
+
encodeBody: ProviderShared.encodeJson,
|
|
147
146
|
middleware: options?.http,
|
|
148
147
|
webSocket: options?.webSocket,
|
|
149
148
|
}),
|
|
@@ -221,9 +220,7 @@ const prepareRequest = (request) => {
|
|
|
221
220
|
const compile = Effect.fn("LLM.compile")(function* (request, options) {
|
|
222
221
|
const resolved = prepareRequest(request);
|
|
223
222
|
const route = resolved.model.route;
|
|
224
|
-
const body = yield* route.body
|
|
225
|
-
.from(resolved)
|
|
226
|
-
.pipe(Effect.flatMap(ProviderShared.validateWith(Schema.decodeUnknownEffect(route.body.schema))));
|
|
223
|
+
const body = yield* route.body.from(resolved);
|
|
227
224
|
const prepared = yield* route.prepareTransport(body, resolved, options);
|
|
228
225
|
return {
|
|
229
226
|
request: resolved,
|
package/dist/route/executor.js
CHANGED
|
@@ -128,6 +128,12 @@ const nativeTransportFailure = (error) => {
|
|
|
128
128
|
return cause;
|
|
129
129
|
return failure;
|
|
130
130
|
};
|
|
131
|
+
// HTTP hooks re-wrap response bodies, so a read failure can arrive as an HttpClientError caused by
|
|
132
|
+
// another HttpClientError. The innermost cause carries the native failure.
|
|
133
|
+
const rootCause = (error) => HttpClientError.isHttpClientError(error) && "cause" in error.reason && error.reason.cause !== undefined
|
|
134
|
+
? rootCause(error.reason.cause)
|
|
135
|
+
: error;
|
|
136
|
+
const CONNECTION_LOST = "Connection lost while reading the response";
|
|
131
137
|
const httpError = (input) => {
|
|
132
138
|
const request = HttpClientError.isHttpClientError(input.error) ? input.error.request : input.request;
|
|
133
139
|
const transportError = (failure) => new AIError({
|
|
@@ -141,18 +147,19 @@ const httpError = (input) => {
|
|
|
141
147
|
url: request.url,
|
|
142
148
|
}),
|
|
143
149
|
});
|
|
144
|
-
const source =
|
|
145
|
-
? (input.error.reason.cause ?? input.error)
|
|
146
|
-
: input.error;
|
|
150
|
+
const source = rootCause(input.error);
|
|
147
151
|
const native = nativeTransportFailure(source);
|
|
148
152
|
const code = native?.code;
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const message = code && detail && !detail.includes(code) ? `${code}: ${detail}` : detail;
|
|
153
|
+
const detail = code && native?.message && !native.message.includes(code) ? `${code}: ${native.message}` : native?.message;
|
|
154
|
+
const message = detail ?? (input.error instanceof Error ? input.error.message : undefined);
|
|
152
155
|
if (Cause.isTimeoutError(input.error) || Cause.isTimeoutError(source))
|
|
153
156
|
return transportError({ message: message ?? "HTTP transport timed out", code: code ?? "Timeout" });
|
|
154
157
|
if (!HttpClientError.isHttpClientError(input.error))
|
|
155
158
|
return transportError({ message: message ?? "HTTP transport failed", code });
|
|
159
|
+
// Effect reports every response body read failure as a DecodeError, but the raw byte stream decodes
|
|
160
|
+
// nothing: provider output parsing happens later and fails as InvalidProviderOutput.
|
|
161
|
+
if (input.operation === "read" && input.error.reason._tag === "DecodeError")
|
|
162
|
+
return transportError({ message: detail ? `${CONNECTION_LOST}: ${detail}` : CONNECTION_LOST, code });
|
|
156
163
|
if (input.error.reason._tag === "TransportError") {
|
|
157
164
|
return transportError({
|
|
158
165
|
message: message ?? input.error.reason.description ?? "HTTP transport failed",
|