@effect/ai-openai 4.0.0-beta.7 → 4.0.0-beta.71

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 (58) hide show
  1. package/dist/Generated.d.ts +66734 -37723
  2. package/dist/Generated.d.ts.map +1 -1
  3. package/dist/Generated.js +1 -1
  4. package/dist/Generated.js.map +1 -1
  5. package/dist/OpenAiClient.d.ts +167 -27
  6. package/dist/OpenAiClient.d.ts.map +1 -1
  7. package/dist/OpenAiClient.js +337 -44
  8. package/dist/OpenAiClient.js.map +1 -1
  9. package/dist/OpenAiClientGenerated.d.ts +91 -0
  10. package/dist/OpenAiClientGenerated.d.ts.map +1 -0
  11. package/dist/OpenAiClientGenerated.js +84 -0
  12. package/dist/OpenAiClientGenerated.js.map +1 -0
  13. package/dist/OpenAiConfig.d.ts +114 -10
  14. package/dist/OpenAiConfig.d.ts.map +1 -1
  15. package/dist/OpenAiConfig.js +68 -7
  16. package/dist/OpenAiConfig.js.map +1 -1
  17. package/dist/OpenAiEmbeddingModel.d.ts +213 -0
  18. package/dist/OpenAiEmbeddingModel.d.ts.map +1 -0
  19. package/dist/OpenAiEmbeddingModel.js +219 -0
  20. package/dist/OpenAiEmbeddingModel.js.map +1 -0
  21. package/dist/OpenAiError.d.ts +168 -35
  22. package/dist/OpenAiError.d.ts.map +1 -1
  23. package/dist/OpenAiError.js +1 -1
  24. package/dist/OpenAiLanguageModel.d.ts +384 -62
  25. package/dist/OpenAiLanguageModel.d.ts.map +1 -1
  26. package/dist/OpenAiLanguageModel.js +416 -166
  27. package/dist/OpenAiLanguageModel.js.map +1 -1
  28. package/dist/OpenAiSchema.d.ts +2298 -0
  29. package/dist/OpenAiSchema.d.ts.map +1 -0
  30. package/dist/OpenAiSchema.js +814 -0
  31. package/dist/OpenAiSchema.js.map +1 -0
  32. package/dist/OpenAiTelemetry.d.ts +59 -18
  33. package/dist/OpenAiTelemetry.d.ts.map +1 -1
  34. package/dist/OpenAiTelemetry.js +35 -8
  35. package/dist/OpenAiTelemetry.js.map +1 -1
  36. package/dist/OpenAiTool.d.ts +157 -62
  37. package/dist/OpenAiTool.d.ts.map +1 -1
  38. package/dist/OpenAiTool.js +134 -39
  39. package/dist/OpenAiTool.js.map +1 -1
  40. package/dist/index.d.ts +19 -33
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +19 -33
  43. package/dist/index.js.map +1 -1
  44. package/dist/internal/errors.js +4 -4
  45. package/dist/internal/errors.js.map +1 -1
  46. package/package.json +3 -3
  47. package/src/Generated.ts +9858 -5044
  48. package/src/OpenAiClient.ts +513 -95
  49. package/src/OpenAiClientGenerated.ts +202 -0
  50. package/src/OpenAiConfig.ts +115 -11
  51. package/src/OpenAiEmbeddingModel.ts +357 -0
  52. package/src/OpenAiError.ts +170 -35
  53. package/src/OpenAiLanguageModel.ts +802 -167
  54. package/src/OpenAiSchema.ts +1289 -0
  55. package/src/OpenAiTelemetry.ts +81 -23
  56. package/src/OpenAiTool.ts +135 -40
  57. package/src/index.ts +22 -33
  58. package/src/internal/errors.ts +6 -4
