@langchain/openai 1.1.3 → 1.2.0-dev-1765432861398

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 (204) hide show
  1. package/README.md +583 -2
  2. package/dist/azure/chat_models/common.d.cts.map +1 -0
  3. package/dist/azure/chat_models/common.d.ts.map +1 -0
  4. package/dist/azure/chat_models/completions.d.cts.map +1 -0
  5. package/dist/azure/chat_models/completions.d.ts.map +1 -0
  6. package/dist/azure/chat_models/index.d.cts +1 -1
  7. package/dist/azure/chat_models/index.d.cts.map +1 -0
  8. package/dist/azure/chat_models/index.d.ts.map +1 -0
  9. package/dist/azure/chat_models/responses.d.cts.map +1 -0
  10. package/dist/azure/chat_models/responses.d.ts.map +1 -0
  11. package/dist/azure/embeddings.d.cts.map +1 -0
  12. package/dist/azure/embeddings.d.ts.map +1 -0
  13. package/dist/azure/llms.d.cts +0 -1
  14. package/dist/azure/llms.d.cts.map +1 -0
  15. package/dist/azure/llms.d.ts +0 -1
  16. package/dist/azure/llms.d.ts.map +1 -0
  17. package/dist/chat_models/base.cjs +5 -1
  18. package/dist/chat_models/base.cjs.map +1 -1
  19. package/dist/chat_models/base.d.cts +8 -22
  20. package/dist/chat_models/base.d.cts.map +1 -0
  21. package/dist/chat_models/base.d.ts +6 -20
  22. package/dist/chat_models/base.d.ts.map +1 -0
  23. package/dist/chat_models/base.js +6 -2
  24. package/dist/chat_models/base.js.map +1 -1
  25. package/dist/chat_models/completions.cjs.map +1 -1
  26. package/dist/chat_models/completions.d.cts +1 -3
  27. package/dist/chat_models/completions.d.cts.map +1 -0
  28. package/dist/chat_models/completions.d.ts +1 -3
  29. package/dist/chat_models/completions.d.ts.map +1 -0
  30. package/dist/chat_models/completions.js.map +1 -1
  31. package/dist/chat_models/index.d.cts +42 -4
  32. package/dist/chat_models/index.d.cts.map +1 -0
  33. package/dist/chat_models/index.d.ts +42 -4
  34. package/dist/chat_models/index.d.ts.map +1 -0
  35. package/dist/chat_models/responses.d.cts +2 -2
  36. package/dist/chat_models/responses.d.cts.map +1 -0
  37. package/dist/chat_models/responses.d.ts +2 -2
  38. package/dist/chat_models/responses.d.ts.map +1 -0
  39. package/dist/converters/completions.cjs +22 -12
  40. package/dist/converters/completions.cjs.map +1 -1
  41. package/dist/converters/completions.d.cts +0 -1
  42. package/dist/converters/completions.d.cts.map +1 -0
  43. package/dist/converters/completions.d.ts +0 -1
  44. package/dist/converters/completions.d.ts.map +1 -0
  45. package/dist/converters/completions.js +23 -13
  46. package/dist/converters/completions.js.map +1 -1
  47. package/dist/converters/responses.cjs +37 -4
  48. package/dist/converters/responses.cjs.map +1 -1
  49. package/dist/converters/responses.d.cts.map +1 -0
  50. package/dist/converters/responses.d.ts.map +1 -0
  51. package/dist/converters/responses.js +39 -6
  52. package/dist/converters/responses.js.map +1 -1
  53. package/dist/embeddings.d.cts +0 -1
  54. package/dist/embeddings.d.cts.map +1 -0
  55. package/dist/embeddings.d.ts +0 -1
  56. package/dist/embeddings.d.ts.map +1 -0
  57. package/dist/index.cjs +2 -1
  58. package/dist/index.d.cts +12 -2
  59. package/dist/index.d.ts +12 -3
  60. package/dist/index.js +2 -2
  61. package/dist/llms.d.cts +0 -1
  62. package/dist/llms.d.cts.map +1 -0
  63. package/dist/llms.d.ts +0 -1
  64. package/dist/llms.d.ts.map +1 -0
  65. package/dist/tools/applyPatch.cjs +116 -0
  66. package/dist/tools/applyPatch.cjs.map +1 -0
  67. package/dist/tools/applyPatch.d.cts +148 -0
  68. package/dist/tools/applyPatch.d.cts.map +1 -0
  69. package/dist/tools/applyPatch.d.ts +148 -0
  70. package/dist/tools/applyPatch.d.ts.map +1 -0
  71. package/dist/tools/applyPatch.js +115 -0
  72. package/dist/tools/applyPatch.js.map +1 -0
  73. package/dist/tools/codeInterpreter.cjs +95 -0
  74. package/dist/tools/codeInterpreter.cjs.map +1 -0
  75. package/dist/tools/codeInterpreter.d.cts +125 -0
  76. package/dist/tools/codeInterpreter.d.cts.map +1 -0
  77. package/dist/tools/codeInterpreter.d.ts +125 -0
  78. package/dist/tools/codeInterpreter.d.ts.map +1 -0
  79. package/dist/tools/codeInterpreter.js +94 -0
  80. package/dist/tools/codeInterpreter.js.map +1 -0
  81. package/dist/tools/computerUse.cjs +240 -0
  82. package/dist/tools/computerUse.cjs.map +1 -0
  83. package/dist/tools/computerUse.d.cts +234 -0
  84. package/dist/tools/computerUse.d.cts.map +1 -0
  85. package/dist/tools/computerUse.d.ts +234 -0
  86. package/dist/tools/computerUse.d.ts.map +1 -0
  87. package/dist/tools/computerUse.js +239 -0
  88. package/dist/tools/computerUse.js.map +1 -0
  89. package/dist/tools/custom.d.cts +1 -1
  90. package/dist/tools/custom.d.cts.map +1 -0
  91. package/dist/tools/custom.d.ts.map +1 -0
  92. package/dist/tools/dalle.d.cts +1 -2
  93. package/dist/tools/dalle.d.cts.map +1 -0
  94. package/dist/tools/dalle.d.ts +1 -2
  95. package/dist/tools/dalle.d.ts.map +1 -0
  96. package/dist/tools/fileSearch.cjs +137 -0
  97. package/dist/tools/fileSearch.cjs.map +1 -0
  98. package/dist/tools/fileSearch.d.cts +224 -0
  99. package/dist/tools/fileSearch.d.cts.map +1 -0
  100. package/dist/tools/fileSearch.d.ts +224 -0
  101. package/dist/tools/fileSearch.d.ts.map +1 -0
  102. package/dist/tools/fileSearch.js +136 -0
  103. package/dist/tools/fileSearch.js.map +1 -0
  104. package/dist/tools/imageGeneration.cjs +128 -0
  105. package/dist/tools/imageGeneration.cjs.map +1 -0
  106. package/dist/tools/imageGeneration.d.cts +199 -0
  107. package/dist/tools/imageGeneration.d.cts.map +1 -0
  108. package/dist/tools/imageGeneration.d.ts +199 -0
  109. package/dist/tools/imageGeneration.d.ts.map +1 -0
  110. package/dist/tools/imageGeneration.js +127 -0
  111. package/dist/tools/imageGeneration.js.map +1 -0
  112. package/dist/tools/index.cjs +26 -0
  113. package/dist/tools/index.cjs.map +1 -0
  114. package/dist/tools/index.d.cts +27 -0
  115. package/dist/tools/index.d.cts.map +1 -0
  116. package/dist/tools/index.d.ts +27 -1
  117. package/dist/tools/index.d.ts.map +1 -0
  118. package/dist/tools/index.js +26 -0
  119. package/dist/tools/index.js.map +1 -0
  120. package/dist/tools/localShell.cjs +145 -0
  121. package/dist/tools/localShell.cjs.map +1 -0
  122. package/dist/tools/localShell.d.cts +167 -0
  123. package/dist/tools/localShell.d.cts.map +1 -0
  124. package/dist/tools/localShell.d.ts +167 -0
  125. package/dist/tools/localShell.d.ts.map +1 -0
  126. package/dist/tools/localShell.js +144 -0
  127. package/dist/tools/localShell.js.map +1 -0
  128. package/dist/tools/mcp.cjs +53 -0
  129. package/dist/tools/mcp.cjs.map +1 -0
  130. package/dist/tools/mcp.d.cts +177 -0
  131. package/dist/tools/mcp.d.cts.map +1 -0
  132. package/dist/tools/mcp.d.ts +177 -0
  133. package/dist/tools/mcp.d.ts.map +1 -0
  134. package/dist/tools/mcp.js +52 -0
  135. package/dist/tools/mcp.js.map +1 -0
  136. package/dist/tools/shell.cjs +163 -0
  137. package/dist/tools/shell.cjs.map +1 -0
  138. package/dist/tools/shell.d.cts +221 -0
  139. package/dist/tools/shell.d.cts.map +1 -0
  140. package/dist/tools/shell.d.ts +221 -0
  141. package/dist/tools/shell.d.ts.map +1 -0
  142. package/dist/tools/shell.js +162 -0
  143. package/dist/tools/shell.js.map +1 -0
  144. package/dist/tools/webSearch.cjs +73 -0
  145. package/dist/tools/webSearch.cjs.map +1 -0
  146. package/dist/tools/webSearch.d.cts +130 -0
  147. package/dist/tools/webSearch.d.cts.map +1 -0
  148. package/dist/tools/webSearch.d.ts +130 -0
  149. package/dist/tools/webSearch.d.ts.map +1 -0
  150. package/dist/tools/webSearch.js +72 -0
  151. package/dist/tools/webSearch.js.map +1 -0
  152. package/dist/types.d.cts +2 -4
  153. package/dist/types.d.cts.map +1 -0
  154. package/dist/types.d.ts +1 -3
  155. package/dist/types.d.ts.map +1 -0
  156. package/dist/utils/azure.d.cts +1 -5
  157. package/dist/utils/azure.d.cts.map +1 -0
  158. package/dist/utils/azure.d.ts +1 -5
  159. package/dist/utils/azure.d.ts.map +1 -0
  160. package/dist/utils/client.d.cts.map +1 -0
  161. package/dist/utils/client.d.ts.map +1 -0
  162. package/dist/utils/misc.cjs +6 -0
  163. package/dist/utils/misc.cjs.map +1 -1
  164. package/dist/utils/misc.d.cts +1 -1
  165. package/dist/utils/misc.d.cts.map +1 -0
  166. package/dist/utils/misc.d.ts +1 -1
  167. package/dist/utils/misc.d.ts.map +1 -0
  168. package/dist/utils/misc.js +6 -1
  169. package/dist/utils/misc.js.map +1 -1
  170. package/dist/utils/prompts.d.cts +0 -1
  171. package/dist/utils/prompts.d.cts.map +1 -0
  172. package/dist/utils/prompts.d.ts +0 -1
  173. package/dist/utils/prompts.d.ts.map +1 -0
  174. package/dist/utils/tools.cjs +39 -1
  175. package/dist/utils/tools.cjs.map +1 -1
  176. package/dist/utils/tools.d.cts.map +1 -0
  177. package/dist/utils/tools.d.ts.map +1 -0
  178. package/dist/utils/tools.js +37 -2
  179. package/dist/utils/tools.js.map +1 -1
  180. package/package.json +8 -6
  181. package/dist/langchain-core/dist/callbacks/base.d.ts +0 -1
  182. package/dist/langchain-core/dist/callbacks/manager.d.ts +0 -2
  183. package/dist/langchain-core/dist/documents/transformers.d.ts +0 -2
  184. package/dist/langchain-core/dist/language_models/base.d.ts +0 -7
  185. package/dist/langchain-core/dist/language_models/chat_models.d.cts +0 -13
  186. package/dist/langchain-core/dist/language_models/chat_models.d.ts +0 -23
  187. package/dist/langchain-core/dist/messages/index.d.ts +0 -1
  188. package/dist/langchain-core/dist/messages/transformers.d.ts +0 -3
  189. package/dist/langchain-core/dist/runnables/base.d.ts +0 -7
  190. package/dist/langchain-core/dist/runnables/config.d.ts +0 -2
  191. package/dist/langchain-core/dist/runnables/graph.d.ts +0 -1
  192. package/dist/langchain-core/dist/runnables/types.d.ts +0 -2
  193. package/dist/langchain-core/dist/tools/index.d.ts +0 -8
  194. package/dist/langchain-core/dist/tools/types.d.ts +0 -7
  195. package/dist/langchain-core/dist/tracers/base.d.ts +0 -2
  196. package/dist/langchain-core/dist/tracers/event_stream.d.ts +0 -2
  197. package/dist/langchain-core/dist/tracers/log_stream.d.ts +0 -3
  198. package/dist/langchain-core/dist/types/_internal.d.cts +0 -11
  199. package/dist/langchain-core/dist/types/_internal.d.ts +0 -11
  200. package/dist/langchain-core/dist/utils/json_schema.d.ts +0 -1
  201. package/dist/langchain-core/dist/utils/stream.d.cts +0 -26
  202. package/dist/langchain-core/dist/utils/stream.d.ts +0 -26
  203. package/dist/langchain-core/dist/utils/types/index.d.ts +0 -1
  204. package/dist/langchain-core/dist/utils/types/zod.d.ts +0 -1
