@yourgpt/llm-sdk 2.6.0-beta.1 → 2.6.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +146 -0
  2. package/dist/adapters/index.d.mts +5 -5
  3. package/dist/adapters/index.d.ts +5 -5
  4. package/dist/adapters/index.js +437 -39
  5. package/dist/adapters/index.mjs +437 -39
  6. package/dist/audio-BBSwnjo8.d.mts +92 -0
  7. package/dist/audio-BBSwnjo8.d.ts +92 -0
  8. package/dist/{base-CkeT7u-O.d.mts → base-BICaQaRS.d.mts} +7 -3
  9. package/dist/{base-BdTpUAWI.d.ts → base-CpRPB8u8.d.ts} +7 -3
  10. package/dist/fallback/index.d.mts +4 -4
  11. package/dist/fallback/index.d.ts +4 -4
  12. package/dist/index.d.mts +20 -36
  13. package/dist/index.d.ts +20 -36
  14. package/dist/index.js +327 -69
  15. package/dist/index.mjs +325 -70
  16. package/dist/providers/anthropic/index.d.mts +3 -3
  17. package/dist/providers/anthropic/index.d.ts +3 -3
  18. package/dist/providers/anthropic/index.js +116 -7
  19. package/dist/providers/anthropic/index.mjs +116 -7
  20. package/dist/providers/azure/index.d.mts +3 -3
  21. package/dist/providers/azure/index.d.ts +3 -3
  22. package/dist/providers/azure/index.js +101 -4
  23. package/dist/providers/azure/index.mjs +101 -4
  24. package/dist/providers/fireworks/index.d.mts +3 -3
  25. package/dist/providers/fireworks/index.d.ts +3 -3
  26. package/dist/providers/fireworks/index.js +393 -31
  27. package/dist/providers/fireworks/index.mjs +393 -31
  28. package/dist/providers/google/index.d.mts +3 -3
  29. package/dist/providers/google/index.d.ts +3 -3
  30. package/dist/providers/google/index.js +393 -31
  31. package/dist/providers/google/index.mjs +393 -31
  32. package/dist/providers/ollama/index.d.mts +4 -4
  33. package/dist/providers/ollama/index.d.ts +4 -4
  34. package/dist/providers/ollama/index.js +87 -2
  35. package/dist/providers/ollama/index.mjs +87 -2
  36. package/dist/providers/openai/index.d.mts +25 -6
  37. package/dist/providers/openai/index.d.ts +25 -6
  38. package/dist/providers/openai/index.js +822 -40
  39. package/dist/providers/openai/index.mjs +821 -41
  40. package/dist/providers/openrouter/index.d.mts +3 -3
  41. package/dist/providers/openrouter/index.d.ts +3 -3
  42. package/dist/providers/openrouter/index.js +393 -31
  43. package/dist/providers/openrouter/index.mjs +393 -31
  44. package/dist/providers/togetherai/index.d.mts +3 -3
  45. package/dist/providers/togetherai/index.d.ts +3 -3
  46. package/dist/providers/togetherai/index.js +393 -31
  47. package/dist/providers/togetherai/index.mjs +393 -31
  48. package/dist/providers/xai/index.d.mts +3 -3
  49. package/dist/providers/xai/index.d.ts +3 -3
  50. package/dist/providers/xai/index.js +393 -31
  51. package/dist/providers/xai/index.mjs +393 -31
  52. package/dist/{types-BWRYIvl_.d.mts → types-C3RgRbEC.d.mts} +1 -1
  53. package/dist/{types-CpXcT-tY.d.ts → types-DCFqkJAy.d.ts} +1 -1
  54. package/dist/{types-NOswlhm9.d.mts → types-DHQEMFHA.d.mts} +3 -3
  55. package/dist/{types-BW3csYo5.d.mts → types-Dg1Bcg1k.d.mts} +106 -3
  56. package/dist/{types-BW3csYo5.d.ts → types-Dg1Bcg1k.d.ts} +106 -3
  57. package/dist/{types-DA54bSmX.d.ts → types-Dikj3En4.d.ts} +3 -3
  58. package/dist/yourgpt/index.d.mts +1 -1
  59. package/dist/yourgpt/index.d.ts +1 -1
  60. package/docs/multimodal-and-audio.md +170 -0
  61. package/package.json +3 -2
@@ -10,6 +10,69 @@ interface OpenAIParameterOptions {
10
10
  onWarning?: (message: string) => void;
11
11
  }
12
12
 