@@ -1,11 +1,28 @@
1
1
  /**
2
- * OpenAI telemetry attributes for OpenTelemetry integration.
2
+ * OpenAI-specific telemetry annotations for GenAI spans.
3
3
  *
4
- * Provides OpenAI-specific GenAI telemetry attributes following OpenTelemetry
5
- * semantic conventions, extending the base GenAI attributes with OpenAI-specific
6
- * request and response metadata.
4
+ * This module extends the provider-neutral GenAI telemetry model with
5
+ * attributes that only exist on OpenAI requests and responses. Use
6
+ * {@link addGenAIAnnotations} when an OpenAI operation already has an
7
+ * OpenTelemetry span and you want to record both standard GenAI metadata and
8
+ * OpenAI details such as response format, requested service tier, actual
9
+ * service tier, or system fingerprint.
7
10
  *
8
- * @since 1.0.0
11
+ * **Mental model**
12
+ *
13
+ * The public option shape stays idiomatic TypeScript (`responseFormat`,
14
+ * `serviceTier`, `systemFingerprint`). When annotations are applied, the
15
+ * attributes are written to the span under OpenTelemetry semantic-convention
16
+ * keys such as `gen_ai.openai.request.response_format` and
17
+ * `gen_ai.openai.response.system_fingerprint`.
18
+ *
19
+ * **Gotchas**
20
+ *
21
+ * Annotation mutates the provided span in place. It does not create, end, or
22
+ * export spans, and OpenAI-specific attributes are only added when the
23
+ * `openai.request` or `openai.response` option objects are present.
24
+ *
25
+ * @since 4.0.0
9
26
  */
10
27
  import { dual } from "effect/Function"
11
28
  import * as String from "effect/String"
@@ -17,10 +34,14 @@ import * as Telemetry from "effect/unstable/ai/Telemetry"
17
34
  * The attributes used to describe telemetry in the context of Generative
18
35
  * Artificial Intelligence (GenAI) Models requests and responses.
19
36
  *