@@ -0,0 +1,136 @@
1
+ //#region src/tools/fileSearch.ts
2
+ /**
3
+ * Converts ranking options to the API format.
4
+ */
5
+ function convertRankingOptions(options) {
6
+ if (!options) return void 0;
7
+ return {
8
+ ranker: options.ranker,
9
+ score_threshold: options.scoreThreshold,
10
+ hybrid_search: options.hybridSearch ? {
11
+ embedding_weight: options.hybridSearch.embeddingWeight,
12
+ text_weight: options.hybridSearch.textWeight
13
+ } : void 0
14
+ };
15
+ }
16
+ /**
17
+ * Creates a File Search tool that allows models to search your files
18
+ * for relevant information using semantic and keyword search.
19
+ *
20
+ * File Search enables models to retrieve information from a knowledge base
21
+ * of previously uploaded files stored in vector stores. This is a hosted tool
22
+ * managed by OpenAI - you don't need to implement the search execution yourself.
23
+ *
24
+ * **Prerequisites**: Before using File Search, you must:
25
+ * 1. Upload files to the File API with `purpose: "assistants"`
26
+ * 2. Create a vector store
27
+ * 3. Add files to the vector store
28
+ *
29
+ * @see {@link https://platform.openai.com/docs/guides/tools-file-search | OpenAI File Search Documentation}
30
+ *
31
+ * @param options - Configuration options for the File Search tool
32
+ * @returns A File Search tool definition to be passed to the OpenAI Responses API
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * import { ChatOpenAI, tools } from "@langchain/openai";
37
+ *
38
+ * const model = new ChatOpenAI({ model: "gpt-4.1" });
39
+ *
40
+ * // Basic usage with a vector store
41
+ * const response = await model.invoke(
42
+ * "What is deep research by OpenAI?",
43
+ * {
44
+ * tools: [tools.fileSearch({
45
+ * vectorStoreIds: ["vs_abc123"]
46
+ * })]
47
+ * }
48
+ * );
49
+ *
50
+ * // Limit the number of results for lower latency
51
+ * const response = await model.invoke(
52
+ * "Find information about pricing",
53
+ * {
54
+ * tools: [tools.fileSearch({
55
+ * vectorStoreIds: ["vs_abc123"],
56
+ * maxNumResults: 5
57
+ * })]
58
+ * }
59
+ * );
60
+ *
61
+ * // With metadata filtering
62
+ * const response = await model.invoke(
63
+ * "Find recent blog posts about AI",
64
+ * {
65
+ * tools: [tools.fileSearch({
66
+ * vectorStoreIds: ["vs_abc123"],
67
+ * filters: {
68
+ * type: "eq",
69
+ * key: "category",
70
+ * value: "blog"
71
+ * }
72
+ * })]
73
+ * }
74
+ * );
75
+ *
76
+ * // With compound filters (AND/OR)
77
+ * const response = await model.invoke(
78
+ * "Find technical docs from 2024",
79
+ * {
80
+ * tools: [tools.fileSearch({
81
+ * vectorStoreIds: ["vs_abc123"],
82
+ * filters: {
83
+ * type: "and",
84
+ * filters: [
85
+ * { type: "eq", key: "category", value: "technical" },
86
+ * { type: "gte", key: "year", value: 2024 }
87
+ * ]
88
+ * }
89
+ * })]
90
+ * }
91
+ * );
92
+ *
93
+ * // With ranking options for more relevant results
94
+ * const response = await model.invoke(
95
+ * "Find the most relevant information",
96
+ * {
97
+ * tools: [tools.fileSearch({
98
+ * vectorStoreIds: ["vs_abc123"],
99
+ * rankingOptions: {
100
+ * scoreThreshold: 0.8,
101
+ * ranker: "auto"
102
+ * }
103
+ * })]
104
+ * }
105
+ * );
106
+ *
107
+ * // Search multiple vector stores
108
+ * const response = await model.invoke(
109
+ * "Search across all knowledge bases",
110
+ * {
111
+ * tools: [tools.fileSearch({
112
+ * vectorStoreIds: ["vs_abc123", "vs_def456"]
113
+ * })]
114
+ * }
115
+ * );
116
+ * ```
117
+ *
118
+ * @remarks
119
+ * - Vector stores must be created and populated before using this tool
120
+ * - The tool returns file citations in the response annotations
121
+ * - Use `include: ["file_search_call.results"]` in the API call to get search results
122
+ * - Supported file types include PDF, DOCX, TXT, MD, and many code file formats
123
+ */
124
+ function fileSearch(options) {
125
+ return {
126
+ type: "file_search",
127
+ vector_store_ids: options.vectorStoreIds,
128
+ max_num_results: options.maxNumResults,
129
+ filters: options.filters,
130
+ ranking_options: convertRankingOptions(options.rankingOptions)
131
+ };
132
+ }
133
+
134
+ //#endregion
135
+ export { fileSearch };
136
+ //# sourceMappingURL=fileSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileSearch.js","names":["options: FileSearchRankingOptions | undefined","options: FileSearchOptions"],"sources":["../../src/tools/fileSearch.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Comparison operators for file attribute filtering.\n */\nexport type FileSearchComparisonType =\n | \"eq\"\n | \"ne\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\";\n\n/**\n * A filter used to compare a specified attribute key to a given value.\n */\nexport interface FileSearchComparisonFilter {\n /**\n * The comparison operator to use.\n * - `eq`: equals\n * - `ne`: not equal\n * - `gt`: greater than\n * - `gte`: greater than or equal\n * - `lt`: less than\n * - `lte`: less than or equal\n */\n type: FileSearchComparisonType;\n /**\n * The attribute key to compare against.\n */\n key: string;\n /**\n * The value to compare against the attribute key.\n * Supports string, number, boolean, or array of strings/numbers.\n */\n value: string | number | boolean | Array<string | number>;\n}\n\n/**\n * Combine multiple filters using `and` or `or`.\n */\nexport interface FileSearchCompoundFilter {\n /**\n * Type of operation: `and` or `or`.\n */\n type: \"and\" | \"or\";\n /**\n * Array of filters to combine.\n */\n filters: Array<FileSearchComparisonFilter | FileSearchCompoundFilter>;\n}\n\n/**\n * Filter type for file search - can be a comparison or compound filter.\n */\nexport type FileSearchFilter =\n | FileSearchComparisonFilter\n | FileSearchCompoundFilter;\n\n/**\n * Weights for hybrid search balancing semantic and keyword matches.\n */\nexport interface FileSearchHybridSearchWeights {\n /**\n * The weight of semantic embedding matches (0-1).\n */\n embeddingWeight: number;\n /**\n * The weight of keyword/text matches (0-1).\n */\n textWeight: number;\n}\n\n/**\n * Ranking options for file search results.\n */\nexport interface FileSearchRankingOptions {\n /**\n * The ranker to use for the file search.\n * - `auto`: Automatically select the best ranker\n * - `default-2024-11-15`: Default ranker as of November 2024\n */\n ranker?: \"auto\" | \"default-2024-11-15\";\n /**\n * The score threshold for results (0-1).\n * Numbers closer to 1 return only the most relevant results but may return fewer.\n */\n scoreThreshold?: number;\n /**\n * Weights that control how reciprocal rank fusion balances semantic\n * embedding matches versus sparse keyword matches when hybrid search is enabled.\n */\n hybridSearch?: FileSearchHybridSearchWeights;\n}\n\n/**\n * Options for the File Search tool.\n */\nexport interface FileSearchOptions {\n /**\n * The IDs of the vector stores to search.\n * You must have previously created vector stores and uploaded files to them.\n */\n vectorStoreIds: string[];\n /**\n * The maximum number of results to return.\n * Must be between 1 and 50 inclusive.\n */\n maxNumResults?: number;\n /**\n * A filter to apply based on file attributes/metadata.\n * Use this to narrow down search results to specific categories or file types.\n */\n filters?: FileSearchFilter;\n /**\n * Ranking options to customize how results are scored and ordered.\n */\n rankingOptions?: FileSearchRankingOptions;\n}\n\n/**\n * OpenAI File Search tool type for the Responses API.\n */\nexport type FileSearchTool = OpenAIClient.Responses.FileSearchTool;\n\n/**\n * Converts ranking options to the API format.\n */\nfunction convertRankingOptions(\n options: FileSearchRankingOptions | undefined\n): OpenAIClient.Responses.FileSearchTool.RankingOptions | undefined {\n if (!options) return undefined;\n return {\n ranker: options.ranker,\n score_threshold: options.scoreThreshold,\n hybrid_search: options.hybridSearch\n ? {\n embedding_weight: options.hybridSearch.embeddingWeight,\n text_weight: options.hybridSearch.textWeight,\n }\n : undefined,\n };\n}\n\n/**\n * Creates a File Search tool that allows models to search your files\n * for relevant information using semantic and keyword search.\n *\n * File Search enables models to retrieve information from a knowledge base\n * of previously uploaded files stored in vector stores. This is a hosted tool\n * managed by OpenAI - you don't need to implement the search execution yourself.\n *\n * **Prerequisites**: Before using File Search, you must:\n * 1. Upload files to the File API with `purpose: \"assistants\"`\n * 2. Create a vector store\n * 3. Add files to the vector store\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-file-search | OpenAI File Search Documentation}\n *\n * @param options - Configuration options for the File Search tool\n * @returns A File Search tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4.1\" });\n *\n * // Basic usage with a vector store\n * const response = await model.invoke(\n * \"What is deep research by OpenAI?\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"]\n * })]\n * }\n * );\n *\n * // Limit the number of results for lower latency\n * const response = await model.invoke(\n * \"Find information about pricing\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * maxNumResults: 5\n * })]\n * }\n * );\n *\n * // With metadata filtering\n * const response = await model.invoke(\n * \"Find recent blog posts about AI\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * filters: {\n * type: \"eq\",\n * key: \"category\",\n * value: \"blog\"\n * }\n * })]\n * }\n * );\n *\n * // With compound filters (AND/OR)\n * const response = await model.invoke(\n * \"Find technical docs from 2024\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * filters: {\n * type: \"and\",\n * filters: [\n * { type: \"eq\", key: \"category\", value: \"technical\" },\n * { type: \"gte\", key: \"year\", value: 2024 }\n * ]\n * }\n * })]\n * }\n * );\n *\n * // With ranking options for more relevant results\n * const response = await model.invoke(\n * \"Find the most relevant information\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\"],\n * rankingOptions: {\n * scoreThreshold: 0.8,\n * ranker: \"auto\"\n * }\n * })]\n * }\n * );\n *\n * // Search multiple vector stores\n * const response = await model.invoke(\n * \"Search across all knowledge bases\",\n * {\n * tools: [tools.fileSearch({\n * vectorStoreIds: [\"vs_abc123\", \"vs_def456\"]\n * })]\n * }\n * );\n * ```\n *\n * @remarks\n * - Vector stores must be created and populated before using this tool\n * - The tool returns file citations in the response annotations\n * - Use `include: [\"file_search_call.results\"]` in the API call to get search results\n * - Supported file types include PDF, DOCX, TXT, MD, and many code file formats\n */\nexport function fileSearch(options: FileSearchOptions): ServerTool {\n return {\n type: \"file_search\",\n vector_store_ids: options.vectorStoreIds,\n max_num_results: options.maxNumResults,\n filters: options.filters as FileSearchTool[\"filters\"],\n ranking_options: convertRankingOptions(options.rankingOptions),\n } satisfies FileSearchTool;\n}\n"],"mappings":";;;;AAiIA,SAAS,sBACPA,SACkE;AAClE,KAAI,CAAC,QAAS,QAAO;AACrB,QAAO;EACL,QAAQ,QAAQ;EAChB,iBAAiB,QAAQ;EACzB,eAAe,QAAQ,eACnB;GACE,kBAAkB,QAAQ,aAAa;GACvC,aAAa,QAAQ,aAAa;EACnC,IACD;CACL;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8GD,SAAgB,WAAWC,SAAwC;AACjE,QAAO;EACL,MAAM;EACN,kBAAkB,QAAQ;EAC1B,iBAAiB,QAAQ;EACzB,SAAS,QAAQ;EACjB,iBAAiB,sBAAsB,QAAQ,eAAe;CAC/D;AACF"}
@@ -0,0 +1,128 @@
1
+
2
+ //#region src/tools/imageGeneration.ts
3
+ /**
4
+ * Converts input mask options to the API format.
5
+ */
6
+ function convertInputImageMask(mask) {
7
+ if (!mask) return void 0;
8
+ return {
9
+ image_url: mask.imageUrl,
10
+ file_id: mask.fileId
11
+ };
12
+ }
13
+ /**
14
+ * Creates an Image Generation tool that allows models to generate or edit images
15
+ * using text prompts and optional image inputs.
16
+ *
17
+ * The image generation tool leverages the GPT Image model and automatically
18
+ * optimizes text inputs for improved performance. When included in a request,
19
+ * the model can decide when and how to generate images as part of the conversation.
20
+ *
21
+ * **Key Features**:
22
+ * - Generate images from text descriptions
23
+ * - Edit existing images with text instructions
24
+ * - Multi-turn image editing by referencing previous responses
25
+ * - Configurable output options (size, quality, format)
26
+ * - Streaming support for partial image generation
27
+ *
28
+ * **Prompting Tips**:
29
+ * - Use terms like "draw" or "edit" in your prompt for best results
30
+ * - For combining images, say "edit the first image by adding this element" instead of "combine"
31
+ *
32
+ * @see {@link https://platform.openai.com/docs/guides/tools-image-generation | OpenAI Image Generation Documentation}
33
+ *
34
+ * @param options - Configuration options for the Image Generation tool
35
+ * @returns An Image Generation tool definition to be passed to the OpenAI Responses API
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * import { ChatOpenAI, tools } from "@langchain/openai";
40
+ *
41
+ * const model = new ChatOpenAI({ model: "gpt-4o" });
42
+ *
43
+ * // Basic usage - generate an image
44
+ * const response = await model.invoke(
45
+ * "Generate an image of a gray tabby cat hugging an otter with an orange scarf",
46
+ * { tools: [tools.imageGeneration()] }
47
+ * );
48
+ *
49
+ * // Access the generated image
50
+ * const imageData = response.additional_kwargs.tool_outputs?.find(
51
+ * (output) => output.type === "image_generation_call"
52
+ * );
53
+ * if (imageData?.result) {
54
+ * // imageData.result contains the base64-encoded image
55
+ * const fs = await import("fs");
56
+ * fs.writeFileSync("output.png", Buffer.from(imageData.result, "base64"));
57
+ * }
58
+ *
59
+ * // With custom options
60
+ * const response = await model.invoke(
61
+ * "Draw a beautiful sunset over mountains",
62
+ * {
63
+ * tools: [tools.imageGeneration({
64
+ * size: "1536x1024", // Landscape format
65
+ * quality: "high", // Higher quality output
66
+ * outputFormat: "jpeg", // JPEG format
67
+ * outputCompression: 90, // 90% compression
68
+ * })]
69
+ * }
70
+ * );
71
+ *
72
+ * // With transparent background
73
+ * const response = await model.invoke(
74
+ * "Create a logo with a transparent background",
75
+ * {
76
+ * tools: [tools.imageGeneration({
77
+ * background: "transparent",
78
+ * outputFormat: "png",
79
+ * })]
80
+ * }
81
+ * );
82
+ *
83
+ * // Force the model to use image generation
84
+ * const response = await model.invoke(
85
+ * "A serene lake at dawn",
86
+ * {
87
+ * tools: [tools.imageGeneration()],
88
+ * tool_choice: { type: "image_generation" },
89
+ * }
90
+ * );
91
+ *
92
+ * // Enable streaming with partial images
93
+ * const response = await model.invoke(
94
+ * "Draw a detailed fantasy castle",
95
+ * {
96
+ * tools: [tools.imageGeneration({
97
+ * partialImages: 2, // Get 2 partial images during generation
98
+ * })]
99
+ * }
100
+ * );
101
+ * ```
102
+ *
103
+ * @remarks
104
+ * - Supported models: gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, o3
105
+ * - The image generation process always uses `gpt-image-1` model internally
106
+ * - The model will automatically revise prompts for improved performance
107
+ * - Access the revised prompt via `revised_prompt` field in the output
108
+ * - Multi-turn editing is supported by passing previous response messages
109
+ */
110
+ function imageGeneration(options) {
111
+ return {
112
+ type: "image_generation",
113
+ background: options?.background,
114
+ input_fidelity: options?.inputFidelity,
115
+ input_image_mask: convertInputImageMask(options?.inputImageMask),
116
+ model: options?.model,
117
+ moderation: options?.moderation,
118
+ output_compression: options?.outputCompression,
119
+ output_format: options?.outputFormat,
120
+ partial_images: options?.partialImages,
121
+ quality: options?.quality,
122
+ size: options?.size
123
+ };
124
+ }
125
+
126
+ //#endregion
127
+ exports.imageGeneration = imageGeneration;
128
+ //# sourceMappingURL=imageGeneration.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageGeneration.cjs","names":["mask: ImageGenerationInputMask | undefined","options?: ImageGenerationOptions"],"sources":["../../src/tools/imageGeneration.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n\n/**\n * Optional mask for inpainting. Allows you to specify areas of the image\n * that should be regenerated.\n */\nexport interface ImageGenerationInputMask {\n /**\n * Base64-encoded mask image URL.\n */\n imageUrl?: string;\n /**\n * File ID for the mask image (uploaded via OpenAI File API).\n */\n fileId?: string;\n}\n\n/**\n * Options for the Image Generation tool.\n */\nexport interface ImageGenerationOptions {\n /**\n * Background type for the generated image.\n * - `transparent`: Generate image with transparent background\n * - `opaque`: Generate image with opaque background\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n background?: \"transparent\" | \"opaque\" | \"auto\";\n\n /**\n * Control how much effort the model will exert to match the style and features,\n * especially facial features, of input images. This parameter is only supported\n * for `gpt-image-1`. Unsupported for `gpt-image-1-mini`.\n * - `high`: Higher fidelity to input images\n * - `low`: Lower fidelity to input images\n * @default \"low\"\n */\n inputFidelity?: \"high\" | \"low\";\n\n /**\n * Optional mask for inpainting. Use this to specify areas of an image\n * that should be regenerated.\n */\n inputImageMask?: ImageGenerationInputMask;\n\n /**\n * The image generation model to use.\n * @default \"gpt-image-1\"\n */\n model?: \"gpt-image-1\" | \"gpt-image-1-mini\";\n\n /**\n * Moderation level for the generated image.\n * - `auto`: Standard moderation\n * - `low`: Less restrictive moderation\n * @default \"auto\"\n */\n moderation?: \"auto\" | \"low\";\n\n /**\n * Compression level for the output image (0-100).\n * Only applies to JPEG and WebP formats.\n * @default 100\n */\n outputCompression?: number;\n\n /**\n * The output format of the generated image.\n * @default \"png\"\n */\n outputFormat?: \"png\" | \"webp\" | \"jpeg\";\n\n /**\n * Number of partial images to generate in streaming mode (0-3).\n * When set, the model will return partial images as they are generated,\n * providing faster visual feedback.\n * @default 0\n */\n partialImages?: number;\n\n /**\n * The quality of the generated image.\n * - `low`: Faster generation, lower quality\n * - `medium`: Balanced generation time and quality\n * - `high`: Slower generation, higher quality\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n quality?: \"low\" | \"medium\" | \"high\" | \"auto\";\n\n /**\n * The size of the generated image.\n * - `1024x1024`: Square format\n * - `1024x1536`: Portrait format\n * - `1536x1024`: Landscape format\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n size?: \"1024x1024\" | \"1024x1536\" | \"1536x1024\" | \"auto\";\n}\n\n/**\n * OpenAI Image Generation tool type for the Responses API.\n */\nexport type ImageGenerationTool = OpenAIClient.Responses.Tool.ImageGeneration;\n\n/**\n * Converts input mask options to the API format.\n */\nfunction convertInputImageMask(\n mask: ImageGenerationInputMask | undefined\n): ImageGenerationTool[\"input_image_mask\"] {\n if (!mask) return undefined;\n return {\n image_url: mask.imageUrl,\n file_id: mask.fileId,\n };\n}\n\n/**\n * Creates an Image Generation tool that allows models to generate or edit images\n * using text prompts and optional image inputs.\n *\n * The image generation tool leverages the GPT Image model and automatically\n * optimizes text inputs for improved performance. When included in a request,\n * the model can decide when and how to generate images as part of the conversation.\n *\n * **Key Features**:\n * - Generate images from text descriptions\n * - Edit existing images with text instructions\n * - Multi-turn image editing by referencing previous responses\n * - Configurable output options (size, quality, format)\n * - Streaming support for partial image generation\n *\n * **Prompting Tips**:\n * - Use terms like \"draw\" or \"edit\" in your prompt for best results\n * - For combining images, say \"edit the first image by adding this element\" instead of \"combine\"\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-image-generation | OpenAI Image Generation Documentation}\n *\n * @param options - Configuration options for the Image Generation tool\n * @returns An Image Generation tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4o\" });\n *\n * // Basic usage - generate an image\n * const response = await model.invoke(\n * \"Generate an image of a gray tabby cat hugging an otter with an orange scarf\",\n * { tools: [tools.imageGeneration()] }\n * );\n *\n * // Access the generated image\n * const imageData = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"image_generation_call\"\n * );\n * if (imageData?.result) {\n * // imageData.result contains the base64-encoded image\n * const fs = await import(\"fs\");\n * fs.writeFileSync(\"output.png\", Buffer.from(imageData.result, \"base64\"));\n * }\n *\n * // With custom options\n * const response = await model.invoke(\n * \"Draw a beautiful sunset over mountains\",\n * {\n * tools: [tools.imageGeneration({\n * size: \"1536x1024\", // Landscape format\n * quality: \"high\", // Higher quality output\n * outputFormat: \"jpeg\", // JPEG format\n * outputCompression: 90, // 90% compression\n * })]\n * }\n * );\n *\n * // With transparent background\n * const response = await model.invoke(\n * \"Create a logo with a transparent background\",\n * {\n * tools: [tools.imageGeneration({\n * background: \"transparent\",\n * outputFormat: \"png\",\n * })]\n * }\n * );\n *\n * // Force the model to use image generation\n * const response = await model.invoke(\n * \"A serene lake at dawn\",\n * {\n * tools: [tools.imageGeneration()],\n * tool_choice: { type: \"image_generation\" },\n * }\n * );\n *\n * // Enable streaming with partial images\n * const response = await model.invoke(\n * \"Draw a detailed fantasy castle\",\n * {\n * tools: [tools.imageGeneration({\n * partialImages: 2, // Get 2 partial images during generation\n * })]\n * }\n * );\n * ```\n *\n * @remarks\n * - Supported models: gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, o3\n * - The image generation process always uses `gpt-image-1` model internally\n * - The model will automatically revise prompts for improved performance\n * - Access the revised prompt via `revised_prompt` field in the output\n * - Multi-turn editing is supported by passing previous response messages\n */\nexport function imageGeneration(options?: ImageGenerationOptions): ServerTool {\n return {\n type: \"image_generation\",\n background: options?.background,\n input_fidelity: options?.inputFidelity,\n input_image_mask: convertInputImageMask(options?.inputImageMask),\n model: options?.model,\n moderation: options?.moderation,\n output_compression: options?.outputCompression,\n output_format: options?.outputFormat,\n partial_images: options?.partialImages,\n quality: options?.quality,\n size: options?.size,\n } satisfies ImageGenerationTool;\n}\n"],"mappings":";;;;;AA+GA,SAAS,sBACPA,MACyC;AACzC,KAAI,CAAC,KAAM,QAAO;AAClB,QAAO;EACL,WAAW,KAAK;EAChB,SAAS,KAAK;CACf;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGD,SAAgB,gBAAgBC,SAA8C;AAC5E,QAAO;EACL,MAAM;EACN,YAAY,SAAS;EACrB,gBAAgB,SAAS;EACzB,kBAAkB,sBAAsB,SAAS,eAAe;EAChE,OAAO,SAAS;EAChB,YAAY,SAAS;EACrB,oBAAoB,SAAS;EAC7B,eAAe,SAAS;EACxB,gBAAgB,SAAS;EACzB,SAAS,SAAS;EAClB,MAAM,SAAS;CAChB;AACF"}
@@ -0,0 +1,199 @@
1
+ import { OpenAI as OpenAI$1 } from "openai";
2
+ import { ServerTool } from "@langchain/core/tools";
3
+
4
+ //#region src/tools/imageGeneration.d.ts
5
+
6
+ /**
7
+ * Optional mask for inpainting. Allows you to specify areas of the image
8
+ * that should be regenerated.
9
+ */
10
+ interface ImageGenerationInputMask {
11
+ /**
12
+ * Base64-encoded mask image URL.
13
+ */
14
+ imageUrl?: string;
15
+ /**
16
+ * File ID for the mask image (uploaded via OpenAI File API).
17
+ */
18
+ fileId?: string;
19
+ }
20
+ /**
21
+ * Options for the Image Generation tool.
22
+ */
23
+ interface ImageGenerationOptions {
24
+ /**
25
+ * Background type for the generated image.
26
+ * - `transparent`: Generate image with transparent background
27
+ * - `opaque`: Generate image with opaque background
28
+ * - `auto`: Let the model decide based on the prompt
29
+ * @default "auto"
30
+ */
31
+ background?: "transparent" | "opaque" | "auto";
32
+ /**
33
+ * Control how much effort the model will exert to match the style and features,
34
+ * especially facial features, of input images. This parameter is only supported
35
+ * for `gpt-image-1`. Unsupported for `gpt-image-1-mini`.
36
+ * - `high`: Higher fidelity to input images
37
+ * - `low`: Lower fidelity to input images
38
+ * @default "low"
39
+ */
40
+ inputFidelity?: "high" | "low";
41
+ /**
42
+ * Optional mask for inpainting. Use this to specify areas of an image
43
+ * that should be regenerated.
44
+ */
45
+ inputImageMask?: ImageGenerationInputMask;
46
+ /**
47
+ * The image generation model to use.
48
+ * @default "gpt-image-1"
49
+ */
50
+ model?: "gpt-image-1" | "gpt-image-1-mini";
51
+ /**
52
+ * Moderation level for the generated image.
53
+ * - `auto`: Standard moderation
54
+ * - `low`: Less restrictive moderation
55
+ * @default "auto"
56
+ */
57
+ moderation?: "auto" | "low";
58
+ /**
59
+ * Compression level for the output image (0-100).
60
+ * Only applies to JPEG and WebP formats.
61
+ * @default 100
62
+ */
63
+ outputCompression?: number;
64
+ /**
65
+ * The output format of the generated image.
66
+ * @default "png"
67
+ */
68
+ outputFormat?: "png" | "webp" | "jpeg";
69
+ /**
70
+ * Number of partial images to generate in streaming mode (0-3).
71
+ * When set, the model will return partial images as they are generated,
72
+ * providing faster visual feedback.
73
+ * @default 0
74
+ */
75
+ partialImages?: number;
76
+ /**
77
+ * The quality of the generated image.
78
+ * - `low`: Faster generation, lower quality
79
+ * - `medium`: Balanced generation time and quality
80
+ * - `high`: Slower generation, higher quality
81
+ * - `auto`: Let the model decide based on the prompt
82
+ * @default "auto"
83
+ */
84
+ quality?: "low" | "medium" | "high" | "auto";
85
+ /**
86
+ * The size of the generated image.
87
+ * - `1024x1024`: Square format
88
+ * - `1024x1536`: Portrait format
89
+ * - `1536x1024`: Landscape format
90
+ * - `auto`: Let the model decide based on the prompt
91
+ * @default "auto"
92
+ */
93
+ size?: "1024x1024" | "1024x1536" | "1536x1024" | "auto";
94
+ }
95
+ /**
96
+ * OpenAI Image Generation tool type for the Responses API.
97
+ */
98
+ type ImageGenerationTool = OpenAI$1.Responses.Tool.ImageGeneration;
99
+ /**
100
+ * Creates an Image Generation tool that allows models to generate or edit images
101
+ * using text prompts and optional image inputs.
102
+ *
103
+ * The image generation tool leverages the GPT Image model and automatically
104
+ * optimizes text inputs for improved performance. When included in a request,
105
+ * the model can decide when and how to generate images as part of the conversation.
106
+ *
107
+ * **Key Features**:
108
+ * - Generate images from text descriptions
109
+ * - Edit existing images with text instructions
110
+ * - Multi-turn image editing by referencing previous responses
111
+ * - Configurable output options (size, quality, format)
112
+ * - Streaming support for partial image generation
113
+ *
114
+ * **Prompting Tips**:
115
+ * - Use terms like "draw" or "edit" in your prompt for best results
116
+ * - For combining images, say "edit the first image by adding this element" instead of "combine"
117
+ *
118
+ * @see {@link https://platform.openai.com/docs/guides/tools-image-generation | OpenAI Image Generation Documentation}
119
+ *
120
+ * @param options - Configuration options for the Image Generation tool
121
+ * @returns An Image Generation tool definition to be passed to the OpenAI Responses API
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * import { ChatOpenAI, tools } from "@langchain/openai";
126
+ *
127
+ * const model = new ChatOpenAI({ model: "gpt-4o" });
128
+ *
129
+ * // Basic usage - generate an image
130
+ * const response = await model.invoke(
131
+ * "Generate an image of a gray tabby cat hugging an otter with an orange scarf",
132
+ * { tools: [tools.imageGeneration()] }
133
+ * );
134
+ *
135
+ * // Access the generated image
136
+ * const imageData = response.additional_kwargs.tool_outputs?.find(
137
+ * (output) => output.type === "image_generation_call"
138
+ * );
139
+ * if (imageData?.result) {
140
+ * // imageData.result contains the base64-encoded image
141
+ * const fs = await import("fs");
142
+ * fs.writeFileSync("output.png", Buffer.from(imageData.result, "base64"));
143
+ * }
144
+ *
145
+ * // With custom options
146
+ * const response = await model.invoke(
147
+ * "Draw a beautiful sunset over mountains",
148
+ * {
149
+ * tools: [tools.imageGeneration({
150
+ * size: "1536x1024", // Landscape format
151
+ * quality: "high", // Higher quality output
152
+ * outputFormat: "jpeg", // JPEG format
153
+ * outputCompression: 90, // 90% compression
154
+ * })]
155
+ * }
156
+ * );
157
+ *
158
+ * // With transparent background
159
+ * const response = await model.invoke(
160
+ * "Create a logo with a transparent background",
161
+ * {
162
+ * tools: [tools.imageGeneration({
163
+ * background: "transparent",
164
+ * outputFormat: "png",
165
+ * })]
166
+ * }
167
+ * );
168
+ *
169
+ * // Force the model to use image generation
170
+ * const response = await model.invoke(
171
+ * "A serene lake at dawn",
172
+ * {
173
+ * tools: [tools.imageGeneration()],
174
+ * tool_choice: { type: "image_generation" },
175
+ * }
176
+ * );
177
+ *
178
+ * // Enable streaming with partial images
179
+ * const response = await model.invoke(
180
+ * "Draw a detailed fantasy castle",
181
+ * {
182
+ * tools: [tools.imageGeneration({
183
+ * partialImages: 2, // Get 2 partial images during generation
184
+ * })]
185
+ * }
186
+ * );
187
+ * ```
188
+ *
189
+ * @remarks
190
+ * - Supported models: gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, o3
191
+ * - The image generation process always uses `gpt-image-1` model internally
192
+ * - The model will automatically revise prompts for improved performance
193
+ * - Access the revised prompt via `revised_prompt` field in the output
194
+ * - Multi-turn editing is supported by passing previous response messages
195
+ */
196
+ declare function imageGeneration(options?: ImageGenerationOptions): ServerTool;
197
+ //#endregion
198
+ export { ImageGenerationInputMask, ImageGenerationOptions, ImageGenerationTool, imageGeneration };
199
+ //# sourceMappingURL=imageGeneration.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageGeneration.d.cts","names":["OpenAI","OpenAIClient","ServerTool","ImageGenerationInputMask","ImageGenerationOptions","ImageGenerationTool","Responses","Tool","ImageGeneration","imageGeneration"],"sources":["../../src/tools/imageGeneration.d.ts"],"sourcesContent":["import { OpenAI as OpenAIClient } from \"openai\";\nimport type { ServerTool } from \"@langchain/core/tools\";\n/**\n * Optional mask for inpainting. Allows you to specify areas of the image\n * that should be regenerated.\n */\nexport interface ImageGenerationInputMask {\n /**\n * Base64-encoded mask image URL.\n */\n imageUrl?: string;\n /**\n * File ID for the mask image (uploaded via OpenAI File API).\n */\n fileId?: string;\n}\n/**\n * Options for the Image Generation tool.\n */\nexport interface ImageGenerationOptions {\n /**\n * Background type for the generated image.\n * - `transparent`: Generate image with transparent background\n * - `opaque`: Generate image with opaque background\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n background?: \"transparent\" | \"opaque\" | \"auto\";\n /**\n * Control how much effort the model will exert to match the style and features,\n * especially facial features, of input images. This parameter is only supported\n * for `gpt-image-1`. Unsupported for `gpt-image-1-mini`.\n * - `high`: Higher fidelity to input images\n * - `low`: Lower fidelity to input images\n * @default \"low\"\n */\n inputFidelity?: \"high\" | \"low\";\n /**\n * Optional mask for inpainting. Use this to specify areas of an image\n * that should be regenerated.\n */\n inputImageMask?: ImageGenerationInputMask;\n /**\n * The image generation model to use.\n * @default \"gpt-image-1\"\n */\n model?: \"gpt-image-1\" | \"gpt-image-1-mini\";\n /**\n * Moderation level for the generated image.\n * - `auto`: Standard moderation\n * - `low`: Less restrictive moderation\n * @default \"auto\"\n */\n moderation?: \"auto\" | \"low\";\n /**\n * Compression level for the output image (0-100).\n * Only applies to JPEG and WebP formats.\n * @default 100\n */\n outputCompression?: number;\n /**\n * The output format of the generated image.\n * @default \"png\"\n */\n outputFormat?: \"png\" | \"webp\" | \"jpeg\";\n /**\n * Number of partial images to generate in streaming mode (0-3).\n * When set, the model will return partial images as they are generated,\n * providing faster visual feedback.\n * @default 0\n */\n partialImages?: number;\n /**\n * The quality of the generated image.\n * - `low`: Faster generation, lower quality\n * - `medium`: Balanced generation time and quality\n * - `high`: Slower generation, higher quality\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n quality?: \"low\" | \"medium\" | \"high\" | \"auto\";\n /**\n * The size of the generated image.\n * - `1024x1024`: Square format\n * - `1024x1536`: Portrait format\n * - `1536x1024`: Landscape format\n * - `auto`: Let the model decide based on the prompt\n * @default \"auto\"\n */\n size?: \"1024x1024\" | \"1024x1536\" | \"1536x1024\" | \"auto\";\n}\n/**\n * OpenAI Image Generation tool type for the Responses API.\n */\nexport type ImageGenerationTool = OpenAIClient.Responses.Tool.ImageGeneration;\n/**\n * Creates an Image Generation tool that allows models to generate or edit images\n * using text prompts and optional image inputs.\n *\n * The image generation tool leverages the GPT Image model and automatically\n * optimizes text inputs for improved performance. When included in a request,\n * the model can decide when and how to generate images as part of the conversation.\n *\n * **Key Features**:\n * - Generate images from text descriptions\n * - Edit existing images with text instructions\n * - Multi-turn image editing by referencing previous responses\n * - Configurable output options (size, quality, format)\n * - Streaming support for partial image generation\n *\n * **Prompting Tips**:\n * - Use terms like \"draw\" or \"edit\" in your prompt for best results\n * - For combining images, say \"edit the first image by adding this element\" instead of \"combine\"\n *\n * @see {@link https://platform.openai.com/docs/guides/tools-image-generation | OpenAI Image Generation Documentation}\n *\n * @param options - Configuration options for the Image Generation tool\n * @returns An Image Generation tool definition to be passed to the OpenAI Responses API\n *\n * @example\n * ```typescript\n * import { ChatOpenAI, tools } from \"@langchain/openai\";\n *\n * const model = new ChatOpenAI({ model: \"gpt-4o\" });\n *\n * // Basic usage - generate an image\n * const response = await model.invoke(\n * \"Generate an image of a gray tabby cat hugging an otter with an orange scarf\",\n * { tools: [tools.imageGeneration()] }\n * );\n *\n * // Access the generated image\n * const imageData = response.additional_kwargs.tool_outputs?.find(\n * (output) => output.type === \"image_generation_call\"\n * );\n * if (imageData?.result) {\n * // imageData.result contains the base64-encoded image\n * const fs = await import(\"fs\");\n * fs.writeFileSync(\"output.png\", Buffer.from(imageData.result, \"base64\"));\n * }\n *\n * // With custom options\n * const response = await model.invoke(\n * \"Draw a beautiful sunset over mountains\",\n * {\n * tools: [tools.imageGeneration({\n * size: \"1536x1024\", // Landscape format\n * quality: \"high\", // Higher quality output\n * outputFormat: \"jpeg\", // JPEG format\n * outputCompression: 90, // 90% compression\n * })]\n * }\n * );\n *\n * // With transparent background\n * const response = await model.invoke(\n * \"Create a logo with a transparent background\",\n * {\n * tools: [tools.imageGeneration({\n * background: \"transparent\",\n * outputFormat: \"png\",\n * })]\n * }\n * );\n *\n * // Force the model to use image generation\n * const response = await model.invoke(\n * \"A serene lake at dawn\",\n * {\n * tools: [tools.imageGeneration()],\n * tool_choice: { type: \"image_generation\" },\n * }\n * );\n *\n * // Enable streaming with partial images\n * const response = await model.invoke(\n * \"Draw a detailed fantasy castle\",\n * {\n * tools: [tools.imageGeneration({\n * partialImages: 2, // Get 2 partial images during generation\n * })]\n * }\n * );\n * ```\n *\n * @remarks\n * - Supported models: gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, o3\n * - The image generation process always uses `gpt-image-1` model internally\n * - The model will automatically revise prompts for improved performance\n * - Access the revised prompt via `revised_prompt` field in the output\n * - Multi-turn editing is supported by passing previous response messages\n */\nexport declare function imageGeneration(options?: ImageGenerationOptions): ServerTool;\n//# sourceMappingURL=imageGeneration.d.ts.map"],"mappings":";;;;;;;AAMA;AAaA;AA2EYK,UAxFKF,wBAAAA,CAwFiBF;EAkGVQ;;;;;;;;;;;;UA7KPL,sBAAAA;;;;;;;;;;;;;;;;;;;;;;mBAsBID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqDTE,mBAAAA,GAAsBJ,QAAAA,CAAaK,SAAAA,CAAUC,IAAAA,CAAKC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkGtCC,eAAAA,WAA0BL,yBAAyBF"}