@opencode/ai 0.0.0-dev-19618 → 0.0.0-dev-19620

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.
@@ -1,7 +1,7 @@
1
- import type { Config, Redacted } from "effect";
1
+ import { type Config, type Redacted } from "effect";
2
2
  import type { ProviderPackage } from "../provider-package.js";
3
3
  import type { AtLeastOne, ProviderAuthOption } from "../route/auth-options.js";
4
- import { Route, type RouteDefaultsInput } from "../route/client.js";
4
+ import type { RouteDefaultsInput } from "../route/client.js";
5
5
  import { type ModelID } from "../schema/index.js";
6
6
  import type { OpenAIProviderOptionsInput } from "./openai-options.js";
7
7
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -9,20 +9,527 @@ export declare const authEnvVars: readonly ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKE
9
9
  type GatewayURL = AtLeastOne<{
10
10
  readonly accountId: string;
11
11
  readonly baseURL: string;
12
- }> & {
12
+ }>;
13
+ type GatewayOptions = {
13
14
  readonly gatewayId?: string;
15
+ readonly metadata?: unknown;
16
+ readonly cacheTtl?: number;
17
+ readonly cacheKey?: string;
18
+ readonly skipCache?: boolean;
19
+ readonly collectLog?: boolean;
14
20
  };
15
- export type LanguageModelOptions = GatewayURL & Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
16
- /** Cloudflare AI Gateway authentication token. Sent as `cf-aig-authorization`. */
21
+ export type LanguageModelOptions = GatewayURL & GatewayOptions & Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
17
22
  readonly gatewayApiKey?: string | Redacted.Redacted | Config.Config<string | Redacted.Redacted>;
18
23
  readonly providerOptions?: OpenAIProviderOptionsInput;
19
24
  };