13
+ /** Responses-only options. Omitted values retain the API's defaults. */
14
+ interface OpenAIResponsesOptions {
15
+ store?: boolean;
16
+ /** Send only new input after this stored response; do not also resend its history. */
17
+ previousResponseId?: string;
18
+ include?: string[];
19
+ reasoningSummary?: "auto" | "concise" | "detailed";
20
+ promptCacheKey?: string;
21
+ /** Legacy retention option for models that support it. */
22
+ promptCacheRetention?: "in_memory" | "24h";
23
+ /** GPT-5.6+ cache mode and minimum lifetime; provider/model support varies. */
24
+ promptCacheOptions?: {
25
+ mode?: "implicit" | "explicit";
26
+ ttl?: "30m";
27
+ };
28
+ }
29
+ interface OpenAITransportOptions {
30
+ /** auto preserves existing routing; responses also works without function tools. */
31
+ api?: "auto" | "chat" | "responses";
32
+ responses?: OpenAIResponsesOptions;
33
+ }
34
+ /** Opaque provider items: retain their complete contents and order for replay. */
35
+ interface OpenAIResponseItem {
36
+ type: string;
37
+ [key: string]: unknown;
38
+ }
39
+ interface OpenAIResponseMetadata {
40
+ id?: string;
41
+ model?: string;
42
+ status?: string;
43
+ output: OpenAIResponseItem[];
44
+ usage?: Record<string, unknown>;
45
+ store?: boolean;
46
+ refusals: string[];
47
+ }
48
+ interface ProviderMetadata {
49
+ openai?: {
50
+ response?: OpenAIResponseMetadata;
51
+ };
52
+ [provider: string]: unknown;
53
+ }
54
+
55
+ /** Explicit model-facing output; the application's raw tool result stays separate. */
56
+ type ToolOutputPart = {
57
+ type: "text";
58
+ text: string;
59
+ } | {
60
+ type: "image";
61
+ data: string | Uint8Array;
62
+ mediaType: string;
63
+ } | {
64
+ type: "image";
65
+ url: string;
66
+ } | {
67
+ type: "image";
68
+ fileId: string;
69
+ provider: "openai";
70
+ };
71
+ interface ToolModelOutput {
72
+ type: "content";
73
+ content: ToolOutputPart[];
74
+ }
75
+
13
76
  /**
14
77
  * Stream event types for llm-sdk
15
78
  * These types are used internally by the SDK for streaming responses
@@ -42,6 +105,7 @@ interface MessageDeltaEvent extends BaseEvent {
42
105
  * Message finished streaming
43
106
  */
44
107
  interface MessageEndEvent extends BaseEvent {
108
+ providerMetadata?: ProviderMetadata;
45
109
  type: "message:end";
46
110
  }
47
111
  /**
@@ -87,6 +151,7 @@ interface ActionArgsEvent extends BaseEvent {
87
151
  * Action execution completed
88
152
  */
