@ai-sdk/openai 4.0.0-beta.8 → 4.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +66 -2
- package/dist/index.d.ts +66 -2
- package/dist/index.js +1139 -852
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1096 -804
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +29 -1
- package/dist/internal/index.d.ts +29 -1
- package/dist/internal/index.js +1170 -894
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +1155 -874
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +139 -0
- package/package.json +1 -1
- package/src/openai-tools.ts +12 -0
- package/src/responses/convert-to-openai-responses-input.ts +85 -4
- package/src/responses/openai-responses-api.ts +87 -1
- package/src/responses/openai-responses-language-model.ts +139 -0
- package/src/responses/openai-responses-prepare-tools.ts +26 -1
- package/src/tool/tool-search.ts +98 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
-
import { ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4 } from '@ai-sdk/provider';
|
|
2
|
+
import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4 } from '@ai-sdk/provider';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
@@ -315,6 +315,20 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
315
315
|
exit_code: number;
|
|
316
316
|
};
|
|
317
317
|
}[];
|
|
318
|
+
} | {
|
|
319
|
+
type: "tool_search_call";
|
|
320
|
+
id: string;
|
|
321
|
+
execution: "server" | "client";
|
|
322
|
+
call_id: string | null;
|
|
323
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
324
|
+
arguments: unknown;
|
|
325
|
+
} | {
|
|
326
|
+
type: "tool_search_output";
|
|
327
|
+
id: string;
|
|
328
|
+
execution: "server" | "client";
|
|
329
|
+
call_id: string | null;
|
|
330
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
331
|
+
tools: Record<string, JSONValue | undefined>[];
|
|
318
332
|
};
|
|
319
333
|
} | {
|
|
320
334
|
type: "response.output_item.done";
|
|
@@ -484,6 +498,20 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
484
498
|
exit_code: number;
|
|
485
499
|
};
|
|
486
500
|
}[];
|
|
501
|
+
} | {
|
|
502
|
+
type: "tool_search_call";
|
|
503
|
+
id: string;
|
|
504
|
+
execution: "server" | "client";
|
|
505
|
+
call_id: string | null;
|
|
506
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
507
|
+
arguments: unknown;
|
|
508
|
+
} | {
|
|
509
|
+
type: "tool_search_output";
|
|
510
|
+
id: string;
|
|
511
|
+
execution: "server" | "client";
|
|
512
|
+
call_id: string | null;
|
|
513
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
514
|
+
tools: Record<string, JSONValue | undefined>[];
|
|
487
515
|
};
|
|
488
516
|
} | {
|
|
489
517
|
type: "response.function_call_arguments.delta";
|
|
@@ -849,7 +877,19 @@ declare const openaiTools: {
|
|
|
849
877
|
type: "approximate";
|
|
850
878
|
country?: string;
|
|
851
879
|
city?: string;
|
|
852
|
-
region
|
|
880
|
+
region
|
|
881
|
+
/**
|
|
882
|
+
* Local shell is a tool that allows agents to run shell commands locally
|
|
883
|
+
* on a machine you or the user provides.
|
|
884
|
+
*
|
|
885
|
+
* Supported models: `gpt-5-codex`
|
|
886
|
+
*/
|
|
887
|
+
? /**
|
|
888
|
+
* Local shell is a tool that allows agents to run shell commands locally
|
|
889
|
+
* on a machine you or the user provides.
|
|
890
|
+
*
|
|
891
|
+
* Supported models: `gpt-5-codex`
|
|
892
|
+
*/: string;
|
|
853
893
|
timezone?: string;
|
|
854
894
|
};
|
|
855
895
|
}>;
|
|
@@ -918,6 +958,30 @@ declare const openaiTools: {
|
|
|
918
958
|
output?: string | null;
|
|
919
959
|
error?: _ai_sdk_provider.JSONValue;
|
|
920
960
|
}>;
|
|
961
|
+
/**
|
|
962
|
+
* Tool search allows the model to dynamically search for and load deferred
|
|
963
|
+
* tools into the model's context as needed. This helps reduce overall token
|
|
964
|
+
* usage, cost, and latency by only loading tools when the model needs them.
|
|
965
|
+
*
|
|
966
|
+
* To use tool search, mark functions or namespaces with `defer_loading: true`
|
|
967
|
+
* in the tools array. The model will use tool search to load these tools
|
|
968
|
+
* when it determines they are needed.
|
|
969
|
+
*/
|
|
970
|
+
toolSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
|
|
971
|
+
arguments?: unknown;
|
|
972
|
+
call_id?: string | null;
|
|
973
|
+
}, {
|
|
974
|
+
tools: Array<_ai_sdk_provider.JSONObject>;
|
|
975
|
+
}, {
|
|
976
|
+
execution?: "server" | "client";
|
|
977
|
+
description?: string;
|
|
978
|
+
parameters?: Record<string, unknown>;
|
|
979
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
980
|
+
arguments?: unknown;
|
|
981
|
+
call_id?: string | null;
|
|
982
|
+
}, {
|
|
983
|
+
tools: Array<_ai_sdk_provider.JSONObject>;
|
|
984
|
+
}>;
|
|
921
985
|
};
|
|
922
986
|
|
|
923
987
|
type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _ai_sdk_provider from '@ai-sdk/provider';
|
|
2
|
-
import { ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4 } from '@ai-sdk/provider';
|
|
2
|
+
import { JSONValue, ProviderV4, LanguageModelV4, EmbeddingModelV4, ImageModelV4, TranscriptionModelV4, SpeechModelV4 } from '@ai-sdk/provider';
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
@@ -315,6 +315,20 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
315
315
|
exit_code: number;
|
|
316
316
|
};
|
|
317
317
|
}[];
|
|
318
|
+
} | {
|
|
319
|
+
type: "tool_search_call";
|
|
320
|
+
id: string;
|
|
321
|
+
execution: "server" | "client";
|
|
322
|
+
call_id: string | null;
|
|
323
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
324
|
+
arguments: unknown;
|
|
325
|
+
} | {
|
|
326
|
+
type: "tool_search_output";
|
|
327
|
+
id: string;
|
|
328
|
+
execution: "server" | "client";
|
|
329
|
+
call_id: string | null;
|
|
330
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
331
|
+
tools: Record<string, JSONValue | undefined>[];
|
|
318
332
|
};
|
|
319
333
|
} | {
|
|
320
334
|
type: "response.output_item.done";
|
|
@@ -484,6 +498,20 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
484
498
|
exit_code: number;
|
|
485
499
|
};
|
|
486
500
|
}[];
|
|
501
|
+
} | {
|
|
502
|
+
type: "tool_search_call";
|
|
503
|
+
id: string;
|
|
504
|
+
execution: "server" | "client";
|
|
505
|
+
call_id: string | null;
|
|
506
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
507
|
+
arguments: unknown;
|
|
508
|
+
} | {
|
|
509
|
+
type: "tool_search_output";
|
|
510
|
+
id: string;
|
|
511
|
+
execution: "server" | "client";
|
|
512
|
+
call_id: string | null;
|
|
513
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
514
|
+
tools: Record<string, JSONValue | undefined>[];
|
|
487
515
|
};
|
|
488
516
|
} | {
|
|
489
517
|
type: "response.function_call_arguments.delta";
|
|
@@ -849,7 +877,19 @@ declare const openaiTools: {
|
|
|
849
877
|
type: "approximate";
|
|
850
878
|
country?: string;
|
|
851
879
|
city?: string;
|
|
852
|
-
region
|
|
880
|
+
region
|
|
881
|
+
/**
|
|
882
|
+
* Local shell is a tool that allows agents to run shell commands locally
|
|
883
|
+
* on a machine you or the user provides.
|
|
884
|
+
*
|
|
885
|
+
* Supported models: `gpt-5-codex`
|
|
886
|
+
*/
|
|
887
|
+
? /**
|
|
888
|
+
* Local shell is a tool that allows agents to run shell commands locally
|
|
889
|
+
* on a machine you or the user provides.
|
|
890
|
+
*
|
|
891
|
+
* Supported models: `gpt-5-codex`
|
|
892
|
+
*/: string;
|
|
853
893
|
timezone?: string;
|
|
854
894
|
};
|
|
855
895
|
}>;
|
|
@@ -918,6 +958,30 @@ declare const openaiTools: {
|
|
|
918
958
|
output?: string | null;
|
|
919
959
|
error?: _ai_sdk_provider.JSONValue;
|
|
920
960
|
}>;
|
|
961
|
+
/**
|
|
962
|
+
* Tool search allows the model to dynamically search for and load deferred
|
|
963
|
+
* tools into the model's context as needed. This helps reduce overall token
|
|
964
|
+
* usage, cost, and latency by only loading tools when the model needs them.
|
|
965
|
+
*
|
|
966
|
+
* To use tool search, mark functions or namespaces with `defer_loading: true`
|
|
967
|
+
* in the tools array. The model will use tool search to load these tools
|
|
968
|
+
* when it determines they are needed.
|
|
969
|
+
*/
|
|
970
|
+
toolSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
|
|
971
|
+
arguments?: unknown;
|
|
972
|
+
call_id?: string | null;
|
|
973
|
+
}, {
|
|
974
|
+
tools: Array<_ai_sdk_provider.JSONObject>;
|
|
975
|
+
}, {
|
|
976
|
+
execution?: "server" | "client";
|
|
977
|
+
description?: string;
|
|
978
|
+
parameters?: Record<string, unknown>;
|
|
979
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
980
|
+
arguments?: unknown;
|
|
981
|
+
call_id?: string | null;
|
|
982
|
+
}, {
|
|
983
|
+
tools: Array<_ai_sdk_provider.JSONObject>;
|
|
984
|
+
}>;
|
|
921
985
|
};
|
|
922
986
|
|
|
923
987
|
type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
|