@opencode/ai 0.0.0-dev-443 → 0.0.0-dev-448

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.
@@ -784,6 +784,69 @@ export declare const provider: {
784
784
  export declare const model: ProviderPackage.Model<Settings, ChatOptionsInput>;
785
785
  export declare const messagesModel: ProviderPackage.Model<Settings<MessagesOptionsInput>, MessagesOptionsInput>;
786
786
  export declare const responsesModel: ProviderPackage.Model<Settings<ResponsesOptionsInput>, ResponsesOptionsInput>;
787
+ export declare const chat: ProviderPackage.Model<Settings<{
788
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
789
+ readonly enableThinking?: boolean | undefined;
790
+ readonly thinkingBudget?: number | undefined;
791
+ readonly preserveThinking?: boolean | undefined;
792
+ readonly clearThinking?: boolean | undefined;
793
+ readonly thinking?: {
794
+ readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
795
+ } | undefined;
796
+ readonly toolStream?: boolean | undefined;
797
+ readonly parallelToolCalls?: boolean | undefined;
798
+ readonly repetitionPenalty?: number | undefined;
799
+ readonly responseFormat?: {
800
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
801
+ readonly json_schema?: {
802
+ readonly [x: string]: unknown;
803
+ } | undefined;
804
+ } | undefined;
805
+ readonly enableSearch?: boolean | undefined;
806
+ readonly searchOptions?: {
807
+ readonly forced_search?: boolean | undefined;
808
+ readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
809
+ readonly enable_search_extension?: boolean | undefined;
810
+ } | undefined;
811
+ }>, {
812
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
813
+ readonly enableThinking?: boolean | undefined;
814
+ readonly thinkingBudget?: number | undefined;
815
+ readonly preserveThinking?: boolean | undefined;
816
+ readonly clearThinking?: boolean | undefined;
817
+ readonly thinking?: {
818
+ readonly type: import("../schema/options.js").OpenString<"adaptive" | "disabled">;
819
+ } | undefined;
820
+ readonly toolStream?: boolean | undefined;
821
+ readonly parallelToolCalls?: boolean | undefined;
822
+ readonly repetitionPenalty?: number | undefined;
823
+ readonly responseFormat?: {
824
+ readonly type: import("../schema/options.js").OpenString<"json_object" | "json_schema" | "text">;
825
+ readonly json_schema?: {
826
+ readonly [x: string]: unknown;
827
+ } | undefined;
828
+ } | undefined;
829
+ readonly enableSearch?: boolean | undefined;
830
+ readonly searchOptions?: {
831
+ readonly forced_search?: boolean | undefined;
832
+ readonly search_strategy?: import("../schema/options.js").OpenString<"agent" | "agent_max" | "max" | "turbo"> | undefined;
833
+ readonly enable_search_extension?: boolean | undefined;
834
+ } | undefined;
835
+ }, import("../route/client.js").CompactionOperations | undefined>;
836
+ export declare const messages: ProviderPackage.Model<Settings<AlibabaMessages.OptionsInput>, AlibabaMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
837
+ export declare const responses: ProviderPackage.Model<Settings<{
838
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
839
+ readonly enableThinking?: boolean | undefined;
840
+ readonly store?: boolean | undefined;
841
+ readonly previousResponseId?: string | undefined;
842
+ readonly conversation?: string | undefined;
843
+ }>, {
844
+ readonly reasoningEffort?: import("../schema/options.js").ReasoningEffort | undefined;
845
+ readonly enableThinking?: boolean | undefined;
846
+ readonly store?: boolean | undefined;
847
+ readonly previousResponseId?: string | undefined;
848
+ readonly conversation?: string | undefined;
849
+ }, import("../route/client.js").CompactionOperations | undefined>;
787
850
  export declare const imageModel: (id: string, settings: Settings) => import("../image.js").ImageModel<import("./alibaba.js").AlibabaImageOptions>;
788
851
  export declare const webSearch: () => ToolDefinition;
789
852
  export declare const webExtractor: () => ToolDefinition;
@@ -76,6 +76,9 @@ export const provider = { id, configure };
76
76
  export const model = (id, input) => configure(config(input)).chat(id);
77
77
  export const messagesModel = (id, input) => configure(config(input)).messages(id);
78
78
  export const responsesModel = (id, input) => configure(config(input)).responses(id);
79
+ export const chat = model;
80
+ export const messages = messagesModel;
81
+ export const responses = responsesModel;
79
82
  export const imageModel = (id, settings) => {
80
83
  const input = config(settings);
81
84
  return configure(input).image(id, input.providerOptions);
@@ -731,6 +731,9 @@ export declare const provider: {
731
731
  responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
732
732
  configure: typeof configure;
733
733
  };
734
+ export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
735
+ export declare const messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
736
+ export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
734
737
  export declare const chatModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
735
738
  export declare const messagesModel: ProviderPackage.Model<MessagesSettings, AnthropicMessages.ProviderOptionsInput>;
736
739
  export declare const responsesModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
@@ -87,6 +87,9 @@ export const configure = (input = {}) => {
87
87
  };
88
88
  };
89
89
  export const provider = configure();
90
+ export const chat = provider.chat;
91
+ export const messages = provider.messages;
92
+ export const responses = provider.responses;
90
93
  const fromSettings = ({ apiKey, auth, baseURL, body, credentials, headers, profile, region, topP, ...providerOptions } = {}) => configure({
91
94
  apiKey,
92
95
  auth,
@@ -0,0 +1,2 @@
1
+ export { messagesModel as model } from "../azure.js";
2
+ export type { MessagesSettings as Settings } from "../azure.js";
@@ -0,0 +1 @@
1
+ export { messagesModel as model } from "../azure.js";
@@ -2,6 +2,7 @@ import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options.
2
2
  import type { Route, RouteDefaultsInput, CompactionOperations } from "../route/client.js";
3
3
  import type { ProviderPackage } from "../provider-package.js";
4
4
  import { type ModelID, type ProviderOptions } from "../schema/index.js";
5
+ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
5
6
  import { type OpenAIProviderOptionsInput } from "./openai-options.js";
6
7
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
8
  type AzureURL = AtLeastOne<{
@@ -12,14 +13,15 @@ export type Config = AzureURL & RouteDefaultsInput & ProviderAuthOption<"optiona
12
13
  readonly apiVersion?: string;
13
14
  readonly queryParams?: Record<string, string>;
14
15
  readonly useDeploymentBasedUrls?: boolean;
15
- readonly providerOptions?: OpenAIProviderOptionsInput;
16
+ readonly providerOptions?: OpenAIProviderOptionsInput | AnthropicMessages.ProviderOptionsInput;
16
17
  };
17
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & AzureURL & {
18
+ export type Settings<Options = OpenAIProviderOptionsInput> = ProviderPackage.Settings & Options & AzureURL & {
18
19
  readonly apiKey?: string | false;
19
20
  readonly apiVersion?: string;
20
21
  readonly queryParams?: Readonly<Record<string, string>>;
21
22
  readonly useDeploymentBasedUrls?: boolean;
22
23
  };
24
+ export type MessagesSettings = Settings<AnthropicMessages.ProviderOptionsInput>;
23
25
  declare const responsesRoute: Route<{
24
26
  readonly model: string;
25
27
  readonly input: readonly ({
@@ -253,6 +255,313 @@ declare const responsesRoute: Route<{
253
255
  endpoint: import("../route/client.js").CompactOperation;
254
256
  }>;
255
257
  export declare const routes: (Route<{
258
+ readonly context_management?: {
259
+ readonly edits: readonly {
260
+ readonly type: "compact_20260112";
261
+ readonly trigger?: {
262
+ readonly type: "input_tokens";
263
+ readonly value: number;
264
+ } | undefined;
265
+ readonly pause_after_compaction?: boolean | undefined;
266
+ readonly instructions?: string | undefined;
267
+ }[];
268
+ } | undefined;
269
+ readonly model: string;
270
+ readonly system?: readonly {
271
+ readonly type: "text";
272
+ readonly text: string;
273
+ readonly cache_control?: {
274
+ readonly type: "ephemeral";
275
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
276
+ } | undefined;
277
+ }[] | undefined;
278
+ readonly messages: readonly ({
279
+ readonly role: "user";
280
+ readonly content: readonly ({
281
+ readonly type: "text";
282
+ readonly text: string;
283
+ readonly cache_control?: {
284
+ readonly type: "ephemeral";
285
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
286
+ } | undefined;
287
+ } | {
288
+ readonly type: "image";
289
+ readonly source: {
290
+ readonly type: "base64";
291
+ readonly media_type: string;
292
+ readonly data: string;
293
+ } | {
294
+ readonly type: "url";
295
+ readonly url: string;
296
+ } | {
297
+ readonly type: "file";
298
+ readonly file_id: string;
299
+ };
300
+ readonly cache_control?: {
301
+ readonly type: "ephemeral";
302
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
303
+ } | undefined;
304
+ readonly transformations?: {
305
+ readonly oversized_image?: "downsize" | "error" | undefined;
306
+ } | undefined;
307
+ } | {
308
+ readonly type: "video";
309
+ readonly source: {
310
+ readonly type: "base64";
311
+ readonly media_type: string;
312
+ readonly data: string;
313
+ } | {
314
+ readonly type: "url";
315
+ readonly url: string;
316
+ } | {
317
+ readonly type: "file";
318
+ readonly file_id: string;
319
+ };
320
+ readonly cache_control?: {
321
+ readonly type: "ephemeral";
322
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
323
+ } | undefined;
324
+ } | {
325
+ readonly type: "document";
326
+ readonly source: {
327
+ readonly type: "base64";
328
+ readonly media_type: "application/pdf";
329
+ readonly data: string;
330
+ } | {
331
+ readonly type: "text";
332
+ readonly media_type: "text/plain";
333
+ readonly data: string;
334
+ } | {
335
+ readonly type: "url";
336
+ readonly url: string;
337
+ } | {
338
+ readonly type: "file";
339
+ readonly file_id: string;
340
+ };
341
+ readonly cache_control?: {
342
+ readonly type: "ephemeral";
343
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
344
+ } | undefined;
345
+ readonly title?: string | undefined;
346
+ readonly context?: string | undefined;
347
+ readonly citations?: {
348
+ readonly enabled: boolean;
349
+ } | undefined;
350
+ } | {
351
+ readonly type: "tool_result";
352
+ readonly tool_use_id: string;
353
+ readonly content: string | readonly ({
354
+ readonly type: "text";
355
+ readonly text: string;
356
+ readonly cache_control?: {
357
+ readonly type: "ephemeral";
358
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
359
+ } | undefined;
360
+ } | {
361
+ readonly type: "image";
362
+ readonly source: {
363
+ readonly type: "base64";
364
+ readonly media_type: string;
365
+ readonly data: string;
366
+ } | {
367
+ readonly type: "url";
368
+ readonly url: string;
369
+ } | {
370
+ readonly type: "file";
371
+ readonly file_id: string;
372
+ };
373
+ readonly cache_control?: {
374
+ readonly type: "ephemeral";
375
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
376
+ } | undefined;
377
+ readonly transformations?: {
378
+ readonly oversized_image?: "downsize" | "error" | undefined;
379
+ } | undefined;
380
+ } | {
381
+ readonly type: "video";
382
+ readonly source: {
383
+ readonly type: "base64";
384
+ readonly media_type: string;
385
+ readonly data: string;
386
+ } | {
387
+ readonly type: "url";
388
+ readonly url: string;
389
+ } | {
390
+ readonly type: "file";
391
+ readonly file_id: string;
392
+ };
393
+ readonly cache_control?: {
394
+ readonly type: "ephemeral";
395
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
396
+ } | undefined;
397
+ } | {
398
+ readonly type: "document";
399
+ readonly source: {
400
+ readonly type: "base64";
401
+ readonly media_type: "application/pdf";
402
+ readonly data: string;
403
+ } | {
404
+ readonly type: "text";
405
+ readonly media_type: "text/plain";
406
+ readonly data: string;
407
+ } | {
408
+ readonly type: "url";
409
+ readonly url: string;
410
+ } | {
411
+ readonly type: "file";
412
+ readonly file_id: string;
413
+ };
414
+ readonly cache_control?: {
415
+ readonly type: "ephemeral";
416
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
417
+ } | undefined;
418
+ readonly title?: string | undefined;
419
+ readonly context?: string | undefined;
420
+ readonly citations?: {
421
+ readonly enabled: boolean;
422
+ } | undefined;
423
+ })[];
424
+ readonly is_error?: boolean | undefined;
425
+ readonly cache_control?: {
426
+ readonly type: "ephemeral";
427
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
428
+ } | undefined;
429
+ })[];
430
+ } | {
431
+ readonly role: "assistant";
432
+ readonly content: readonly ({
433
+ readonly type: "compaction";
434
+ readonly content: string | null;
435
+ } | {
436
+ readonly type: "text";
437
+ readonly text: string;
438
+ readonly cache_control?: {
439
+ readonly type: "ephemeral";
440
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
441
+ } | undefined;
442
+ } | {
443
+ readonly type: "thinking";
444
+ readonly thinking: string;
445
+ readonly signature: string;
446
+ readonly cache_control?: {
447
+ readonly type: "ephemeral";
448
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
449
+ } | undefined;
450
+ } | {
451
+ readonly type: "redacted_thinking";
452
+ readonly data: string;
453
+ readonly cache_control?: {
454
+ readonly type: "ephemeral";
455
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
456
+ } | undefined;
457
+ } | {
458
+ readonly type: "tool_use";
459
+ readonly id: string;
460
+ readonly name: string;
461
+ readonly input: unknown;
462
+ readonly cache_control?: {
463
+ readonly type: "ephemeral";
464
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
465
+ } | undefined;
466
+ } | {
467
+ readonly type: "server_tool_use";
468
+ readonly id: string;
469
+ readonly name: string;
470
+ readonly input: unknown;
471
+ readonly cache_control?: {
472
+ readonly type: "ephemeral";
473
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
474
+ } | undefined;
475
+ } | {
476
+ readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
477
+ readonly tool_use_id: string;
478
+ readonly content: unknown;
479
+ readonly cache_control?: {
480
+ readonly type: "ephemeral";
481
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
482
+ } | undefined;
483
+ })[];
484
+ } | {
485
+ readonly role: "system";
486
+ readonly content: readonly {
487
+ readonly type: "text";
488
+ readonly text: string;
489
+ readonly cache_control?: {
490
+ readonly type: "ephemeral";
491
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
492
+ } | undefined;
493
+ }[];
494
+ readonly output_config?: {
495
+ readonly effort: string;
496
+ } | undefined;
497
+ })[];
498
+ readonly tools?: readonly {
499
+ readonly name: string;
500
+ readonly description: string;
501
+ readonly input_schema: {
502
+ readonly [x: string]: unknown;
503
+ };
504
+ readonly cache_control?: {
505
+ readonly type: "ephemeral";
506
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
507
+ } | undefined;
508
+ }[] | undefined;
509
+ readonly tool_choice?: {
510
+ readonly type: "any" | "auto" | "none";
511
+ readonly disable_parallel_tool_use?: boolean | undefined;
512
+ } | {
513
+ readonly type: "tool";
514
+ readonly name: string;
515
+ readonly disable_parallel_tool_use?: boolean | undefined;
516
+ } | undefined;
517
+ readonly stream: true;
518
+ readonly max_tokens: number;
519
+ readonly temperature?: number | undefined;
520
+ readonly top_p?: number | undefined;
521
+ readonly top_k?: number | undefined;
522
+ readonly stop_sequences?: readonly string[] | undefined;
523
+ readonly thinking?: {
524
+ readonly type: "between_tools" | "disabled";
525
+ } | {
526
+ readonly display?: import("../schema/options.js").OpenString<"omitted" | "summarized"> | undefined;
527
+ readonly block_binding?: {
528
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"drop_block" | "error"> | undefined;
529
+ } | undefined;
530
+ readonly type: "enabled";
531
+ readonly budget_tokens: number;
532
+ } | {
533
+ readonly display?: import("../schema/options.js").OpenString<"omitted" | "summarized"> | undefined;
534
+ readonly block_binding?: {
535
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"drop_block" | "error"> | undefined;
536
+ } | undefined;
537
+ readonly type: "adaptive";
538
+ } | undefined;
539
+ readonly output_config?: {
540
+ readonly effort?: string | undefined;
541
+ readonly format?: {
542
+ readonly type: "json_schema";
543
+ readonly schema: {
544
+ readonly [x: string]: unknown;
545
+ };
546
+ } | null | undefined;
547
+ } | undefined;
548
+ readonly cache_control?: {
549
+ readonly type: "ephemeral";
550
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
551
+ } | undefined;
552
+ readonly container?: string | {
553
+ readonly id?: string | null | undefined;
554
+ readonly skills?: readonly {
555
+ readonly [x: string]: unknown;
556
+ }[] | null | undefined;
557
+ } | null | undefined;
558
+ readonly inference_geo?: string | null | undefined;
559
+ readonly metadata?: {
560
+ readonly user_id?: string | null | undefined;
561
+ } | undefined;
562
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
563
+ readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
564
+ }, import("../route/transport/http.js").HttpPrepared<string>, CompactionOperations | undefined> | Route<{
256
565
  readonly model: string;
257
566
  readonly messages: readonly ({
258
567
  readonly role: "system";
@@ -666,6 +975,7 @@ export declare const configure: (input: Config) => {
666
975
  endpoint: import("../route/client.js").CompactOperation;
667
976
  }>;
668
977
  chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, CompactionOperations | undefined>;
978
+ messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, CompactionOperations | undefined>;
669
979
  image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
670
980
  configure: typeof configure;
671
981
  };
@@ -675,8 +985,13 @@ export declare const provider: {
675
985
  };
676
986
  export declare const responsesModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput, typeof responsesRoute.compact>;
677
987
  export declare const chatModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
988
+ export declare const messagesModel: ProviderPackage.Model<MessagesSettings, AnthropicMessages.ProviderOptionsInput>;
678
989
  export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
679
- export declare const model: ProviderPackage.Model<Settings, import("./openai-options.js").OpenAIOptionsInput, {
990
+ export declare const model: ProviderPackage.Model<Settings<import("./openai-options.js").OpenAIOptionsInput>, import("./openai-options.js").OpenAIOptionsInput, {
991
+ endpoint: import("../route/client.js").CompactOperation;
992
+ }>;
993
+ export declare const responses: ProviderPackage.Model<Settings<import("./openai-options.js").OpenAIOptionsInput>, import("./openai-options.js").OpenAIOptionsInput, {
680
994
  endpoint: import("../route/client.js").CompactOperation;
681
995
  }>;
996
+ export declare const chat: ProviderPackage.Model<Settings<import("./openai-options.js").OpenAIOptionsInput>, import("./openai-options.js").OpenAIOptionsInput, CompactionOperations | undefined>;
682
997
  export {};
@@ -3,6 +3,7 @@ import { AuthOptions } from "../route/auth-options.js";
3
3
  import { Endpoint } from "../route/endpoint.js";
4
4
  import { MediaRoute } from "../route/media.js";
5
5
  import { HttpOptions, ProviderConfigurationError, ProviderID, mergeHttpOptions, } from "../schema/index.js";
6
+ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
6
7
  import { OpenAIImages } from "../protocols/openai-images.js";
7
8
  import * as OpenAIChat from "../protocols/openai-chat.js";
8
9
  import * as OpenAIResponses from "../protocols/openai-responses.js";
@@ -39,7 +40,10 @@ const chatRoute = OpenAIChat.route.with({
39
40
  provider: id,
40
41
  auth: routeAuth,
41
42
  });
42
- export const routes = [responsesRoute, chatRoute];
43
+ // Claude on Foundry serves Anthropic Messages under the resource's `services.ai.azure.com` host and accepts the
44
+ // resource key as `x-api-key`; it rejects `api-key`.
45
+ const messagesRoute = AnthropicMessages.route.with({ id: "azure-anthropic-messages", provider: id });
46
+ export const routes = [responsesRoute, chatRoute, messagesRoute];
43
47
  const defaults = (input) => {
44
48
  const { apiKey: _, apiVersion: _apiVersion, resourceName: _resourceName, useDeploymentBasedUrls: _useDeploymentBasedUrls, baseURL: _baseURL, queryParams: _queryParams, ...rest } = input;
45
49
  if ("auth" in rest) {
@@ -48,10 +52,10 @@ const defaults = (input) => {
48
52
  }
49
53
  return rest;
50
54
  };
51
- const auth = (input) => {
55
+ const auth = (input, header = "api-key") => {
52
56
  if ("auth" in input && input.auth)
53
57
  return input.auth;
54
- return Auth.remove("authorization").andThen(AuthOptions.apiKey(input, "AZURE_OPENAI_API_KEY", Auth.header("api-key")));
58
+ return Auth.remove("authorization").andThen(AuthOptions.apiKey(input, "AZURE_OPENAI_API_KEY", Auth.header(header)));
55
59
  };
56
60
  const configuredRoute = (route, input, modelID) => route.with({
57
61
  auth: auth(input),
@@ -75,6 +79,16 @@ export const configure = (input) => {
75
79
  const chat = (modelID) => configuredRoute(chatRoute, input, modelID)
76
80
  .with(withOpenAIOptions(modelID, modelDefaults))
77
81
  .model({ id: modelID, compatibility: { supportsPromptCacheKey: true } });
82
+ const messages = (modelID) => messagesRoute
83
+ .with({
84
+ ...modelDefaults,
85
+ auth: auth(input, "x-api-key"),
86
+ endpoint: {
87
+ baseURL: Endpoint.trimBaseUrl(input.baseURL ?? `https://${input.resourceName.trim()}.services.ai.azure.com/anthropic/v1`),
88
+ query: input.queryParams,
89
+ },
90
+ })
91
+ .model({ id: modelID });
78
92
  const image = (modelID, providerOptions) => {
79
93
  const target = endpoint(input, modelID);
80
94
  const media = MediaRoute.deployment({ ...input, baseURL: target.baseURL }, auth(input));
@@ -91,6 +105,7 @@ export const configure = (input) => {
91
105
  model: responses,
92
106
  responses,
93
107
  chat,
108
+ messages,
94
109
  image,
95
110
  configure,
96
111
  };
@@ -117,8 +132,11 @@ const config = ({ apiKey, apiVersion, baseURL, body, headers, queryParams, resou
117
132
  };
118
133
  export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
119
134
  export const chatModel = (modelID, settings) => configure(config(settings)).chat(modelID);
135
+ export const messagesModel = (modelID, settings) => configure(config(settings)).messages(modelID);
120
136
  export const imageModel = (modelID, settings) => {
121
137
  const input = config(settings);
122
138
  return configure(input).image(modelID, input.providerOptions);
123
139
  };
124
140
  export const model = responsesModel;
141
+ export const responses = responsesModel;
142
+ export const chat = chatModel;
@@ -1463,6 +1463,12 @@ export declare const configure: (input: Config) => {
1463
1463
  endpoint: import("../route/client.js").CompactOperation;
1464
1464
  trigger: import("../route/client.js").TriggerCompactOperation;
1465
1465
  }>;
1466
+ chat: (value: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
1467
+ responses: (value: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, {
1468
+ endpoint: import("../route/client.js").CompactOperation;
1469
+ trigger: import("../route/client.js").TriggerCompactOperation;
1470
+ }>;
1471
+ messages: (value: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
1466
1472
  decision: (value: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
1467
1473
  configure: typeof configure;
1468
1474
  };
@@ -1471,5 +1477,8 @@ export declare const provider: {
1471
1477
  configure: typeof configure;
1472
1478
  };
1473
1479
  export declare const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
1480
+ export declare const chat: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
1481
+ export declare const responses: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
1482
+ export declare const messages: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
1474
1483
  export declare const decisionModel: (modelID: string, settings: Settings) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
1475
1484
  export * as CloudflareAIGateway from "./cloudflare-ai-gateway.js";
@@ -78,9 +78,16 @@ export const configure = (input) => {
78
78
  headers: headers(input),
79
79
  }
80
80
  : rest;
81
- const responses = responsesRoute.with(passthrough("openai"));
82
- const messages = messagesRoute.with(passthrough("anthropic/v1"));
83
- const chat = route.with(rest);
81
+ const responsesConfigured = responsesRoute.with(passthrough("openai"));
82
+ const messagesConfigured = messagesRoute.with(passthrough("anthropic/v1"));
83
+ const chatConfigured = route.with(rest);
84
+ const responses = (value) => responsesConfigured.model({
85
+ id: native ? value.replace(/^openai\//, "") : value,
86
+ });
87
+ const messages = (value) => messagesConfigured.model({
88
+ id: native ? value.replace(/^anthropic\//, "").replaceAll(".", "-") : value,
89
+ });
90
+ const chat = (value) => chatConfigured.model({ id: value.replace(/^workers-ai\//, "") });
84
91
  // The Run API base is derived per call so a chat-only configuration without an account still constructs.
85
92
  const decision = (value, providerOptions) => CloudflareRunDecisions.route
86
93
  .with({
@@ -95,21 +102,23 @@ export const configure = (input) => {
95
102
  id,
96
103
  model: (value) => {
97
104
  if (value.startsWith("openai/"))
98
- return responses.model({ id: native ? value.slice("openai/".length) : value });
105
+ return responses(value);
99
106
  if (value.startsWith("anthropic/"))
100
- return messages.model({
101
- id: native ? value.slice("anthropic/".length).replaceAll(".", "-") : value,
102
- });
103
- if (value.startsWith("workers-ai/"))
104
- return chat.model({ id: value.slice("workers-ai/".length) });
105
- return chat.model({ id: value });
107
+ return messages(value);
108
+ return chat(value);
106
109
  },
110
+ chat,
111
+ responses,
112
+ messages,
107
113
  decision,
108
114
  configure,
109
115
  };
110
116
  };
111
117
  export const provider = { id, configure };
112
118
  export const model = (modelID, settings) => configure(config(settings)).model(modelID);
119
+ export const chat = (modelID, settings) => configure(config(settings)).chat(modelID);
120
+ export const responses = (modelID, settings) => configure(config(settings)).responses(modelID);
121
+ export const messages = (modelID, settings) => configure(config(settings)).messages(modelID);
113
122
  export const decisionModel = (modelID, settings) => {
114
123
  const input = config(settings);
115
124
  return configure(input).decision(modelID, input.providerOptions);
@@ -489,5 +489,6 @@ export declare const provider: {
489
489
  chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
490
490
  configure: typeof configure;
491
491
  };
492
+ export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<ChatOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
492
493
  export declare const model: ProviderPackage.Model<Settings, CohereChat.ProviderOptionsInput>;
493
494
  export * as Cohere from "./cohere.js";
@@ -36,6 +36,7 @@ export const configure = (input = {}) => {
36
36
  };
37
37
  };
38
38
  export const provider = configure();
39
+ export const chat = provider.chat;
39
40
  export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions } = {}) => configure({
40
41
  apiKey,
41
42
  baseURL,
@@ -812,6 +812,7 @@ export declare const routes: (Route<{
812
812
  export declare const configure: (input?: Config) => {
813
813
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
814
814
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
815
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
815
816
  responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
816
817
  image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
817
818
  decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
@@ -820,6 +821,7 @@ export declare const configure: (input?: Config) => {
820
821
  export declare const provider: {
821
822
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
822
823
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
824
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
823
825
  responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
824
826
  image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
825
827
  decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
@@ -827,6 +829,7 @@ export declare const provider: {
827
829
  };
828
830
  export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<import("../decision.js").DecisionOptions>;
829
831
  export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
832
+ export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
830
833
  export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
831
834
  export declare const model: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
832
835
  export declare const responsesModel: ProviderPackage.Model<Settings<OpenResponsesProviderOptionsInput>, OpenResponsesProviderOptionsInput>;
@@ -55,14 +55,16 @@ export const configure = (input = {}) => {
55
55
  const decision = (modelID, providerOptions) => decisionRoute.model({ id: modelID, providerOptions });
56
56
  const media = MediaRoute.deployment({ ...input, baseURL: endpoint ?? baseURL }, auth);
57
57
  const image = (modelID, providerOptions) => OpenAIImages.model({ ...media, id: modelID, provider: id, providerOptions });
58
+ const chat = (modelID) => configured.model({
59
+ id: modelID,
60
+ compatibility: {
61
+ supportsPromptCacheKey: true,
62
+ },
63
+ });
58
64
  return {
59
65
  id,
60
- model: (modelID) => configured.model({
61
- id: modelID,
62
- compatibility: {
63
- supportsPromptCacheKey: true,
64
- },
65
- }),
66
+ model: chat,
67
+ chat,
66
68
  responses: (modelID) => configuredResponses.model({ id: modelID }),
67
69
  image,
68
70
  decision,
@@ -72,6 +74,7 @@ export const configure = (input = {}) => {
72
74
  export const provider = configure();
73
75
  export const decision = provider.decision;
74
76
  export const image = provider.image;
77
+ export const chat = provider.chat;
75
78
  export const responses = provider.responses;
76
79
  export const model = (modelID, settings) => configure(config(settings)).model(modelID);
77
80
  export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
@@ -170,6 +170,7 @@ export type Settings = ProviderPackage.Settings & Gemini.ProviderOptionsInput &
170
170
  export declare const configure: (input?: Config) => {
171
171
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
172
172
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<Gemini.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
173
+ gemini: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<Gemini.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
173
174
  interactions: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
174
175
  readonly previousInteractionId?: string | undefined;
175
176
  readonly store?: boolean | undefined;
@@ -186,6 +187,7 @@ export declare const configure: (input?: Config) => {
186
187
  export declare const provider: {
187
188
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
188
189
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<Gemini.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
190
+ gemini: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<Gemini.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
189
191
  interactions: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
190
192
  readonly previousInteractionId?: string | undefined;
191
193
  readonly store?: boolean | undefined;
@@ -202,6 +204,7 @@ export declare const provider: {
202
204
  export declare const model: ProviderPackage.Model<Settings, Gemini.ProviderOptionsInput>;
203
205
  export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
204
206
  export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/google-images.js").GoogleImageOptions>;
207
+ export declare const gemini: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<Gemini.OptionsInput, import("../route/client.js").CompactionOperations | undefined>;
205
208
  export declare const interactions: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<{
206
209
  readonly previousInteractionId?: string | undefined;
207
210
  readonly store?: boolean | undefined;
@@ -22,9 +22,11 @@ const interactionsRoute = (input) => {
22
22
  export const configure = (input = {}) => {
23
23
  const route = configuredRoute(input);
24
24
  const media = MediaRoute.deployment(input, auth(input));
25
+ const gemini = (modelID) => route.model({ id: modelID });
25
26
  return {
26
27
  id,
27
- model: (modelID) => route.model({ id: modelID }),
28
+ model: gemini,
29
+ gemini,
28
30
  interactions: (modelID) => interactionsRoute(input).model({ id: modelID }),
29
31
  image: (modelID, providerOptions) => GoogleImages.model({ ...media, id: modelID, providerOptions }),
30
32
  video: (modelID) => GoogleVideo.model({ ...media, id: modelID }),
@@ -49,6 +51,7 @@ function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
49
51
  };
50
52
  }
51
53
  export const image = provider.image;
54
+ export const gemini = provider.gemini;
52
55
  export const interactions = provider.interactions;
53
56
  export const video = provider.video;
54
57
  export const speech = provider.speech;
@@ -1131,6 +1131,7 @@ export declare const routes: (Route<{
1131
1131
  export declare const configure: (input?: Config) => {
1132
1132
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
1133
1133
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
1134
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
1134
1135
  responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
1135
1136
  image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
1136
1137
  decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
@@ -1139,6 +1140,7 @@ export declare const configure: (input?: Config) => {
1139
1140
  export declare const provider: {
1140
1141
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
1141
1142
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
1143
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
1142
1144
  responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
1143
1145
  image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
1144
1146
  decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
@@ -1146,6 +1148,7 @@ export declare const provider: {
1146
1148
  };
1147
1149
  export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
1148
1150
  export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
1151
+ export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
1149
1152
  export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterResponsesProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
1150
1153
  export declare const model: ProviderPackage.Model<Settings, OpenRouterProviderOptionsInput>;
1151
1154
  export declare const responsesModel: ProviderPackage.Model<Settings<OpenRouterResponsesProviderOptionsInput>, OpenRouterResponsesProviderOptionsInput>;
@@ -161,9 +161,11 @@ export const configure = (input = {}) => {
161
161
  compatibility: { mediaInput: "state" },
162
162
  providerOptions,
163
163
  });
164
+ const chat = (modelID) => chatRoute.model({ id: modelID, compatibility: { supportsPromptCacheKey: true } });
164
165
  return {
165
166
  id,
166
- model: (modelID) => chatRoute.model({ id: modelID, compatibility: { supportsPromptCacheKey: true } }),
167
+ model: chat,
168
+ chat,
167
169
  responses: (modelID) => configuredResponses.model({ id: modelID }),
168
170
  image,
169
171
  decision,
@@ -173,6 +175,7 @@ export const configure = (input = {}) => {
173
175
  export const provider = configure();
174
176
  export const decision = provider.decision;
175
177
  export const image = provider.image;
178
+ export const chat = provider.chat;
176
179
  export const responses = provider.responses;
177
180
  export const model = (modelID, settings) => configure(config(settings)).model(modelID);
178
181
  export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
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-443",
3
+ "version": "0.0.0-dev-448",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -104,6 +104,10 @@
104
104
  "import": "./dist/providers/azure/images.js",
105
105
  "types": "./dist/providers/azure/images.d.ts"
106
106
  },
107
+ "./providers/azure/messages": {
108
+ "import": "./dist/providers/azure/messages.js",
109
+ "types": "./dist/providers/azure/messages.d.ts"
110
+ },
107
111
  "./providers/azure/responses": {
108
112
  "import": "./dist/providers/azure/responses.js",
109
113
  "types": "./dist/providers/azure/responses.d.ts"
@@ -516,7 +520,7 @@
516
520
  "devDependencies": {
517
521
  "@clack/prompts": "1.0.0-alpha.1",
518
522
  "@effect/platform-node": "4.1.0",
519
- "@opencode/http-recorder": "0.0.0-dev-443",
523
+ "@opencode/http-recorder": "0.0.0-dev-448",
520
524
  "@tsconfig/bun": "1.0.9",
521
525
  "@types/bun": "1.4.3",
522
526
  "@typescript/native": "npm:typescript@7.1.0-beta",
@@ -526,7 +530,7 @@
526
530
  "@aws-sdk/credential-providers": "3.1057.0",
527
531
  "@smithy/eventstream-codec": "4.2.14",
528
532
  "@smithy/util-utf8": "4.2.2",
529
- "@opencode/schema": "0.0.0-dev-443",
533
+ "@opencode/schema": "0.0.0-dev-448",
530
534
  "aws4fetch": "1.0.20",
531
535
  "effect": "4.1.0",
532
536
  "google-auth-library": "10.5.0"