20
- * {@see https://opentelemetry.io/docs/specs/semconv/attributes-registry/gen-ai/}
37
+ * **Details**
38
+ *
39
+ * These attributes follow the OpenTelemetry generative AI semantic
40
+ * conventions:
41
+ * https://opentelemetry.io/docs/specs/semconv/attributes-registry/gen-ai/
21
42
  *
22
- * @since 1.0.0
23
43
  * @category models
44
+ * @since 4.0.0
24
45
  */
25
46
  export type OpenAiTelemetryAttributes = Simplify<
26
47
  & Telemetry.GenAITelemetryAttributes
@@ -32,8 +53,8 @@ export type OpenAiTelemetryAttributes = Simplify<
32
53
  * All telemetry attributes which are part of the GenAI specification,
33
54
  * including the OpenAi-specific attributes.
34
55
  *
35
- * @since 1.0.0
36
56
  * @category models
57
+ * @since 4.0.0
37
58
  */
38
59
  export type AllAttributes = Telemetry.AllAttributes & RequestAttributes & ResponseAttributes
39
60
 
@@ -41,8 +62,8 @@ export type AllAttributes = Telemetry.AllAttributes & RequestAttributes & Respon
41
62
  * Telemetry attributes which are part of the GenAI specification and are
42
63
  * namespaced by `gen_ai.openai.request`.
43
64
  *
44
- * @since 1.0.0
45
65
  * @category models
66
+ * @since 4.0.0
46
67
  */
47
68
  export interface RequestAttributes {
48
69
  /**
@@ -59,8 +80,8 @@ export interface RequestAttributes {
59
80
  * Telemetry attributes which are part of the GenAI specification and are
60
81
  * namespaced by `gen_ai.openai.response`.
61
82
  *
62
- * @since 1.0.0
63
83
  * @category models
84
+ * @since 4.0.0
64
85
  */
65
86
  export interface ResponseAttributes {
66
87
  /**
@@ -78,11 +99,13 @@ export interface ResponseAttributes {
78
99
  * The `gen_ai.openai.request.response_format` attribute has the following
79
100
  * list of well-known values.
80
101
  *
102
+ * **Details**
103
+ *
81
104
  * If one of them applies, then the respective value **MUST** be used;
82
105
  * otherwise, a custom value **MAY** be used.
83
106
  *
84
- * @since 1.0.0
85
107
  * @category models
108
+ * @since 4.0.0
86
109
  */
87
110
  export type WellKnownResponseFormat = "json_object" | "json_schema" | "text"
88
111
 
@@ -90,17 +113,22 @@ export type WellKnownResponseFormat = "json_object" | "json_schema" | "text"
90
113
  * The `gen_ai.openai.request.service_tier` attribute has the following
91
114
  * list of well-known values.
92
115
  *
116
+ * **Details**
117
+ *
93
118
  * If one of them applies, then the respective value **MUST** be used;
94
119
  * otherwise, a custom value **MAY** be used.
95
120
  *
96
- * @since 1.0.0
97
121
  * @category models
122
+ * @since 4.0.0
98
123
  */
99
124
  export type WellKnownServiceTier = "auto" | "default"
100
125
 
101
126
  /**
102
- * @since 1.0.0
103
- * @since models
127
+ * Options accepted by `addGenAIAnnotations`, combining standard GenAI
128
+ * telemetry attributes with optional OpenAI request and response attributes.
129
+ *
130
+ * @category models
131
+ * @since 4.0.0
104
132
  */
105
133
  export type OpenAiTelemetryAttributeOptions = Telemetry.GenAITelemetryAttributeOptions & {
106
134
  openai?: {
@@ -120,30 +148,60 @@ const addOpenAiResponseAttributes = Telemetry.addSpanAttributes("gen_ai.openai.r
120
148
  * Applies the specified OpenAi GenAI telemetry attributes to the provided
121
149
  * `Span`.
122
150
  *
123
- * **NOTE**: This method will mutate the `Span` **in-place**.
151
+ * **When to use**
152
+ *
153
+ * Use to annotate an existing OpenTelemetry span with standard GenAI attributes
154
+ * plus OpenAI-specific request and response metadata.
155
+ *
156
+ * **Gotchas**
124
157
  *
125
- * @since 1.0.0
126
- * @since utilities
158
+ * This method will mutate the `Span` **in-place**.
159
+ *
160
+ * @see {@link OpenAiTelemetryAttributeOptions} for the accepted telemetry attributes
161
+ * @see {@link Telemetry.addGenAIAnnotations} for the provider-neutral annotation helper
162
+ *
163
+ * @category tracing
164
+ * @since 4.0.0
127
165
  */
128
166
  export const addGenAIAnnotations: {
129
167
  /**
130
168
  * Applies the specified OpenAi GenAI telemetry attributes to the provided
131
169
  * `Span`.
132
170
  *
133
- * **NOTE**: This method will mutate the `Span` **in-place**.
171
+ * **When to use**
172
+ *
173
+ * Use to annotate an existing OpenTelemetry span with standard GenAI attributes
174
+ * plus OpenAI-specific request and response metadata.
175
+ *
176
+ * **Gotchas**
177
+ *
178
+ * This method will mutate the `Span` **in-place**.
134
179
  *
135
- * @since 1.0.0
136
- * @since utilities
180
+ * @see {@link OpenAiTelemetryAttributeOptions} for the accepted telemetry attributes
181
+ * @see {@link Telemetry.addGenAIAnnotations} for the provider-neutral annotation helper
182
+ *
183
+ * @category tracing
184
+ * @since 4.0.0
137
185
  */
138
186
  (options: OpenAiTelemetryAttributeOptions): (span: Span) => void
139
187
  /**
140
188
  * Applies the specified OpenAi GenAI telemetry attributes to the provided
141
189
  * `Span`.
142
190
  *
143
- * **NOTE**: This method will mutate the `Span` **in-place**.
191
+ * **When to use**
192
+ *
193
+ * Use to annotate an existing OpenTelemetry span with standard GenAI attributes
194
+ * plus OpenAI-specific request and response metadata.
195
+ *
196
+ * **Gotchas**
197
+ *
198
+ * This method will mutate the `Span` **in-place**.
199
+ *
200
+ * @see {@link OpenAiTelemetryAttributeOptions} for the accepted telemetry attributes
201
+ * @see {@link Telemetry.addGenAIAnnotations} for the provider-neutral annotation helper
144
202
  *
145
- * @since 1.0.0
146
- * @since utilities
203
+ * @category tracing
204
+ * @since 4.0.0
147
205
  */
148
206
  (span: Span, options: OpenAiTelemetryAttributeOptions): void
149
207
  } = dual(2, (span: Span, options: OpenAiTelemetryAttributeOptions) => {
package/src/OpenAiTool.ts CHANGED
@@ -1,10 +1,29 @@
1
1
  /**
2
- * OpenAI provider-defined tools for use with the LanguageModel.
2
+ * OpenAI provider-defined tools for Effect AI language model requests.
3
3
  *
4
- * Provides tools that are natively supported by OpenAI's API, including
5
- * code interpreter, file search, and web search functionality.
4
+ * This module exposes typed descriptors for OpenAI tools such as code
5
+ * interpreter, file search, image generation, MCP, web search, and shell-like
6
+ * local tools. Each descriptor captures the OpenAI provider name, user-facing
7
+ * configuration arguments, provider call parameters, success output schema, and
8
+ * whether the tool call needs an application-provided handler.
6
9
  *
7
- * @since 1.0.0
10
+ * **Mental model**
11
+ *
12
+ * Provider-defined tools are not implementations of the capability themselves.
13
+ * They are schemas and metadata that tell the language model provider which
14
+ * tool to make available and tell Effect AI how to decode any tool calls or
15
+ * tool results that come back.
16
+ *
17
+ * **Common tasks**
18
+ *
19
+ * Use hosted or provider-routed tools such as {@link CodeInterpreter},
20
+ * {@link FileSearch}, {@link ImageGeneration}, {@link Mcp}, {@link WebSearch},
21
+ * and {@link WebSearchPreview} to opt into OpenAI-managed capabilities. Use
22
+ * handler-required tools such as {@link ApplyPatch}, {@link Shell}, and
23
+ * {@link LocalShell} only when your application is prepared to execute the
24
+ * requested local operation and enforce its own safety policy.
25
+ *
26
+ * @since 4.0.0
8
27
  */
9
28
  import * as Schema from "effect/Schema"
10
29
  import * as Tool from "effect/unstable/ai/Tool"
@@ -13,8 +32,8 @@ import * as Generated from "./Generated.ts"
13
32
  /**
14
33
  * Union of all OpenAI provider-defined tools.
15
34
  *
16
- * @since 1.0.0
17
35
  * @category models
36
+ * @since 4.0.0
18
37
  */
19
38
  export type OpenAiTool =
20
39
  | ReturnType<typeof ApplyPatch>
@@ -28,14 +47,18 @@ export type OpenAiTool =
28
47
  | ReturnType<typeof WebSearchPreview>
29
48
 
30
49
  /**
31
- * OpenAI Apply Patch tool.
50
+ * OpenAI Apply Patch tool that allows the model to apply diffs by creating,
51
+ * deleting, or updating files. This local tool runs in your environment and
52
+ * requires a handler to execute file operations.
32
53
  *
33
- * Allows the model to apply diffs by creating, deleting, or updating files.
34
- * This is a local tool that runs in your environment and requires a handler
35
- * to execute file operations.
54
+ * **When to use**
55
+ *
56
+ * Use when you want an OpenAI model to request structured file edits as create,
57
+ * delete, or update operations that your application executes through a local
58
+ * handler.
36
59
  *
37
- * @since 1.0.0
38
60
  * @category tools
61
+ * @since 4.0.0
39
62
  */
40
63
  export const ApplyPatch = Tool.providerDefined({
41
64
  id: "openai.apply_patch",
@@ -53,12 +76,21 @@ export const ApplyPatch = Tool.providerDefined({
53
76
  })
54
77
 
55
78
  /**
56
- * OpenAI Code Interpreter tool.
79
+ * OpenAI Code Interpreter tool that allows the model to execute Python code in
80
+ * a sandboxed environment.
81
+ *
82
+ * **When to use**
83
+ *
84
+ * Use to enable OpenAI-hosted Python execution for a model response.
85
+ *
86
+ * **Details**
57
87
  *
58
- * Allows the model to execute Python code in a sandboxed environment.
88
+ * The tool is configured with a `container` argument. Successful tool calls
89
+ * expose `outputs`, which may contain logs or generated images, or `null` when
90
+ * no outputs are available.
59
91
  *
60
- * @since 1.0.0
61
92
  * @category tools
93
+ * @since 4.0.0
62
94
  */
63
95
  export const CodeInterpreter = Tool.providerDefined({
64
96
  id: "openai.code_interpreter",
@@ -77,12 +109,22 @@ export const CodeInterpreter = Tool.providerDefined({
77
109
  })
78
110
 
79
111
  /**
80
- * OpenAI File Search tool.
112
+ * OpenAI File Search tool that enables the model to search through uploaded
113
+ * files and vector stores.
81
114
  *
82
- * Enables the model to search through uploaded files and vector stores.
115
+ * **When to use**
116
+ *
117
+ * Use to let an OpenAI model search uploaded files through one or more vector
118
+ * stores.
119
+ *
120
+ * **Details**
121
+ *
122
+ * The tool requires `vector_store_ids` and accepts optional `filters`,
123
+ * `max_num_results`, and `ranking_options`. Successful tool calls expose the
124
+ * search `status`, generated `queries`, and optional `results`.
83
125
  *
84
- * @since 1.0.0
85
126
  * @category tools
127
+ * @since 4.0.0
86
128
  */
87
129
  export const FileSearch = Tool.providerDefined({
88
130
  id: "openai.file_search",
@@ -102,12 +144,23 @@ export const FileSearch = Tool.providerDefined({
102
144
  })
103
145
 
104
146
  /**
105
- * OpenAI Image Generation tool.
147
+ * OpenAI Image Generation tool that enables the model to generate images using
148
+ * the GPT image models.
149
+ *
150
+ * **When to use**
106
151
  *
107
- * Enables the model to generate images using the GPT image models.
152
+ * Use to enable OpenAI provider-defined image generation through a language
153
+ * model response.
154
+ *
155
+ * **Details**
156
+ *
157
+ * The tool configures the `image_generation` provider tool, including model,
158
+ * size, quality, output format, moderation, background, input-image options,
159
+ * and partial image settings. Successful tool calls expose `result` as base64
160
+ * image data or `null`.
108
161
  *
109
- * @since 1.0.0
110
162
  * @category tools
163
+ * @since 4.0.0
111
164
  */
112
165
  export const ImageGeneration = Tool.providerDefined({
113
166
  id: "openai.image_generation",
@@ -131,13 +184,23 @@ export const ImageGeneration = Tool.providerDefined({
131
184
  })
132
185
 
133
186
  /**
134
- * OpenAI Local Shell tool.
187
+ * OpenAI Local Shell tool that enables the model to run a command with a local
188
+ * shell. This local tool runs in your environment and requires a handler to
189
+ * execute commands.
190
+ *
191
+ * **When to use**
192
+ *
193
+ * Use to let an OpenAI model request local shell commands that your application
194
+ * executes through a handler.
135
195
  *
136
- * Enables the model to run a command with a local shell. This is a local tool
137
- * that runs in your environment and requires a handler to execute commands.
196
+ * **Details**
197
+ *
198
+ * The tool exposes a provider-defined `local_shell` call. It is marked as
199
+ * handler-required, so applications must provide the command execution policy
200
+ * and implementation.
138
201
  *
139
- * @since 1.0.0
140
202
  * @category tools
203
+ * @since 4.0.0
141
204
  */
142
205
  export const LocalShell = Tool.providerDefined({
143
206
  id: "openai.local_shell",
@@ -153,13 +216,27 @@ export const LocalShell = Tool.providerDefined({
153
216
  })
154
217
 
155
218
  /**
156
- * OpenAI MCP tool.
219
+ * OpenAI MCP tool that gives the model access to additional tools via remote
220
+ * Model Context Protocol (MCP) servers.
221
+ *
222
+ * **When to use**
223
+ *
224
+ * Use to let an OpenAI model call tools exposed by a remote MCP server.
225
+ *
226
+ * **Details**
157
227
  *
158
- * Gives the model access to additional tools via remote Model Context Protocol
159
- * (MCP) servers
228
+ * The tool accepts MCP server configuration such as allowed tools,
229
+ * authorization, connector id, approval requirements, server metadata, and
230
+ * server URL. Tool call results include the called tool name, arguments, output,
231
+ * error, and server label.
232
+ *
233
+ * **Gotchas**
234
+ *
235
+ * This schema leaves both `server_url` and `connector_id` optional, but OpenAI
236
+ * may require a server URL or connector id for a usable MCP tool configuration.
160
237
  *
161
- * @since 1.0.0
162
238
  * @category tools
239
+ * @since 4.0.0
163
240
  */
164
241
  export const Mcp = Tool.providerDefined({
165
242
  id: "openai.mcp",
@@ -174,6 +251,7 @@ export const Mcp = Tool.providerDefined({
174
251
  server_label: Generated.MCPTool.fields.server_label,
175
252
  server_url: Generated.MCPTool.fields.server_url
176
253
  }),
254
+ parameters: Schema.Unknown,
177
255
  success: Schema.Struct({
178
256
  type: Generated.MCPToolCall.fields.type,
179
257
  name: Generated.MCPToolCall.fields.name,
@@ -185,14 +263,12 @@ export const Mcp = Tool.providerDefined({
185
263
  })
186
264
 
187
265
  /**
188
- * OpenAI Function Shell tool.
266
+ * OpenAI Function Shell tool that enables the model to execute one or more shell
267
+ * commands in a managed environment. This local tool runs in your environment
268
+ * and requires a handler to execute commands.
189
269
  *
190
- * Enables the model to execute one or more shell commands in a managed
191
- * environment. This is a local tool that runs in your environment and requires
192
- * a handler to execute commands.
193
- *
194
- * @since 1.0.0
195
270
  * @category tools
271
+ * @since 4.0.0
196
272
  */
197
273
  export const Shell = Tool.providerDefined({
198
274
  id: "openai.shell",
@@ -203,17 +279,27 @@ export const Shell = Tool.providerDefined({
203
279
  action: Generated.FunctionShellCall.fields.action
204
280
  }),
205
281
  success: Schema.Struct({
206
- output: Generated.FunctionShellCallOutputItemParam.fields.output
282
+ output: Generated.FunctionShellCallOutput.fields.output
207
283
  })
208
284
  })
209
285
 
210
286
  /**
211
- * OpenAI Web Search tool.
287
+ * OpenAI Web Search tool that enables the model to search the web for
288
+ * information.
289
+ *
290
+ * **When to use**
212
291
  *
213
- * Enables the model to search the web for information.
292
+ * Use to enable OpenAI provider-defined web search for a model response.
293
+ *
294
+ * **Details**
295
+ *
296
+ * The tool accepts optional filters, user location, and search context size.
297
+ * Successful calls expose the performed search action and status.
298
+ *
299
+ * @see {@link WebSearchPreview} for the preview web search provider tool
214
300
  *
215
- * @since 1.0.0
216
301
  * @category tools
302
+ * @since 4.0.0
217
303
  */
218
304
  export const WebSearch = Tool.providerDefined({
219
305
  id: "openai.web_search",
@@ -234,12 +320,21 @@ export const WebSearch = Tool.providerDefined({
234
320
  })
235
321
 
236
322
  /**
237
- * OpenAI Web Search Preview tool.
323
+ * OpenAI preview Web Search tool for model responses.
324
+ *
325
+ * **When to use**
326
+ *
327
+ * Use to enable the preview OpenAI web search provider tool.
328
+ *
329
+ * **Details**
330
+ *
331
+ * The preview tool accepts optional user location and search context size, then
332
+ * exposes the performed search action and status in successful calls.
238
333
  *
239
- * Preview version of the web search tool with additional features.
334
+ * @see {@link WebSearch} for the stable web search provider tool
240
335
  *
241
- * @since 1.0.0
242
336
  * @category tools
337
+ * @since 4.0.0
243
338
  */
244
339
  export const WebSearchPreview = Tool.providerDefined({
245
340
  id: "openai.web_search_preview",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
 
5
5
  // @barrel: Auto-generated exports. Do not edit manually.
@@ -10,57 +10,46 @@
10
10
  export * as Generated from "./Generated.ts"
11
11
 
12
12
  /**
13
- * OpenAI Client module for interacting with OpenAI's API.
14
- *
15
- * Provides a type-safe, Effect-based client for OpenAI operations including
16
- * completions, embeddings, and streaming responses.
17
- *
18
- * @since 1.0.0
13
+ * @since 4.0.0
19
14
  */
20
15
  export * as OpenAiClient from "./OpenAiClient.ts"
21
16
 
22
17
  /**
23
- * @since 1.0.0
18
+ * @since 4.0.0
19
+ */
20
+ export * as OpenAiClientGenerated from "./OpenAiClientGenerated.ts"
21
+
22
+ /**
23
+ * @since 4.0.0
24
24
  */
25
25
  export * as OpenAiConfig from "./OpenAiConfig.ts"
26
26
 
27
27
  /**
28
- * OpenAI error metadata augmentation.
29
- *
30
- * Provides OpenAI-specific metadata fields for AI error types through module
31
- * augmentation, enabling typed access to OpenAI error details.
32
- *
33
- * @since 1.0.0
28
+ * @since 4.0.0
29
+ */
30
+ export * as OpenAiEmbeddingModel from "./OpenAiEmbeddingModel.ts"
31
+
32
+ /**
33
+ * @since 4.0.0
34
34
  */
35
35
  export * as OpenAiError from "./OpenAiError.ts"
36
36
 
37
37
  /**
38
- * OpenAI Language Model implementation.
39
- *
40
- * Provides a LanguageModel implementation for OpenAI's responses API,
41
- * supporting text generation, structured output, tool calling, and streaming.
42
- *
43
- * @since 1.0.0
38
+ * @since 4.0.0
44
39
  */
45
40
  export * as OpenAiLanguageModel from "./OpenAiLanguageModel.ts"
46
41
 
47
42
  /**
48
- * OpenAI telemetry attributes for OpenTelemetry integration.
49
- *
50
- * Provides OpenAI-specific GenAI telemetry attributes following OpenTelemetry
51
- * semantic conventions, extending the base GenAI attributes with OpenAI-specific
52
- * request and response metadata.
53
- *
54
- * @since 1.0.0
43
+ * @since 4.0.0
44
+ */
45
+ export * as OpenAiSchema from "./OpenAiSchema.ts"
46
+
47
+ /**
48
+ * @since 4.0.0
55
49
  */
56
50
  export * as OpenAiTelemetry from "./OpenAiTelemetry.ts"
57
51
 
58
52
  /**
59
- * OpenAI provider-defined tools for use with the LanguageModel.
60
- *
61
- * Provides tools that are natively supported by OpenAI's API, including
62
- * code interpreter, file search, and web search functionality.
63
- *
64
- * @since 1.0.0
53
+ * @since 4.0.0
65
54
  */
66
55
  export * as OpenAiTool from "./OpenAiTool.ts"
@@ -161,12 +161,14 @@ export const parseRateLimitHeaders = (headers: Record<string, string>) => {
161
161
  let retryAfter: Duration.Duration | undefined
162
162
  if (Predicate.isNotUndefined(retryAfterRaw)) {
163
163
  const parsed = Number.parse(retryAfterRaw)
164
- if (Predicate.isNotUndefined(parsed)) {
165
- retryAfter = Duration.seconds(parsed)
164
+ if (Option.isSome(parsed)) {
165
+ retryAfter = Duration.seconds(parsed.value)
166
166
  }
167
167
  }
168
168
  const remainingRaw = headers["x-ratelimit-remaining-requests"]
169
- const remaining = Predicate.isNotUndefined(remainingRaw) ? Number.parse(remainingRaw) ?? null : null
169
+ const remaining = Predicate.isNotUndefined(remainingRaw)
170
+ ? Option.getOrNull(Number.parse(remainingRaw))
171
+ : null
170
172
  return {
171
173
  retryAfter,
172
174
  limit: headers["x-ratelimit-limit-requests"] ?? null,
@@ -187,7 +189,7 @@ export const buildHttpRequestDetails = (
187
189
  method: request.method,
188
190
  url: request.url,
189
191
  urlParams: Array.from(request.urlParams),
190
- hash: request.hash,
192
+ hash: Option.getOrUndefined(request.hash),
191
193
  headers: Redactable.redact(request.headers) as Record<string, string>
192
194
  })
193
195