20
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & GatewayURL & {
25
+ export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & GatewayURL & GatewayOptions & {
21
26
  readonly apiKey?: string;
22
27
  readonly gatewayApiKey?: string;
23
28
  };
24
29
  export declare const baseURL: (input: GatewayURL) => string;
25
- export declare const route: Route<{
30
+ export declare const responsesRoute: import("../route/client.js").Route<{
31
+ readonly input: readonly ({
32
+ readonly [x: string]: unknown;
33
+ readonly id: string;
34
+ readonly type: "web_search_call";
35
+ readonly status?: string | undefined;
36
+ readonly action?: {
37
+ readonly [x: string]: unknown;
38
+ } | null | undefined;
39
+ } | {
40
+ readonly [x: string]: unknown;
41
+ readonly id: string;
42
+ readonly type: "file_search_call";
43
+ readonly status?: string | undefined;
44
+ readonly queries?: readonly string[] | undefined;
45
+ readonly results?: readonly {
46
+ readonly [x: string]: unknown;
47
+ }[] | null | undefined;
48
+ } | {
49
+ readonly [x: string]: unknown;
50
+ readonly id: string;
51
+ readonly type: "code_interpreter_call";
52
+ readonly status?: string | undefined;
53
+ readonly code?: string | null | undefined;
54
+ readonly container_id?: string | null | undefined;
55
+ readonly outputs?: readonly {
56
+ readonly [x: string]: unknown;
57
+ }[] | null | undefined;
58
+ } | {
59
+ readonly [x: string]: unknown;
60
+ readonly id: string;
61
+ readonly type: "mcp_call";
62
+ readonly status?: string | undefined;
63
+ readonly name?: string | undefined;
64
+ readonly output?: string | null | undefined;
65
+ readonly error?: unknown;
66
+ readonly arguments?: string | undefined;
67
+ readonly server_label?: string | undefined;
68
+ } | {
69
+ readonly type: "configuration_update";
70
+ readonly reasoning: {
71
+ readonly effort: import("../schema/options.js").ReasoningEffort;
72
+ };
73
+ } | {
74
+ readonly type: "reasoning";
75
+ readonly summary: readonly {
76
+ readonly type: "summary_text";
77
+ readonly text: string;
78
+ }[];
79
+ readonly id?: string | undefined;
80
+ readonly encrypted_content?: string | null | undefined;
81
+ } | {
82
+ readonly type: "compaction";
83
+ readonly encrypted_content: string;
84
+ readonly id?: string | null | undefined;
85
+ } | {
86
+ readonly role: "system";
87
+ readonly content: string;
88
+ } | {
89
+ readonly role: "developer";
90
+ readonly content: string;
91
+ } | {
92
+ readonly content: readonly ({
93
+ readonly type: "input_image";
94
+ readonly image_url: string;
95
+ readonly detail?: string | undefined;
96
+ } | {
97
+ readonly type: "input_file";
98
+ readonly filename: string;
99
+ readonly detail?: string | undefined;
100
+ readonly file_data?: string | undefined;
101
+ readonly file_url?: string | undefined;
102
+ } | {
103
+ readonly type: "input_text";
104
+ readonly text: string;
105
+ })[];
106
+ readonly role: "user";
107
+ readonly id?: string | undefined;
108
+ readonly type?: "message" | undefined;
109
+ readonly status?: string | undefined;
110
+ } | {
111
+ readonly type: "message";
112
+ readonly content: readonly {
113
+ readonly type: "output_text";
114
+ readonly text: string;
115
+ }[];
116
+ readonly role: "assistant";
117
+ readonly id?: string | undefined;
118
+ readonly status?: string | undefined;
119
+ readonly phase?: "commentary" | "final_answer" | null | undefined;
120
+ } | {
121
+ readonly type: "function_call";
122
+ readonly name: string;
123
+ readonly arguments: string;
124
+ readonly call_id: string;
125
+ readonly id?: string | undefined;
126
+ readonly namespace?: string | undefined;
127
+ } | {
128
+ readonly type: "function_call_output";
129
+ readonly call_id: string;
130
+ readonly output: string | readonly ({
131
+ readonly type: "input_image";
132
+ readonly image_url: string;
133
+ readonly detail?: string | undefined;
134
+ } | {
135
+ readonly type: "input_file";
136
+ readonly filename: string;
137
+ readonly detail?: string | undefined;
138
+ readonly file_data?: string | undefined;
139
+ readonly file_url?: string | undefined;
140
+ } | {
141
+ readonly type: "input_text";
142
+ readonly text: string;
143
+ } | {
144
+ readonly type: "input_video";
145
+ readonly video_url: string;
146
+ })[];
147
+ } | {
148
+ readonly [x: string]: unknown;
149
+ readonly id: string;
150
+ readonly type: "computer_call";
151
+ readonly status?: string | undefined;
152
+ readonly action?: {
153
+ readonly [x: string]: unknown;
154
+ } | null | undefined;
155
+ readonly call_id?: string | undefined;
156
+ readonly pending_safety_checks?: readonly {
157
+ readonly [x: string]: unknown;
158
+ }[] | undefined;
159
+ } | {
160
+ readonly [x: string]: unknown;
161
+ readonly id: string;
162
+ readonly type: "web_search_preview_call";
163
+ readonly status?: string | undefined;
164
+ readonly action?: {
165
+ readonly [x: string]: unknown;
166
+ } | null | undefined;
167
+ } | {
168
+ readonly [x: string]: unknown;
169
+ readonly id: string;
170
+ readonly type: "image_generation_call";
171
+ readonly status?: string | undefined;
172
+ readonly result?: string | null | undefined;
173
+ readonly revised_prompt?: string | null | undefined;
174
+ readonly output_format?: "png" | "jpeg" | "webp" | undefined;
175
+ })[];
176
+ readonly model: string;
177
+ readonly stream: true;
178
+ readonly metadata?: {
179
+ readonly [x: string]: string;
180
+ } | undefined;
181
+ readonly instructions?: string | undefined;
182
+ readonly reasoning?: {
183
+ readonly summary?: "auto" | "concise" | "detailed" | undefined;
184
+ readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
185
+ } | undefined;
186
+ readonly tools?: readonly ({
187
+ readonly type: "function";
188
+ readonly description: string;
189
+ readonly name: string;
190
+ readonly parameters: {
191
+ readonly [x: string]: unknown;
192
+ };
193
+ readonly strict?: boolean | undefined;
194
+ } | {
195
+ readonly type: "image_generation";
196
+ readonly size?: string | undefined;
197
+ readonly action?: "generate" | "auto" | "edit" | undefined;
198
+ readonly output_format?: "png" | "jpeg" | "webp" | undefined;
199
+ readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
200
+ readonly background?: "auto" | "opaque" | "transparent" | undefined;
201
+ readonly output_compression?: number | undefined;
202
+ readonly input_fidelity?: "low" | "high" | undefined;
203
+ readonly partial_images?: number | undefined;
204
+ } | {
205
+ readonly type: "namespace";
206
+ readonly name: string;
207
+ readonly description: string;
208
+ readonly tools: readonly {
209
+ readonly type: "function";
210
+ readonly description: string;
211
+ readonly name: string;
212
+ readonly parameters: {
213
+ readonly [x: string]: unknown;
214
+ };
215
+ readonly strict?: boolean | undefined;
216
+ }[];
217
+ })[] | undefined;
218
+ readonly text?: {
219
+ readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
220
+ } | undefined;
221
+ readonly temperature?: number | undefined;
222
+ readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
223
+ readonly context_management?: readonly {
224
+ readonly type: "compaction";
225
+ readonly compact_threshold?: number | undefined;
226
+ }[] | undefined;
227
+ readonly tool_choice?: "required" | "auto" | "none" | {
228
+ readonly type: "function";
229
+ readonly name: string;
230
+ } | {
231
+ readonly type: "allowed_tools";
232
+ readonly mode: "required" | "auto" | "none";
233
+ readonly tools: readonly {
234
+ readonly type: "function";
235
+ readonly name: string;
236
+ }[];
237
+ } | {
238
+ readonly type: "image_generation";
239
+ } | undefined;
240
+ readonly top_p?: number | undefined;
241
+ readonly frequency_penalty?: number | undefined;
242
+ readonly presence_penalty?: number | undefined;
243
+ readonly prompt_cache_key?: string | undefined;
244
+ readonly parallel_tool_calls?: boolean | undefined;
245
+ readonly store?: boolean | undefined;
246
+ readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
247
+ readonly truncation?: "auto" | "disabled" | undefined;
248
+ readonly stream_options?: {
249
+ readonly include_obfuscation?: boolean | undefined;
250
+ } | undefined;
251
+ readonly safety_identifier?: string | undefined;
252
+ readonly top_logprobs?: number | undefined;
253
+ readonly max_output_tokens?: number | undefined;
254
+ readonly max_tool_calls?: number | undefined;
255
+ }, import("../protocols/open-responses-channel.js").Prepared, {
256
+ endpoint: import("../route/client.js").CompactOperation;
257
+ trigger: import("../route/client.js").TriggerCompactOperation;
258
+ }>;
259
+ export declare const messagesRoute: import("../route/client.js").Route<{
260
+ readonly max_tokens: number;
261
+ readonly model: string;
262
+ readonly messages: readonly ({
263
+ readonly role: "user";
264
+ readonly content: readonly ({
265
+ readonly type: "text";
266
+ readonly text: string;
267
+ readonly cache_control?: {
268
+ readonly type: "ephemeral";
269
+ readonly ttl?: "1h" | "5m" | undefined;
270
+ } | undefined;
271
+ } | {
272
+ readonly type: "image";
273
+ readonly source: {
274
+ readonly type: "base64";
275
+ readonly media_type: string;
276
+ readonly data: string;
277
+ } | {
278
+ readonly type: "url";
279
+ readonly url: string;
280
+ } | {
281
+ readonly type: "file";
282
+ readonly file_id: string;
283
+ };
284
+ readonly cache_control?: {
285
+ readonly type: "ephemeral";
286
+ readonly ttl?: "1h" | "5m" | undefined;
287
+ } | undefined;
288
+ readonly transformations?: {
289
+ readonly oversized_image?: "error" | "downsize" | undefined;
290
+ } | undefined;
291
+ } | {
292
+ readonly type: "document";
293
+ readonly source: {
294
+ readonly type: "base64";
295
+ readonly media_type: "application/pdf";
296
+ readonly data: string;
297
+ } | {
298
+ readonly type: "text";
299
+ readonly media_type: "text/plain";
300
+ readonly data: string;
301
+ } | {
302
+ readonly type: "url";
303
+ readonly url: string;
304
+ } | {
305
+ readonly type: "file";
306
+ readonly file_id: string;
307
+ };
308
+ readonly title?: string | undefined;
309
+ readonly context?: string | undefined;
310
+ readonly cache_control?: {
311
+ readonly type: "ephemeral";
312
+ readonly ttl?: "1h" | "5m" | undefined;
313
+ } | undefined;
314
+ readonly citations?: {
315
+ readonly enabled: boolean;
316
+ } | undefined;
317
+ } | {
318
+ readonly type: "tool_result";
319
+ readonly content: string | readonly ({
320
+ readonly type: "text";
321
+ readonly text: string;
322
+ readonly cache_control?: {
323
+ readonly type: "ephemeral";
324
+ readonly ttl?: "1h" | "5m" | undefined;
325
+ } | undefined;
326
+ } | {
327
+ readonly type: "image";
328
+ readonly source: {
329
+ readonly type: "base64";
330
+ readonly media_type: string;
331
+ readonly data: string;
332
+ } | {
333
+ readonly type: "url";
334
+ readonly url: string;
335
+ } | {
336
+ readonly type: "file";
337
+ readonly file_id: string;
338
+ };
339
+ readonly cache_control?: {
340
+ readonly type: "ephemeral";
341
+ readonly ttl?: "1h" | "5m" | undefined;
342
+ } | undefined;
343
+ readonly transformations?: {
344
+ readonly oversized_image?: "error" | "downsize" | undefined;
345
+ } | undefined;
346
+ } | {
347
+ readonly type: "document";
348
+ readonly source: {
349
+ readonly type: "base64";
350
+ readonly media_type: "application/pdf";
351
+ readonly data: string;
352
+ } | {
353
+ readonly type: "text";
354
+ readonly media_type: "text/plain";
355
+ readonly data: string;
356
+ } | {
357
+ readonly type: "url";
358
+ readonly url: string;
359
+ } | {
360
+ readonly type: "file";
361
+ readonly file_id: string;
362
+ };
363
+ readonly title?: string | undefined;
364
+ readonly context?: string | undefined;
365
+ readonly cache_control?: {
366
+ readonly type: "ephemeral";
367
+ readonly ttl?: "1h" | "5m" | undefined;
368
+ } | undefined;
369
+ readonly citations?: {
370
+ readonly enabled: boolean;
371
+ } | undefined;
372
+ })[];
373
+ readonly tool_use_id: string;
374
+ readonly cache_control?: {
375
+ readonly type: "ephemeral";
376
+ readonly ttl?: "1h" | "5m" | undefined;
377
+ } | undefined;
378
+ readonly is_error?: boolean | undefined;
379
+ })[];
380
+ } | {
381
+ readonly role: "assistant";
382
+ readonly content: readonly ({
383
+ readonly type: "text";
384
+ readonly text: string;
385
+ readonly cache_control?: {
386
+ readonly type: "ephemeral";
387
+ readonly ttl?: "1h" | "5m" | undefined;
388
+ } | undefined;
389
+ } | {
390
+ readonly id: string;
391
+ readonly type: "tool_use";
392
+ readonly name: string;
393
+ readonly input: unknown;
394
+ readonly cache_control?: {
395
+ readonly type: "ephemeral";
396
+ readonly ttl?: "1h" | "5m" | undefined;
397
+ } | undefined;
398
+ } | {
399
+ readonly id: string;
400
+ readonly type: "server_tool_use";
401
+ readonly name: string;
402
+ readonly input: unknown;
403
+ readonly cache_control?: {
404
+ readonly type: "ephemeral";
405
+ readonly ttl?: "1h" | "5m" | undefined;
406
+ } | undefined;
407
+ } | {
408
+ readonly type: "web_search_tool_result" | "code_execution_tool_result" | "web_fetch_tool_result";
409
+ readonly content: unknown;
410
+ readonly tool_use_id: string;
411
+ readonly cache_control?: {
412
+ readonly type: "ephemeral";
413
+ readonly ttl?: "1h" | "5m" | undefined;
414
+ } | undefined;
415
+ } | {
416
+ readonly type: "thinking";
417
+ readonly thinking: string;
418
+ readonly signature: string;
419
+ readonly cache_control?: {
420
+ readonly type: "ephemeral";
421
+ readonly ttl?: "1h" | "5m" | undefined;
422
+ } | undefined;
423
+ } | {
424
+ readonly data: string;
425
+ readonly type: "redacted_thinking";
426
+ readonly cache_control?: {
427
+ readonly type: "ephemeral";
428
+ readonly ttl?: "1h" | "5m" | undefined;
429
+ } | undefined;
430
+ } | {
431
+ readonly type: "compaction";
432
+ readonly content: string | null;
433
+ })[];
434
+ } | {
435
+ readonly content: readonly {
436
+ readonly type: "text";
437
+ readonly text: string;
438
+ readonly cache_control?: {
439
+ readonly type: "ephemeral";
440
+ readonly ttl?: "1h" | "5m" | undefined;
441
+ } | undefined;
442
+ }[];
443
+ readonly role: "system";
444
+ readonly output_config?: {
445
+ readonly effort: string;
446
+ } | undefined;
447
+ })[];
448
+ readonly stream: true;
449
+ readonly metadata?: {
450
+ readonly user_id?: string | null | undefined;
451
+ } | undefined;
452
+ readonly tools?: readonly {
453
+ readonly description: string;
454
+ readonly name: string;
455
+ readonly input_schema: {
456
+ readonly [x: string]: unknown;
457
+ };
458
+ readonly cache_control?: {
459
+ readonly type: "ephemeral";
460
+ readonly ttl?: "1h" | "5m" | undefined;
461
+ } | undefined;
462
+ }[] | undefined;
463
+ readonly system?: readonly {
464
+ readonly type: "text";
465
+ readonly text: string;
466
+ readonly cache_control?: {
467
+ readonly type: "ephemeral";
468
+ readonly ttl?: "1h" | "5m" | undefined;
469
+ } | undefined;
470
+ }[] | undefined;
471
+ readonly temperature?: number | undefined;
472
+ readonly thinking?: {
473
+ readonly type: "enabled";
474
+ readonly budget_tokens: number;
475
+ readonly display?: "summarized" | "omitted" | undefined;
476
+ readonly block_binding?: {
477
+ readonly prefix_mismatch_behavior?: string | undefined;
478
+ } | undefined;
479
+ } | {
480
+ readonly type: "adaptive";
481
+ readonly display?: "summarized" | "omitted" | undefined;
482
+ readonly block_binding?: {
483
+ readonly prefix_mismatch_behavior?: string | undefined;
484
+ } | undefined;
485
+ } | {
486
+ readonly type: "disabled";
487
+ } | undefined;
488
+ readonly service_tier?: "auto" | "standard_only" | undefined;
489
+ readonly container?: string | {
490
+ readonly id?: string | null | undefined;
491
+ readonly skills?: readonly {
492
+ readonly [x: string]: unknown;
493
+ }[] | null | undefined;
494
+ } | null | undefined;
495
+ readonly inference_geo?: string | null | undefined;
496
+ readonly cache_control?: {
497
+ readonly type: "ephemeral";
498
+ readonly ttl?: "1h" | "5m" | undefined;
499
+ } | undefined;
500
+ readonly output_config?: {
501
+ readonly format?: {
502
+ readonly type: "json_schema";
503
+ readonly schema: {
504
+ readonly [x: string]: unknown;
505
+ };
506
+ } | null | undefined;
507
+ readonly effort?: string | undefined;
508
+ } | undefined;
509
+ readonly context_management?: {
510
+ readonly edits: readonly {
511
+ readonly type: "compact_20260112";
512
+ readonly instructions?: string | undefined;
513
+ readonly trigger?: {
514
+ readonly type: "input_tokens";
515
+ readonly value: number;
516
+ } | undefined;
517
+ readonly pause_after_compaction?: boolean | undefined;
518
+ }[];
519
+ } | undefined;
520
+ readonly tool_choice?: {
521
+ readonly type: "auto" | "none" | "any";
522
+ readonly disable_parallel_tool_use?: boolean | undefined;
523
+ } | {
524
+ readonly type: "tool";
525
+ readonly name: string;
526
+ readonly disable_parallel_tool_use?: boolean | undefined;
527
+ } | undefined;
528
+ readonly top_p?: number | undefined;
529
+ readonly top_k?: number | undefined;
530
+ readonly stop_sequences?: readonly string[] | undefined;
531
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>;
532
+ export declare const route: import("../route/client.js").Route<{
26
533
  readonly model: string;
27
534
  readonly messages: readonly ({
28
535
  readonly role: "system";
@@ -121,7 +628,279 @@ export declare const route: Route<{
121
628
  } | undefined;
122
629
  readonly tool_stream?: boolean | undefined;
123
630
  }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>;
124
- export declare const routes: Route<{
631
+ export declare const routes: (import("../route/client.js").Route<{
632
+ readonly max_tokens: number;
633
+ readonly model: string;
634
+ readonly messages: readonly ({
635
+ readonly role: "user";
636
+ readonly content: readonly ({
637
+ readonly type: "text";
638
+ readonly text: string;
639
+ readonly cache_control?: {
640
+ readonly type: "ephemeral";
641
+ readonly ttl?: "1h" | "5m" | undefined;
642
+ } | undefined;
643
+ } | {
644
+ readonly type: "image";
645
+ readonly source: {
646
+ readonly type: "base64";
647
+ readonly media_type: string;
648
+ readonly data: string;
649
+ } | {
650
+ readonly type: "url";
651
+ readonly url: string;
652
+ } | {
653
+ readonly type: "file";
654
+ readonly file_id: string;
655
+ };
656
+ readonly cache_control?: {
657
+ readonly type: "ephemeral";
658
+ readonly ttl?: "1h" | "5m" | undefined;
659
+ } | undefined;
660
+ readonly transformations?: {
661
+ readonly oversized_image?: "error" | "downsize" | undefined;
662
+ } | undefined;
663
+ } | {
664
+ readonly type: "document";
665
+ readonly source: {
666
+ readonly type: "base64";
667
+ readonly media_type: "application/pdf";
668
+ readonly data: string;
669
+ } | {
670
+ readonly type: "text";
671
+ readonly media_type: "text/plain";
672
+ readonly data: string;
673
+ } | {
674
+ readonly type: "url";
675
+ readonly url: string;
676
+ } | {
677
+ readonly type: "file";
678
+ readonly file_id: string;
679
+ };
680
+ readonly title?: string | undefined;
681
+ readonly context?: string | undefined;
682
+ readonly cache_control?: {
683
+ readonly type: "ephemeral";
684
+ readonly ttl?: "1h" | "5m" | undefined;
685
+ } | undefined;
686
+ readonly citations?: {
687
+ readonly enabled: boolean;
688
+ } | undefined;
689
+ } | {
690
+ readonly type: "tool_result";
691
+ readonly content: string | readonly ({
692
+ readonly type: "text";
693
+ readonly text: string;
694
+ readonly cache_control?: {
695
+ readonly type: "ephemeral";
696
+ readonly ttl?: "1h" | "5m" | undefined;
697
+ } | undefined;
698
+ } | {
699
+ readonly type: "image";
700
+ readonly source: {
701
+ readonly type: "base64";
702
+ readonly media_type: string;
703
+ readonly data: string;
704
+ } | {
705
+ readonly type: "url";
706
+ readonly url: string;
707
+ } | {
708
+ readonly type: "file";
709
+ readonly file_id: string;
710
+ };
711
+ readonly cache_control?: {
712
+ readonly type: "ephemeral";
713
+ readonly ttl?: "1h" | "5m" | undefined;
714
+ } | undefined;
715
+ readonly transformations?: {
716
+ readonly oversized_image?: "error" | "downsize" | undefined;
717
+ } | undefined;
718
+ } | {
719
+ readonly type: "document";
720
+ readonly source: {
721
+ readonly type: "base64";
722
+ readonly media_type: "application/pdf";
723
+ readonly data: string;
724
+ } | {
725
+ readonly type: "text";
726
+ readonly media_type: "text/plain";
727
+ readonly data: string;
728
+ } | {
729
+ readonly type: "url";
730
+ readonly url: string;
731
+ } | {
732
+ readonly type: "file";
733
+ readonly file_id: string;
734
+ };
735
+ readonly title?: string | undefined;
736
+ readonly context?: string | undefined;
737
+ readonly cache_control?: {
738
+ readonly type: "ephemeral";
739
+ readonly ttl?: "1h" | "5m" | undefined;
740
+ } | undefined;
741
+ readonly citations?: {
742
+ readonly enabled: boolean;
743
+ } | undefined;
744
+ })[];
745
+ readonly tool_use_id: string;
746
+ readonly cache_control?: {
747
+ readonly type: "ephemeral";
748
+ readonly ttl?: "1h" | "5m" | undefined;
749
+ } | undefined;
750
+ readonly is_error?: boolean | undefined;
751
+ })[];
752
+ } | {
753
+ readonly role: "assistant";
754
+ readonly content: readonly ({
755
+ readonly type: "text";
756
+ readonly text: string;
757
+ readonly cache_control?: {
758
+ readonly type: "ephemeral";
759
+ readonly ttl?: "1h" | "5m" | undefined;
760
+ } | undefined;
761
+ } | {
762
+ readonly id: string;
763
+ readonly type: "tool_use";
764
+ readonly name: string;
765
+ readonly input: unknown;
766
+ readonly cache_control?: {
767
+ readonly type: "ephemeral";
768
+ readonly ttl?: "1h" | "5m" | undefined;
769
+ } | undefined;
770
+ } | {
771
+ readonly id: string;
772
+ readonly type: "server_tool_use";
773
+ readonly name: string;
774
+ readonly input: unknown;
775
+ readonly cache_control?: {
776
+ readonly type: "ephemeral";
777
+ readonly ttl?: "1h" | "5m" | undefined;
778
+ } | undefined;
779
+ } | {
780
+ readonly type: "web_search_tool_result" | "code_execution_tool_result" | "web_fetch_tool_result";
781
+ readonly content: unknown;
782
+ readonly tool_use_id: string;
783
+ readonly cache_control?: {
784
+ readonly type: "ephemeral";
785
+ readonly ttl?: "1h" | "5m" | undefined;
786
+ } | undefined;
787
+ } | {
788
+ readonly type: "thinking";
789
+ readonly thinking: string;
790
+ readonly signature: string;
791
+ readonly cache_control?: {
792
+ readonly type: "ephemeral";
793
+ readonly ttl?: "1h" | "5m" | undefined;
794
+ } | undefined;
795
+ } | {
796
+ readonly data: string;
797
+ readonly type: "redacted_thinking";
798
+ readonly cache_control?: {
799
+ readonly type: "ephemeral";
800
+ readonly ttl?: "1h" | "5m" | undefined;
801
+ } | undefined;
802
+ } | {
803
+ readonly type: "compaction";
804
+ readonly content: string | null;
805
+ })[];
806
+ } | {
807
+ readonly content: readonly {
808
+ readonly type: "text";
809
+ readonly text: string;
810
+ readonly cache_control?: {
811
+ readonly type: "ephemeral";
812
+ readonly ttl?: "1h" | "5m" | undefined;
813
+ } | undefined;
814
+ }[];
815
+ readonly role: "system";
816
+ readonly output_config?: {
817
+ readonly effort: string;
818
+ } | undefined;
819
+ })[];
820
+ readonly stream: true;
821
+ readonly metadata?: {
822
+ readonly user_id?: string | null | undefined;
823
+ } | undefined;
824
+ readonly tools?: readonly {
825
+ readonly description: string;
826
+ readonly name: string;
827
+ readonly input_schema: {
828
+ readonly [x: string]: unknown;
829
+ };
830
+ readonly cache_control?: {
831
+ readonly type: "ephemeral";
832
+ readonly ttl?: "1h" | "5m" | undefined;
833
+ } | undefined;
834
+ }[] | undefined;
835
+ readonly system?: readonly {
836
+ readonly type: "text";
837
+ readonly text: string;
838
+ readonly cache_control?: {
839
+ readonly type: "ephemeral";
840
+ readonly ttl?: "1h" | "5m" | undefined;
841
+ } | undefined;
842
+ }[] | undefined;
843
+ readonly temperature?: number | undefined;
844
+ readonly thinking?: {
845
+ readonly type: "enabled";
846
+ readonly budget_tokens: number;
847
+ readonly display?: "summarized" | "omitted" | undefined;
848
+ readonly block_binding?: {
849
+ readonly prefix_mismatch_behavior?: string | undefined;
850
+ } | undefined;
851
+ } | {
852
+ readonly type: "adaptive";
853
+ readonly display?: "summarized" | "omitted" | undefined;
854
+ readonly block_binding?: {
855
+ readonly prefix_mismatch_behavior?: string | undefined;
856
+ } | undefined;
857
+ } | {
858
+ readonly type: "disabled";
859
+ } | undefined;
860
+ readonly service_tier?: "auto" | "standard_only" | undefined;
861
+ readonly container?: string | {
862
+ readonly id?: string | null | undefined;
863
+ readonly skills?: readonly {
864
+ readonly [x: string]: unknown;
865
+ }[] | null | undefined;
866
+ } | null | undefined;
867
+ readonly inference_geo?: string | null | undefined;
868
+ readonly cache_control?: {
869
+ readonly type: "ephemeral";
870
+ readonly ttl?: "1h" | "5m" | undefined;
871
+ } | undefined;
872
+ readonly output_config?: {
873
+ readonly format?: {
874
+ readonly type: "json_schema";
875
+ readonly schema: {
876
+ readonly [x: string]: unknown;
877
+ };
878
+ } | null | undefined;
879
+ readonly effort?: string | undefined;
880
+ } | undefined;
881
+ readonly context_management?: {
882
+ readonly edits: readonly {
883
+ readonly type: "compact_20260112";
884
+ readonly instructions?: string | undefined;
885
+ readonly trigger?: {
886
+ readonly type: "input_tokens";
887
+ readonly value: number;
888
+ } | undefined;
889
+ readonly pause_after_compaction?: boolean | undefined;
890
+ }[];
891
+ } | undefined;
892
+ readonly tool_choice?: {
893
+ readonly type: "auto" | "none" | "any";
894
+ readonly disable_parallel_tool_use?: boolean | undefined;
895
+ } | {
896
+ readonly type: "tool";
897
+ readonly name: string;
898
+ readonly disable_parallel_tool_use?: boolean | undefined;
899
+ } | undefined;
900
+ readonly top_p?: number | undefined;
901
+ readonly top_k?: number | undefined;
902
+ readonly stop_sequences?: readonly string[] | undefined;
903
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | import("../route/client.js").Route<{
125
904
  readonly model: string;
126
905
  readonly messages: readonly ({
127
906
  readonly role: "system";
@@ -219,17 +998,245 @@ export declare const routes: Route<{
219
998
  readonly include_usage: boolean;
220
999
  } | undefined;
221
1000
  readonly tool_stream?: boolean | undefined;
222
- }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
1001
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | import("../route/client.js").Route<{
1002
+ readonly input: readonly ({
1003
+ readonly [x: string]: unknown;
1004
+ readonly id: string;
1005
+ readonly type: "web_search_call";
1006
+ readonly status?: string | undefined;
1007
+ readonly action?: {
1008
+ readonly [x: string]: unknown;
1009
+ } | null | undefined;
1010
+ } | {
1011
+ readonly [x: string]: unknown;
1012
+ readonly id: string;
1013
+ readonly type: "file_search_call";
1014
+ readonly status?: string | undefined;
1015
+ readonly queries?: readonly string[] | undefined;
1016
+ readonly results?: readonly {
1017
+ readonly [x: string]: unknown;
1018
+ }[] | null | undefined;
1019
+ } | {
1020
+ readonly [x: string]: unknown;
1021
+ readonly id: string;
1022
+ readonly type: "code_interpreter_call";
1023
+ readonly status?: string | undefined;
1024
+ readonly code?: string | null | undefined;
1025
+ readonly container_id?: string | null | undefined;
1026
+ readonly outputs?: readonly {
1027
+ readonly [x: string]: unknown;
1028
+ }[] | null | undefined;
1029
+ } | {
1030
+ readonly [x: string]: unknown;
1031
+ readonly id: string;
1032
+ readonly type: "mcp_call";
1033
+ readonly status?: string | undefined;
1034
+ readonly name?: string | undefined;
1035
+ readonly output?: string | null | undefined;
1036
+ readonly error?: unknown;
1037
+ readonly arguments?: string | undefined;
1038
+ readonly server_label?: string | undefined;
1039
+ } | {
1040
+ readonly type: "configuration_update";
1041
+ readonly reasoning: {
1042
+ readonly effort: import("../schema/options.js").ReasoningEffort;
1043
+ };
1044
+ } | {
1045
+ readonly type: "reasoning";
1046
+ readonly summary: readonly {
1047
+ readonly type: "summary_text";
1048
+ readonly text: string;
1049
+ }[];
1050
+ readonly id?: string | undefined;
1051
+ readonly encrypted_content?: string | null | undefined;
1052
+ } | {
1053
+ readonly type: "compaction";
1054
+ readonly encrypted_content: string;
1055
+ readonly id?: string | null | undefined;
1056
+ } | {
1057
+ readonly role: "system";
1058
+ readonly content: string;
1059
+ } | {
1060
+ readonly role: "developer";
1061
+ readonly content: string;
1062
+ } | {
1063
+ readonly content: readonly ({
1064
+ readonly type: "input_image";
1065
+ readonly image_url: string;
1066
+ readonly detail?: string | undefined;
1067
+ } | {
1068
+ readonly type: "input_file";
1069
+ readonly filename: string;
1070
+ readonly detail?: string | undefined;
1071
+ readonly file_data?: string | undefined;
1072
+ readonly file_url?: string | undefined;
1073
+ } | {
1074
+ readonly type: "input_text";
1075
+ readonly text: string;
1076
+ })[];
1077
+ readonly role: "user";
1078
+ readonly id?: string | undefined;
1079
+ readonly type?: "message" | undefined;
1080
+ readonly status?: string | undefined;
1081
+ } | {
1082
+ readonly type: "message";
1083
+ readonly content: readonly {
1084
+ readonly type: "output_text";
1085
+ readonly text: string;
1086
+ }[];
1087
+ readonly role: "assistant";
1088
+ readonly id?: string | undefined;
1089
+ readonly status?: string | undefined;
1090
+ readonly phase?: "commentary" | "final_answer" | null | undefined;
1091
+ } | {
1092
+ readonly type: "function_call";
1093
+ readonly name: string;
1094
+ readonly arguments: string;
1095
+ readonly call_id: string;
1096
+ readonly id?: string | undefined;
1097
+ readonly namespace?: string | undefined;
1098
+ } | {
1099
+ readonly type: "function_call_output";
1100
+ readonly call_id: string;
1101
+ readonly output: string | readonly ({
1102
+ readonly type: "input_image";
1103
+ readonly image_url: string;
1104
+ readonly detail?: string | undefined;
1105
+ } | {
1106
+ readonly type: "input_file";
1107
+ readonly filename: string;
1108
+ readonly detail?: string | undefined;
1109
+ readonly file_data?: string | undefined;
1110
+ readonly file_url?: string | undefined;
1111
+ } | {
1112
+ readonly type: "input_text";
1113
+ readonly text: string;
1114
+ } | {
1115
+ readonly type: "input_video";
1116
+ readonly video_url: string;
1117
+ })[];
1118
+ } | {
1119
+ readonly [x: string]: unknown;
1120
+ readonly id: string;
1121
+ readonly type: "computer_call";
1122
+ readonly status?: string | undefined;
1123
+ readonly action?: {
1124
+ readonly [x: string]: unknown;
1125
+ } | null | undefined;
1126
+ readonly call_id?: string | undefined;
1127
+ readonly pending_safety_checks?: readonly {
1128
+ readonly [x: string]: unknown;
1129
+ }[] | undefined;
1130
+ } | {
1131
+ readonly [x: string]: unknown;
1132
+ readonly id: string;
1133
+ readonly type: "web_search_preview_call";
1134
+ readonly status?: string | undefined;
1135
+ readonly action?: {
1136
+ readonly [x: string]: unknown;
1137
+ } | null | undefined;
1138
+ } | {
1139
+ readonly [x: string]: unknown;
1140
+ readonly id: string;
1141
+ readonly type: "image_generation_call";
1142
+ readonly status?: string | undefined;
1143
+ readonly result?: string | null | undefined;
1144
+ readonly revised_prompt?: string | null | undefined;
1145
+ readonly output_format?: "png" | "jpeg" | "webp" | undefined;
1146
+ })[];
1147
+ readonly model: string;
1148
+ readonly stream: true;
1149
+ readonly metadata?: {
1150
+ readonly [x: string]: string;
1151
+ } | undefined;
1152
+ readonly instructions?: string | undefined;
1153
+ readonly reasoning?: {
1154
+ readonly summary?: "auto" | "concise" | "detailed" | undefined;
1155
+ readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
1156
+ } | undefined;
1157
+ readonly tools?: readonly ({
1158
+ readonly type: "function";
1159
+ readonly description: string;
1160
+ readonly name: string;
1161
+ readonly parameters: {
1162
+ readonly [x: string]: unknown;
1163
+ };
1164
+ readonly strict?: boolean | undefined;
1165
+ } | {
1166
+ readonly type: "image_generation";
1167
+ readonly size?: string | undefined;
1168
+ readonly action?: "generate" | "auto" | "edit" | undefined;
1169
+ readonly output_format?: "png" | "jpeg" | "webp" | undefined;
1170
+ readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
1171
+ readonly background?: "auto" | "opaque" | "transparent" | undefined;
1172
+ readonly output_compression?: number | undefined;
1173
+ readonly input_fidelity?: "low" | "high" | undefined;
1174
+ readonly partial_images?: number | undefined;
1175
+ } | {
1176
+ readonly type: "namespace";
1177
+ readonly name: string;
1178
+ readonly description: string;
1179
+ readonly tools: readonly {
1180
+ readonly type: "function";
1181
+ readonly description: string;
1182
+ readonly name: string;
1183
+ readonly parameters: {
1184
+ readonly [x: string]: unknown;
1185
+ };
1186
+ readonly strict?: boolean | undefined;
1187
+ }[];
1188
+ })[] | undefined;
1189
+ readonly text?: {
1190
+ readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
1191
+ } | undefined;
1192
+ readonly temperature?: number | undefined;
1193
+ readonly service_tier?: import("../protocols/utils/open-responses-options.js").ServiceTier | undefined;
1194
+ readonly context_management?: readonly {
1195
+ readonly type: "compaction";
1196
+ readonly compact_threshold?: number | undefined;
1197
+ }[] | undefined;
1198
+ readonly tool_choice?: "required" | "auto" | "none" | {
1199
+ readonly type: "function";
1200
+ readonly name: string;
1201
+ } | {
1202
+ readonly type: "allowed_tools";
1203
+ readonly mode: "required" | "auto" | "none";
1204
+ readonly tools: readonly {
1205
+ readonly type: "function";
1206
+ readonly name: string;
1207
+ }[];
1208
+ } | {
1209
+ readonly type: "image_generation";
1210
+ } | undefined;
1211
+ readonly top_p?: number | undefined;
1212
+ readonly frequency_penalty?: number | undefined;
1213
+ readonly presence_penalty?: number | undefined;
1214
+ readonly prompt_cache_key?: string | undefined;
1215
+ readonly parallel_tool_calls?: boolean | undefined;
1216
+ readonly store?: boolean | undefined;
1217
+ readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
1218
+ readonly truncation?: "auto" | "disabled" | undefined;
1219
+ readonly stream_options?: {
1220
+ readonly include_obfuscation?: boolean | undefined;
1221
+ } | undefined;
1222
+ readonly safety_identifier?: string | undefined;
1223
+ readonly top_logprobs?: number | undefined;
1224
+ readonly max_output_tokens?: number | undefined;
1225
+ readonly max_tool_calls?: number | undefined;
1226
+ }, import("../protocols/open-responses-channel.js").Prepared, {
1227
+ endpoint: import("../route/client.js").CompactOperation;
1228
+ trigger: import("../route/client.js").TriggerCompactOperation;
1229
+ }>)[];
223
1230
  export declare const configure: (input: LanguageModelOptions) => {
224
1231
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
225
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
1232
+ model: (input: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
226
1233
  configure: (input: LanguageModelOptions) => /*elided*/ any;
227
1234
  };
228
1235
  export declare const provider: {
229
1236
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
230
1237
  configure: (input: LanguageModelOptions) => {
231
1238
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
232
- model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
1239
+ model: (input: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
233
1240
  configure: /*elided*/ any;
234
1241
  };
235
1242
  };
@@ -1,7 +1,6 @@
1
- import { OpenAIChat } from "../protocols/openai-chat.js";
1
+ import { Schema } from "effect";
2
+ import { AnthropicMessages, OpenAIChat, OpenAIResponses } from "../protocols/index.js";
2
3
  import { Auth } from "../route/auth.js";
3
- import { Route } from "../route/client.js";
4
- import { Endpoint } from "../route/endpoint.js";
5
4
  import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
6
5
  export const id = ProviderID.make("cloudflare-ai-gateway");
7
6
  export const authEnvVars = ["CLOUDFLARE_API_TOKEN", "CF_AIG_TOKEN"];
@@ -13,53 +12,91 @@ export const baseURL = (input) => {
13
12
  provider: id,
14
13
  message: "CloudflareAIGateway.configure requires accountId unless baseURL is supplied",
15
14
  });
16
- return `https://gateway.ai.cloudflare.com/v1/${encodeURIComponent(input.accountId)}/${encodeURIComponent(input.gatewayId?.trim() || "default")}/compat`;
15
+ return `https://api.cloudflare.com/client/v4/accounts/${encodeURIComponent(input.accountId)}/ai/v1`;
17
16
  };
17
+ export const responsesRoute = OpenAIResponses.route.with({
18
+ id: "cloudflare-ai-gateway-responses",
19
+ provider: id,
20
+ endpoint: { baseURL: undefined },
21
+ });
22
+ export const messagesRoute = AnthropicMessages.route.with({
23
+ id: "cloudflare-ai-gateway-messages",
24
+ provider: id,
25
+ endpoint: { baseURL: undefined },
26
+ });
27
+ export const route = OpenAIChat.route.with({
28
+ id: "cloudflare-ai-gateway-chat",
29
+ provider: id,
30
+ endpoint: { baseURL: undefined },
31
+ });
32
+ export const routes = [responsesRoute, messagesRoute, route];
18
33
  const auth = (input) => {
19
34
  if ("auth" in input && input.auth)
20
35
  return input.auth;
21
- const gateway = Auth.optional(input.gatewayApiKey, "gatewayApiKey")
36
+ return Auth.optional(input.gatewayApiKey ?? ("apiKey" in input ? input.apiKey : undefined), "apiKey")
22
37
  .orElse(Auth.config(authEnvVars[0]))
23
38
  .orElse(Auth.config(authEnvVars[1]))
24
- .pipe(Auth.bearerHeader("cf-aig-authorization"));
25
- if (!("apiKey" in input) || input.apiKey === undefined)
26
- return gateway;
27
- if (input.gatewayApiKey === undefined)
28
- return Auth.bearer(input.apiKey);
29
- return Auth.bearerHeader("cf-aig-authorization", input.gatewayApiKey).andThen(Auth.bearer(input.apiKey));
39
+ .bearer();
30
40
  };
31
- export const route = Route.make({
32
- id: "cloudflare-ai-gateway",
33
- provider: id,
34
- providerMetadataKey: "cloudflare-ai-gateway",
35
- protocol: OpenAIChat.protocol,
36
- endpoint: Endpoint.path("/chat/completions"),
37
- framing: OpenAIChat.framing,
41
+ const headers = (input) => ({
42
+ ...(input.gatewayId === undefined ? {} : { "cf-aig-gateway-id": input.gatewayId.trim() || "default" }),
43
+ ...(input.metadata === undefined
44
+ ? {}
45
+ : { "cf-aig-metadata": Schema.encodeSync(Schema.fromJsonString(Schema.Unknown))(input.metadata) }),
46
+ ...(input.cacheTtl === undefined ? {} : { "cf-aig-cache-ttl": String(input.cacheTtl) }),
47
+ ...(input.cacheKey === undefined ? {} : { "cf-aig-cache-key": input.cacheKey }),
48
+ ...(input.skipCache === undefined ? {} : { "cf-aig-skip-cache": String(input.skipCache) }),
49
+ ...(input.collectLog === undefined ? {} : { "cf-aig-collect-log": String(input.collectLog) }),
50
+ ...input.headers,
38
51
  });
39
- export const routes = [route];
52
+ const modelID = (input) => {
53
+ const value = String(input);
54
+ if (value.startsWith("workers-ai/"))
55
+ return value.slice("workers-ai/".length);
56
+ if (value.startsWith("anthropic/"))
57
+ return `anthropic/${value.slice("anthropic/".length).replaceAll(".", "-")}`;
58
+ return value;
59
+ };
40
60
  export const configure = (input) => {
41
- const { accountId: _accountId, gatewayId: _gatewayId, apiKey: _apiKey, gatewayApiKey: _gatewayApiKey, baseURL: _baseURL, auth: _auth, ...defaults } = input;
42
- const configured = route.with({
43
- ...defaults,
61
+ const defaults = {
44
62
  endpoint: { baseURL: baseURL(input) },
45
63
  auth: auth(input),
46
- });
64
+ headers: headers(input),
65
+ http: input.http,
66
+ providerOptions: input.providerOptions,
67
+ };
68
+ const responses = responsesRoute.with(defaults);
69
+ const messages = messagesRoute.with(defaults);
70
+ const chat = route.with(defaults);
47
71
  return {
48
72
  id,
49
- model: (modelID) => configured.model({ id: modelID }),
73
+ model: (input) => {
74
+ const wire = modelID(input);
75
+ if (String(input).startsWith("openai/"))
76
+ return responses.model({ id: wire });
77
+ if (String(input).startsWith("anthropic/"))
78
+ return messages.model({ id: wire });
79
+ return chat.model({ id: wire });
80
+ },
50
81
  configure,
51
82
  };
52
83
  };
53
84
  export const provider = { id, configure };
54
- export const model = (modelID, settings) => {
55
- const { accountId: _, apiKey, baseURL: _url, body, gatewayApiKey, gatewayId: _id, headers, ...providerOptions } = settings;
85
+ export const model = (modelID, { accountId, apiKey, baseURL: configuredBaseURL, body, cacheKey, cacheTtl, collectLog, gatewayApiKey, gatewayId, headers, metadata, skipCache, ...providerOptions }) => {
86
+ const connection = configuredBaseURL === undefined ? { accountId: accountId ?? "" } : { baseURL: configuredBaseURL };
56
87
  return configure({
88
+ ...connection,
57
89
  apiKey,
90
+ cacheKey,
91
+ cacheTtl,
92
+ collectLog,
58
93
  gatewayApiKey,
59
- baseURL: baseURL(settings),
94
+ gatewayId,
60
95
  headers: headers === undefined ? undefined : { ...headers },
61
96
  http: body === undefined ? undefined : { body: { ...body } },
97
+ metadata,
62
98
  providerOptions,
99
+ skipCache,
63
100
  }).model(modelID);
64
101
  };
65
102
  export * as CloudflareAIGateway from "./cloudflare-ai-gateway.js";
@@ -4,7 +4,7 @@ import { Route, type RouteDefaultsInput } from "../route/client.js";
4
4
  import { type ModelID } from "../schema/index.js";
5
5
  import type { OpenAIProviderOptionsInput } from "./openai-options.js";
6
6
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
- export declare const authEnvVars: readonly ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN"];
7
+ export declare const authEnvVars: readonly ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN", "CLOUDFLARE_API_TOKEN"];
8
8
  type WorkersAIURL = AtLeastOne<{
9
9
  readonly accountId: string;
10
10
  readonly baseURL: string;
@@ -4,7 +4,7 @@ import { Route } from "../route/client.js";
4
4
  import { Endpoint } from "../route/endpoint.js";
5
5
  import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
6
6
  export const id = ProviderID.make("cloudflare-workers-ai");
7
- export const authEnvVars = ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN"];
7
+ export const authEnvVars = ["CLOUDFLARE_API_KEY", "CLOUDFLARE_WORKERS_AI_TOKEN", "CLOUDFLARE_API_TOKEN"];
8
8
  export const baseURL = (input) => {
9
9
  if (input.baseURL)
10
10
  return input.baseURL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-19618",
3
+ "version": "0.0.0-dev-19620",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "@clack/prompts": "1.0.0-alpha.1",
32
32
  "@effect/platform-node": "4.0.0-rc.112",
33
- "@opencode/http-recorder": "0.0.0-dev-19618",
33
+ "@opencode/http-recorder": "0.0.0-dev-19620",
34
34
  "@tsconfig/bun": "1.0.9",
35
35
  "@types/bun": "1.4.0",
36
36
  "@typescript/native-preview": "7.0.0-dev.20251207.1",
@@ -40,7 +40,7 @@
40
40
  "@aws-sdk/credential-providers": "3.1057.0",
41
41
  "@smithy/eventstream-codec": "4.2.14",
42
42
  "@smithy/util-utf8": "4.2.2",
43
- "@opencode/schema": "0.0.0-dev-19618",
43
+ "@opencode/schema": "0.0.0-dev-19620",
44
44
  "aws4fetch": "1.0.20",
45
45
  "effect": "4.0.0-rc.112",
46
46
  "google-auth-library": "10.5.0"