89
153
  interface ActionEndEvent extends BaseEvent {
154
+ modelOutput?: ToolModelOutput;
90
155
  type: "action:end";
91
156
  id: string;
92
157
  name?: string;
@@ -123,6 +188,7 @@ interface ToolCallInfo {
123
188
  * Assistant message with tool calls
124
189
  */
125
190
  interface AssistantToolMessage {
191
+ providerMetadata?: ProviderMetadata;
126
192
  role: "assistant";
127
193
  content: string | null;
128
194
  tool_calls: Array<{
@@ -198,6 +264,8 @@ interface CitationEvent extends BaseEvent {
198
264
  * Message format for done event (API format with snake_case)
199
265
  */
200
266
  interface DoneEventMessage {
267
+ modelOutput?: ToolModelOutput;
268
+ providerMetadata?: ProviderMetadata;
201
269
  role: "assistant" | "tool";
202
270
  content: string | null;
203
271
  tool_calls?: Array<{
@@ -232,6 +300,7 @@ interface ThreadCreatedEvent extends BaseEvent {
232
300
  * Stream completed
233
301
  */
234
302
  interface DoneEvent extends BaseEvent {
303
+ providerMetadata?: ProviderMetadata;
235
304
  type: "done";
236
305
  requiresAction?: boolean;
237
306
  messages?: DoneEventMessage[];
@@ -310,6 +379,8 @@ interface MessageMetadata {
310
379
  * Message type (simplified for llm-sdk)
311
380
  */
312
381
  interface Message {
382
+ modelOutput?: ToolModelOutput;
383
+ providerMetadata?: ProviderMetadata;
313
384
  id: string;
314
385
  thread_id?: string;
315
386
  role: MessageRole;
@@ -380,7 +451,10 @@ interface AIContent {
380
451
  type?: "text" | "image";
381
452
  text?: string;
382
453
  mediaType?: string;
383
- data?: string;
454
+ data?: string | Uint8Array;
455
+ url?: string;
456
+ fileId?: string;
457
+ provider?: "openai";
384
458
  summary?: string;
385
459
  details?: string;
386
460
  }
@@ -396,6 +470,7 @@ interface ToolInputSchema {
396
470
  * Tool definition
397
471
  */
398
472
  interface ToolDefinition<TParams = Record<string, unknown>> {
473
+ toModelOutput?: (result: unknown) => ToolModelOutput | undefined;
399
474
  name: string;
400
475
  description: string;
401
476
  location: ToolLocation;
@@ -625,11 +700,14 @@ interface UserMessage {
625
700
  content: string | UserContentPart[];
626
701
  }
627
702
  interface AssistantMessage {
703
+ /** Provider state retained for continuation and inspection. */
704
+ providerMetadata?: ProviderMetadata;
628
705
  role: "assistant";
629
706
  content: string | null;
630
707
  toolCalls?: ToolCall[];
631
708
  }
632
709
  interface ToolMessage {
710
+ modelOutput?: ToolModelOutput;
633
711
  role: "tool";
634
712
  toolCallId: string;
635
713
  content: string;
@@ -650,6 +728,7 @@ interface ImagePart {
650
728
  mimeType?: string;
651
729
  }
652
730
  interface FilePart {
731
+ filename?: string;
653
732
  type: "file";
654
733
  /** Base64 data or URL */
655
734
  data: string;
@@ -666,6 +745,8 @@ interface Tool<TParams = unknown, TResult = unknown> {
666
745
  parameters: z.ZodType<TParams>;
667
746
  /** Execute function */
668
747
  execute: (params: TParams, context: ToolContext) => Promise<TResult>;
748
+ /** Map the raw result to explicit text/image content for the model. */
749
+ toModelOutput?: (result: TResult) => ToolModelOutput | undefined;
669
750
  /**
670
751
  * Hide this tool's execution from the chat UI.
671
752
  * When true, tool calls and results won't be displayed to the user,
@@ -700,6 +781,7 @@ interface ToolCall {
700
781
  * Tool execution result
701
782
  */
702
783
  interface ToolResult {
784
+ modelOutput?: ToolModelOutput;
703
785
  /** Tool call ID this result corresponds to */
704
786
  toolCallId: string;
705
787
  /** Result data (will be JSON stringified for LLM) */
@@ -709,6 +791,8 @@ interface ToolResult {
709
791
  * Parameters for model.doGenerate() and model.doStream()
710
792
  */
711
793
  interface DoGenerateParams {
794
+ /** OpenAI endpoint and Responses options. */
795
+ openai?: OpenAITransportOptions;
712
796
  /** Messages to send to LLM */
713
797
  messages: CoreMessage[];
714
798
  /** Tools available to the LLM (already formatted for provider) */
@@ -728,6 +812,8 @@ interface DoGenerateParams {
728
812
  * Result from model.doGenerate()
729
813
  */
730
814
  interface DoGenerateResult {
815
+ /** Provider state retained for continuation and inspection. */
816
+ providerMetadata?: ProviderMetadata;
731
817
  /** Generated text content */
732
818
  text: string;
733
819
  /** Tool calls requested by the LLM */
@@ -764,11 +850,14 @@ interface ToolCallChunk {
764
850
  toolCall: ToolCall;
765
851
  }
766
852
  interface ToolResultChunk {
853
+ modelOutput?: ToolModelOutput;
767
854
  type: "tool-result";
768
855
  toolCallId: string;
769
856
  result: unknown;
770
857
  }
771
858
  interface FinishChunk {
859
+ /** Provider state retained for continuation and inspection. */
860
+ providerMetadata?: ProviderMetadata;
772
861
  type: "finish";
773
862
  finishReason: FinishReason;
774
863
  usage?: TokenUsage;
@@ -781,6 +870,8 @@ interface ErrorChunk {
781
870
  * Parameters for generateText()
782
871
  */
783
872
  interface GenerateTextParams {
873
+ /** OpenAI endpoint and Responses options. */
874
+ openai?: OpenAITransportOptions;
784
875
  /** Language model to use */
785
876
  model: LanguageModel;
786
877
  /** Simple prompt (converted to user message) */
@@ -790,7 +881,7 @@ interface GenerateTextParams {
790
881
  /** Full message history */
791
882
  messages?: CoreMessage[];
792
883
  /** Tools available to the LLM */
793
- tools?: Record<string, Tool>;
884
+ tools?: Record<string, Tool<any, any>>;
794
885
  /** Maximum agentic steps (tool call loops) */
795
886
  maxSteps?: number;
796
887
  /** OpenAI reasoning effort. Omit to preserve the model default. */
@@ -808,6 +899,8 @@ interface GenerateTextParams {
808
899
  * Result from generateText()
809
900
  */
810
901
  interface GenerateTextResult {
902
+ /** Provider state retained for continuation and inspection. */
903
+ providerMetadata?: ProviderMetadata;
811
904
  /** Final text output */
812
905
  text: string;
813
906
  /** Token usage */
@@ -829,6 +922,8 @@ interface GenerateTextResult {
829
922
  * A single step in the generation process
830
923
  */
831
924
  interface GenerateStep {
925
+ /** Provider state retained for continuation and inspection. */
926
+ providerMetadata?: ProviderMetadata;
832
927
  /** Text generated in this step */
833
928
  text: string;
834
929
  /** Tool calls made in this step */
@@ -848,6 +943,11 @@ type StreamTextParams = GenerateTextParams;
848
943
  * Result from streamText()
849
944
  */
850
945
  interface StreamTextResult {
946
+ /** Final conversation, including opaque provider state for replay. */
947
+ readonly response: Promise<{
948
+ messages: CoreMessage[];
949
+ }>;
950
+ readonly providerMetadata: Promise<ProviderMetadata | undefined>;
851
951
  /** Async iterable of text chunks only */
852
952
  textStream: AsyncIterable<string>;
853
953
  /** Async iterable of all stream parts */
@@ -884,6 +984,7 @@ type StreamPart = {
884
984
  type: "tool-result";
885
985
  toolCallId: string;
886
986
  result: unknown;
987
+ modelOutput?: ToolModelOutput;
887
988
  } | {
888
989
  type: "step-start";
889
990
  step: number;
@@ -891,10 +992,12 @@ type StreamPart = {
891
992
  type: "step-finish";
892
993
  step: number;
893
994
  finishReason: FinishReason;
995
+ providerMetadata?: ProviderMetadata;
894
996
  } | {
895
997
  type: "finish";
896
998
  finishReason: FinishReason;
897
999
  usage: TokenUsage;
1000
+ providerMetadata?: ProviderMetadata;
898
1001
  } | {
899
1002
  type: "error";
900
1003
  error: Error;
@@ -981,4 +1084,4 @@ interface StorageFile {
981
1084
  filename?: string;
982
1085
  }
983
1086
 
984
- export { type UnifiedToolResult as $, type ActionDefinition as A, type ToolResultChunk as B, type CoreMessage as C, type DoneEventMessage as D, type FinishChunk as E, type FilePart as F, type GenerateTextParams as G, type ErrorChunk as H, type ImagePart as I, type TokenUsage as J, type KnowledgeBaseConfig as K, type LanguageModel as L, type Message as M, type FinishReason as N, type OpenAIReasoningEffort as O, type ProviderToolRuntimeOptions as P, type ResponseOptions as Q, type ResponseFormat as R, type StreamTextParams as S, type ToolContext as T, type UserMessage as U, type StorageFile as V, type WebSearchConfig as W, DEFAULT_CAPABILITIES as X, type LLMConfig as Y, type ToolLocation as Z, type UnifiedToolCall as _, type GenerateTextResult as a, type ToolExecution as a0, type OpenAIToolSelectionHints as a1, type AnthropicToolSelectionHints as a2, type ToolNativeProviderHints as a3, type OpenAIProviderToolOptions as a4, type AnthropicProviderToolOptions as a5, type Citation as a6, type OpenAIParameterOptions as a7, type MessageAttachment as a8, type StreamTextResult as b, type Tool as c, type ToolDefinition as d, type ToolProfile as e, type StorageAdapter as f, type StreamEvent as g, type ToolCallInfo as h, type TokenUsageRaw as i, type ToolResponse as j, type StorageMessage as k, type ModelCapabilities as l, type DoGenerateParams as m, type DoGenerateResult as n, type SystemMessage as o, type AssistantMessage as p, type ToolMessage as q, type UserContentPart as r, type TextPart as s, type ToolCall as t, type ToolResult as u, type GenerateStep as v, type StreamPart as w, type StreamChunk as x, type TextDeltaChunk as y, type ToolCallChunk as z };
1087
+ export { type LLMConfig as $, type ActionDefinition as A, type StreamChunk as B, type CoreMessage as C, type DoneEventMessage as D, type TextDeltaChunk as E, type FilePart as F, type GenerateTextParams as G, type ToolCallChunk as H, type ImagePart as I, type ToolResultChunk as J, type KnowledgeBaseConfig as K, type LanguageModel as L, type Message as M, type FinishChunk as N, type OpenAITransportOptions as O, type ProviderMetadata as P, type ErrorChunk as Q, type ResponseFormat as R, type StreamTextParams as S, type ToolContext as T, type UserMessage as U, type TokenUsage as V, type WebSearchConfig as W, type FinishReason as X, type ResponseOptions as Y, type StorageFile as Z, DEFAULT_CAPABILITIES as _, type GenerateTextResult as a, type ToolLocation as a0, type UnifiedToolCall as a1, type UnifiedToolResult as a2, type ToolExecution as a3, type OpenAIToolSelectionHints as a4, type AnthropicToolSelectionHints as a5, type ToolNativeProviderHints as a6, type OpenAIProviderToolOptions as a7, type AnthropicProviderToolOptions as a8, type Citation as a9, type OpenAIResponsesOptions as aa, type OpenAIResponseItem as ab, type OpenAIResponseMetadata as ac, type ToolOutputPart as ad, type OpenAIParameterOptions as ae, type MessageAttachment as af, type StreamTextResult as b, type ToolModelOutput as c, type Tool as d, type ToolDefinition as e, type ToolProfile as f, type StorageAdapter as g, type OpenAIReasoningEffort as h, type StreamEvent as i, type ToolCallInfo as j, type TokenUsageRaw as k, type ProviderToolRuntimeOptions as l, type ToolResponse as m, type StorageMessage as n, type ModelCapabilities as o, type DoGenerateParams as p, type DoGenerateResult as q, type SystemMessage as r, type AssistantMessage as s, type ToolMessage as t, type UserContentPart as u, type TextPart as v, type ToolCall as w, type ToolResult as x, type GenerateStep as y, type StreamPart as z };
@@ -10,6 +10,69 @@ interface OpenAIParameterOptions {
10
10
  onWarning?: (message: string) => void;
11
11
  }
12
12
 
13
+ /** Responses-only options. Omitted values retain the API's defaults. */
14
+ interface OpenAIResponsesOptions {
15
+ store?: boolean;
16
+ /** Send only new input after this stored response; do not also resend its history. */
17
+ previousResponseId?: string;
18
+ include?: string[];
19
+ reasoningSummary?: "auto" | "concise" | "detailed";
20
+ promptCacheKey?: string;
21
+ /** Legacy retention option for models that support it. */
22
+ promptCacheRetention?: "in_memory" | "24h";
23
+ /** GPT-5.6+ cache mode and minimum lifetime; provider/model support varies. */
24
+ promptCacheOptions?: {
25
+ mode?: "implicit" | "explicit";
26
+ ttl?: "30m";
27
+ };
28
+ }
29
+ interface OpenAITransportOptions {
30
+ /** auto preserves existing routing; responses also works without function tools. */
31
+ api?: "auto" | "chat" | "responses";
32
+ responses?: OpenAIResponsesOptions;
33
+ }
34
+ /** Opaque provider items: retain their complete contents and order for replay. */
35
+ interface OpenAIResponseItem {
36
+ type: string;
37
+ [key: string]: unknown;
38
+ }
39
+ interface OpenAIResponseMetadata {
40
+ id?: string;
41
+ model?: string;
42
+ status?: string;
43
+ output: OpenAIResponseItem[];
44
+ usage?: Record<string, unknown>;
45
+ store?: boolean;
46
+ refusals: string[];
47
+ }
48
+ interface ProviderMetadata {
49
+ openai?: {
50
+ response?: OpenAIResponseMetadata;
51
+ };
52
+ [provider: string]: unknown;
53
+ }
54
+
55
+ /** Explicit model-facing output; the application's raw tool result stays separate. */
56
+ type ToolOutputPart = {
57
+ type: "text";
58
+ text: string;
59
+ } | {
60
+ type: "image";
61
+ data: string | Uint8Array;
62
+ mediaType: string;
63
+ } | {
64
+ type: "image";
65
+ url: string;
66
+ } | {
67
+ type: "image";
68
+ fileId: string;
69
+ provider: "openai";
70
+ };
71
+ interface ToolModelOutput {
72
+ type: "content";
73
+ content: ToolOutputPart[];
74
+ }
75
+
13
76
  /**
14
77
  * Stream event types for llm-sdk
15
78
  * These types are used internally by the SDK for streaming responses
@@ -42,6 +105,7 @@ interface MessageDeltaEvent extends BaseEvent {
42
105
  * Message finished streaming
43
106
  */
44
107
  interface MessageEndEvent extends BaseEvent {
108
+ providerMetadata?: ProviderMetadata;
45
109
  type: "message:end";
46
110
  }
47
111
  /**
@@ -87,6 +151,7 @@ interface ActionArgsEvent extends BaseEvent {
87
151
  * Action execution completed
88
152
  */
89
153
  interface ActionEndEvent extends BaseEvent {
154
+ modelOutput?: ToolModelOutput;
90
155
  type: "action:end";
91
156
  id: string;
92
157
  name?: string;
@@ -123,6 +188,7 @@ interface ToolCallInfo {
123
188
  * Assistant message with tool calls
124
189
  */
125
190
  interface AssistantToolMessage {
191
+ providerMetadata?: ProviderMetadata;
126
192
  role: "assistant";
127
193
  content: string | null;
128
194
  tool_calls: Array<{
@@ -198,6 +264,8 @@ interface CitationEvent extends BaseEvent {
198
264
  * Message format for done event (API format with snake_case)
199
265
  */
200
266
  interface DoneEventMessage {
267
+ modelOutput?: ToolModelOutput;
268
+ providerMetadata?: ProviderMetadata;
201
269
  role: "assistant" | "tool";
202
270
  content: string | null;
203
271
  tool_calls?: Array<{
@@ -232,6 +300,7 @@ interface ThreadCreatedEvent extends BaseEvent {
232
300
  * Stream completed
233
301
  */
234
302
  interface DoneEvent extends BaseEvent {
303
+ providerMetadata?: ProviderMetadata;
235
304
  type: "done";
236
305
  requiresAction?: boolean;
237
306
  messages?: DoneEventMessage[];
@@ -310,6 +379,8 @@ interface MessageMetadata {
310
379
  * Message type (simplified for llm-sdk)
311
380
  */
312
381
  interface Message {
382
+ modelOutput?: ToolModelOutput;
383
+ providerMetadata?: ProviderMetadata;
313
384
  id: string;
314
385
  thread_id?: string;
315
386
  role: MessageRole;
@@ -380,7 +451,10 @@ interface AIContent {
380
451
  type?: "text" | "image";
381
452
  text?: string;
382
453
  mediaType?: string;
383
- data?: string;
454
+ data?: string | Uint8Array;
455
+ url?: string;
456
+ fileId?: string;
457
+ provider?: "openai";
384
458
  summary?: string;
385
459
  details?: string;
386
460
  }
@@ -396,6 +470,7 @@ interface ToolInputSchema {
396
470
  * Tool definition
397
471
  */
398
472
  interface ToolDefinition<TParams = Record<string, unknown>> {
473
+ toModelOutput?: (result: unknown) => ToolModelOutput | undefined;
399
474
  name: string;
400
475
  description: string;
401
476
  location: ToolLocation;
@@ -625,11 +700,14 @@ interface UserMessage {
625
700
  content: string | UserContentPart[];
626
701
  }
627
702
  interface AssistantMessage {
703
+ /** Provider state retained for continuation and inspection. */
704
+ providerMetadata?: ProviderMetadata;
628
705
  role: "assistant";
629
706
  content: string | null;
630
707
  toolCalls?: ToolCall[];
631
708
  }
632
709
  interface ToolMessage {
710
+ modelOutput?: ToolModelOutput;
633
711
  role: "tool";
634
712
  toolCallId: string;
635
713
  content: string;
@@ -650,6 +728,7 @@ interface ImagePart {
650
728
  mimeType?: string;
651
729
  }
652
730
  interface FilePart {
731
+ filename?: string;
653
732
  type: "file";
654
733
  /** Base64 data or URL */
655
734
  data: string;
@@ -666,6 +745,8 @@ interface Tool<TParams = unknown, TResult = unknown> {
666
745
  parameters: z.ZodType<TParams>;
667
746
  /** Execute function */
668
747
  execute: (params: TParams, context: ToolContext) => Promise<TResult>;
748
+ /** Map the raw result to explicit text/image content for the model. */
749
+ toModelOutput?: (result: TResult) => ToolModelOutput | undefined;
669
750
  /**
670
751
  * Hide this tool's execution from the chat UI.
671
752
  * When true, tool calls and results won't be displayed to the user,
@@ -700,6 +781,7 @@ interface ToolCall {
700
781
  * Tool execution result
701
782
  */
702
783
  interface ToolResult {
784
+ modelOutput?: ToolModelOutput;
703
785
  /** Tool call ID this result corresponds to */
704
786
  toolCallId: string;
705
787
  /** Result data (will be JSON stringified for LLM) */
@@ -709,6 +791,8 @@ interface ToolResult {
709
791
  * Parameters for model.doGenerate() and model.doStream()
710
792
  */
711
793
  interface DoGenerateParams {
794
+ /** OpenAI endpoint and Responses options. */
795
+ openai?: OpenAITransportOptions;
712
796
  /** Messages to send to LLM */
713
797
  messages: CoreMessage[];
714
798
  /** Tools available to the LLM (already formatted for provider) */
@@ -728,6 +812,8 @@ interface DoGenerateParams {
728
812
  * Result from model.doGenerate()
729
813
  */
730
814
  interface DoGenerateResult {
815
+ /** Provider state retained for continuation and inspection. */
816
+ providerMetadata?: ProviderMetadata;
731
817
  /** Generated text content */
732
818
  text: string;
733
819
  /** Tool calls requested by the LLM */
@@ -764,11 +850,14 @@ interface ToolCallChunk {
764
850
  toolCall: ToolCall;
765
851
  }
766
852
  interface ToolResultChunk {
853
+ modelOutput?: ToolModelOutput;
767
854
  type: "tool-result";
768
855
  toolCallId: string;
769
856
  result: unknown;
770
857
  }
771
858
  interface FinishChunk {
859
+ /** Provider state retained for continuation and inspection. */
860
+ providerMetadata?: ProviderMetadata;
772
861
  type: "finish";
773
862
  finishReason: FinishReason;
774
863
  usage?: TokenUsage;
@@ -781,6 +870,8 @@ interface ErrorChunk {
781
870
  * Parameters for generateText()
782
871
  */
783
872
  interface GenerateTextParams {
873
+ /** OpenAI endpoint and Responses options. */
874
+ openai?: OpenAITransportOptions;
784
875
  /** Language model to use */
785
876
  model: LanguageModel;
786
877
  /** Simple prompt (converted to user message) */
@@ -790,7 +881,7 @@ interface GenerateTextParams {
790
881
  /** Full message history */
791
882
  messages?: CoreMessage[];
792
883
  /** Tools available to the LLM */
793
- tools?: Record<string, Tool>;
884
+ tools?: Record<string, Tool<any, any>>;
794
885
  /** Maximum agentic steps (tool call loops) */
795
886
  maxSteps?: number;
796
887
  /** OpenAI reasoning effort. Omit to preserve the model default. */
@@ -808,6 +899,8 @@ interface GenerateTextParams {
808
899
  * Result from generateText()
809
900
  */
810
901
  interface GenerateTextResult {
902
+ /** Provider state retained for continuation and inspection. */
903
+ providerMetadata?: ProviderMetadata;
811
904
  /** Final text output */
812
905
  text: string;
813
906
  /** Token usage */
@@ -829,6 +922,8 @@ interface GenerateTextResult {
829
922
  * A single step in the generation process
830
923
  */
831
924
  interface GenerateStep {
925
+ /** Provider state retained for continuation and inspection. */
926
+ providerMetadata?: ProviderMetadata;
832
927
  /** Text generated in this step */
833
928
  text: string;
834
929
  /** Tool calls made in this step */
@@ -848,6 +943,11 @@ type StreamTextParams = GenerateTextParams;
848
943
  * Result from streamText()
849
944
  */
850
945
  interface StreamTextResult {
946
+ /** Final conversation, including opaque provider state for replay. */
947
+ readonly response: Promise<{
948
+ messages: CoreMessage[];
949
+ }>;
950
+ readonly providerMetadata: Promise<ProviderMetadata | undefined>;
851
951
  /** Async iterable of text chunks only */
852
952
  textStream: AsyncIterable<string>;
853
953
  /** Async iterable of all stream parts */
@@ -884,6 +984,7 @@ type StreamPart = {
884
984
  type: "tool-result";
885
985
  toolCallId: string;
886
986
  result: unknown;
987
+ modelOutput?: ToolModelOutput;
887
988
  } | {
888
989
  type: "step-start";
889
990
  step: number;
@@ -891,10 +992,12 @@ type StreamPart = {
891
992
  type: "step-finish";
892
993
  step: number;
893
994
  finishReason: FinishReason;
995
+ providerMetadata?: ProviderMetadata;
894
996
  } | {
895
997
  type: "finish";
896
998
  finishReason: FinishReason;
897
999
  usage: TokenUsage;
1000
+ providerMetadata?: ProviderMetadata;
898
1001
  } | {
899
1002
  type: "error";
900
1003
  error: Error;
@@ -981,4 +1084,4 @@ interface StorageFile {
981
1084
  filename?: string;
982
1085
  }
983
1086
 
984
- export { type UnifiedToolResult as $, type ActionDefinition as A, type ToolResultChunk as B, type CoreMessage as C, type DoneEventMessage as D, type FinishChunk as E, type FilePart as F, type GenerateTextParams as G, type ErrorChunk as H, type ImagePart as I, type TokenUsage as J, type KnowledgeBaseConfig as K, type LanguageModel as L, type Message as M, type FinishReason as N, type OpenAIReasoningEffort as O, type ProviderToolRuntimeOptions as P, type ResponseOptions as Q, type ResponseFormat as R, type StreamTextParams as S, type ToolContext as T, type UserMessage as U, type StorageFile as V, type WebSearchConfig as W, DEFAULT_CAPABILITIES as X, type LLMConfig as Y, type ToolLocation as Z, type UnifiedToolCall as _, type GenerateTextResult as a, type ToolExecution as a0, type OpenAIToolSelectionHints as a1, type AnthropicToolSelectionHints as a2, type ToolNativeProviderHints as a3, type OpenAIProviderToolOptions as a4, type AnthropicProviderToolOptions as a5, type Citation as a6, type OpenAIParameterOptions as a7, type MessageAttachment as a8, type StreamTextResult as b, type Tool as c, type ToolDefinition as d, type ToolProfile as e, type StorageAdapter as f, type StreamEvent as g, type ToolCallInfo as h, type TokenUsageRaw as i, type ToolResponse as j, type StorageMessage as k, type ModelCapabilities as l, type DoGenerateParams as m, type DoGenerateResult as n, type SystemMessage as o, type AssistantMessage as p, type ToolMessage as q, type UserContentPart as r, type TextPart as s, type ToolCall as t, type ToolResult as u, type GenerateStep as v, type StreamPart as w, type StreamChunk as x, type TextDeltaChunk as y, type ToolCallChunk as z };
1087
+ export { type LLMConfig as $, type ActionDefinition as A, type StreamChunk as B, type CoreMessage as C, type DoneEventMessage as D, type TextDeltaChunk as E, type FilePart as F, type GenerateTextParams as G, type ToolCallChunk as H, type ImagePart as I, type ToolResultChunk as J, type KnowledgeBaseConfig as K, type LanguageModel as L, type Message as M, type FinishChunk as N, type OpenAITransportOptions as O, type ProviderMetadata as P, type ErrorChunk as Q, type ResponseFormat as R, type StreamTextParams as S, type ToolContext as T, type UserMessage as U, type TokenUsage as V, type WebSearchConfig as W, type FinishReason as X, type ResponseOptions as Y, type StorageFile as Z, DEFAULT_CAPABILITIES as _, type GenerateTextResult as a, type ToolLocation as a0, type UnifiedToolCall as a1, type UnifiedToolResult as a2, type ToolExecution as a3, type OpenAIToolSelectionHints as a4, type AnthropicToolSelectionHints as a5, type ToolNativeProviderHints as a6, type OpenAIProviderToolOptions as a7, type AnthropicProviderToolOptions as a8, type Citation as a9, type OpenAIResponsesOptions as aa, type OpenAIResponseItem as ab, type OpenAIResponseMetadata as ac, type ToolOutputPart as ad, type OpenAIParameterOptions as ae, type MessageAttachment as af, type StreamTextResult as b, type ToolModelOutput as c, type Tool as d, type ToolDefinition as e, type ToolProfile as f, type StorageAdapter as g, type OpenAIReasoningEffort as h, type StreamEvent as i, type ToolCallInfo as j, type TokenUsageRaw as k, type ProviderToolRuntimeOptions as l, type ToolResponse as m, type StorageMessage as n, type ModelCapabilities as o, type DoGenerateParams as p, type DoGenerateResult as q, type SystemMessage as r, type AssistantMessage as s, type ToolMessage as t, type UserContentPart as u, type TextPart as v, type ToolCall as w, type ToolResult as x, type GenerateStep as y, type StreamPart as z };
@@ -1,5 +1,5 @@
1
- import { a7 as OpenAIParameterOptions, d as ToolDefinition, _ as UnifiedToolCall, $ as UnifiedToolResult } from './types-BW3csYo5.js';
2
- import { L as LLMAdapter } from './base-BdTpUAWI.js';
1
+ import { ae as OpenAIParameterOptions, O as OpenAITransportOptions, e as ToolDefinition, a1 as UnifiedToolCall, a2 as UnifiedToolResult } from './types-Dg1Bcg1k.js';
2
+ import { L as LLMAdapter } from './base-CpRPB8u8.js';
3
3
 
4
4
  /**
5
5
  * Provider formatter interface
@@ -251,7 +251,7 @@ interface BaseProviderConfig {
251
251
  /**
252
252
  * OpenAI provider configuration
253
253
  */
254
- interface OpenAIProviderConfig extends BaseProviderConfig, OpenAIParameterOptions {
254
+ interface OpenAIProviderConfig extends BaseProviderConfig, OpenAIParameterOptions, OpenAITransportOptions {
255
255
  /** OpenAI organization ID */
256
256
  organization?: string;
257
257
  /** OpenAI project ID */
@@ -1,4 +1,4 @@
1
- import { k as StorageMessage, f as StorageAdapter, V as StorageFile } from '../types-BW3csYo5.mjs';
1
+ import { n as StorageMessage, g as StorageAdapter, Z as StorageFile } from '../types-Dg1Bcg1k.mjs';
2
2
  import 'zod';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { k as StorageMessage, f as StorageAdapter, V as StorageFile } from '../types-BW3csYo5.js';
1
+ import { n as StorageMessage, g as StorageAdapter, Z as StorageFile } from '../types-Dg1Bcg1k.js';
2
2
  import 'zod';
3
3
 
4
4
  /**