@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,62 +1,88 @@
1
+ /**
2
+ * The `OpenAiLanguageModel` module provides the OpenAI Responses API
3
+ * implementation of Effect AI's `LanguageModel` service. It translates Effect
4
+ * AI prompts, files, tools, structured output requests, reasoning metadata, and
5
+ * provider options into OpenAI response requests, then converts OpenAI
6
+ * responses and streams back into Effect AI response parts.
7
+ *
8
+ * **Mental model**
9
+ *
10
+ * `OpenAiClient` owns HTTP transport and provider calls. This module owns
11
+ * protocol translation: request assembly, tool choice conversion, structured
12
+ * output codecs, streaming event handling, response metadata, and GenAI
13
+ * telemetry annotations. {@link model}, {@link layer}, and {@link make} all
14
+ * build the same OpenAI-backed `LanguageModel.LanguageModel` service from a
15
+ * model id and optional request defaults.
16
+ *
17
+ * **Common tasks**
18
+ *
19
+ * - Provide an OpenAI-backed `LanguageModel.LanguageModel` from an existing
20
+ * `OpenAiClient`
21
+ * - Generate text or stream text through Effect AI's provider-neutral language
22
+ * model API
23
+ * - Use OpenAI provider metadata for files, reasoning items, tool calls, and
24
+ * response parts
25
+ * - Scope Responses API defaults with {@link Config} and
26
+ * {@link withConfigOverride}
27
+ *
28
+ * **Gotchas**
29
+ *
30
+ * - Some OpenAI model families receive system instructions as developer
31
+ * messages because the Responses API treats them differently.
32
+ * - File prompt parts are sent either as provider file ids or as base64
33
+ * content, depending on `fileIdPrefixes`.
34
+ * - Structured output and tool-call behavior depends on both Effect AI tool
35
+ * definitions and OpenAI model capabilities.
36
+ *
37
+ * @since 4.0.0
38
+ */
39
+ import * as Context from "effect/Context";
1
40
  import * as Effect from "effect/Effect";
2
41
  import * as Layer from "effect/Layer";
3
42
  import * as Schema from "effect/Schema";
4
- import * as ServiceMap from "effect/ServiceMap";
5
43
  import * as LanguageModel from "effect/unstable/ai/LanguageModel";
6
44
  import * as AiModel from "effect/unstable/ai/Model";
7
- import * as Generated from "./Generated.ts";
8
45
  import { OpenAiClient } from "./OpenAiClient.ts";
46
+ import type * as OpenAiSchema from "./OpenAiSchema.ts";
9
47
  declare const ResponseModelIds: Schema.Literals<readonly ["o1-pro", "o1-pro-2025-03-19", "o3-pro", "o3-pro-2025-06-10", "o3-deep-research", "o3-deep-research-2025-06-26", "o4-mini-deep-research", "o4-mini-deep-research-2025-06-26", "computer-use-preview", "computer-use-preview-2025-03-11", "gpt-5-codex", "gpt-5-pro", "gpt-5-pro-2025-10-06", "gpt-5.1-codex-max"]>;
10
- declare const SharedModelIds: Schema.Literals<readonly ["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.1", "gpt-5.1-2025-11-13", "gpt-5.1-codex", "gpt-5.1-mini", "gpt-5.1-chat-latest", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5-2025-08-07", "gpt-5-mini-2025-08-07", "gpt-5-nano-2025-08-07", "gpt-5-chat-latest", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4.1-2025-04-14", "gpt-4.1-mini-2025-04-14", "gpt-4.1-nano-2025-04-14", "o4-mini", "o4-mini-2025-04-16", "o3", "o3-2025-04-16", "o3-mini", "o3-mini-2025-01-31", "o1", "o1-2024-12-17", "o1-preview", "o1-preview-2024-09-12", "o1-mini", "o1-mini-2024-09-12", "gpt-4o", "gpt-4o-2024-11-20", "gpt-4o-2024-08-06", "gpt-4o-2024-05-13", "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini-audio-preview", "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-search-preview", "gpt-4o-mini-search-preview", "gpt-4o-search-preview-2025-03-11", "gpt-4o-mini-search-preview-2025-03-11", "chatgpt-4o-latest", "codex-mini-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", "gpt-4-turbo-preview", "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-0613", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613"]>;
48
+ declare const SharedModelIds: Schema.Literals<readonly ["gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "gpt-5.4-mini-2026-03-17", "gpt-5.4-nano-2026-03-17", "gpt-5.3-chat-latest", "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.1", "gpt-5.1-2025-11-13", "gpt-5.1-codex", "gpt-5.1-mini", "gpt-5.1-chat-latest", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5-2025-08-07", "gpt-5-mini-2025-08-07", "gpt-5-nano-2025-08-07", "gpt-5-chat-latest", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano", "gpt-4.1-2025-04-14", "gpt-4.1-mini-2025-04-14", "gpt-4.1-nano-2025-04-14", "o4-mini", "o4-mini-2025-04-16", "o3", "o3-2025-04-16", "o3-mini", "o3-mini-2025-01-31", "o1", "o1-2024-12-17", "o1-preview", "o1-preview-2024-09-12", "o1-mini", "o1-mini-2024-09-12", "gpt-4o", "gpt-4o-2024-11-20", "gpt-4o-2024-08-06", "gpt-4o-2024-05-13", "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-10-01", "gpt-4o-audio-preview-2024-12-17", "gpt-4o-audio-preview-2025-06-03", "gpt-4o-mini-audio-preview", "gpt-4o-mini-audio-preview-2024-12-17", "gpt-4o-search-preview", "gpt-4o-mini-search-preview", "gpt-4o-search-preview-2025-03-11", "gpt-4o-mini-search-preview-2025-03-11", "chatgpt-4o-latest", "codex-mini-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", "gpt-4-0125-preview", "gpt-4-turbo-preview", "gpt-4-1106-preview", "gpt-4-vision-preview", "gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-0613", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0301", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-3.5-turbo-16k-0613"]>;
11
49
  /**
12
- * @since 1.0.0
50
+ * OpenAI model identifiers supported by the Responses API language model.
51
+ *
13
52
  * @category models
53
+ * @since 4.0.0
14
54
  */
15
55
  export type Model = typeof ResponseModelIds.Encoded | typeof SharedModelIds.Encoded;
16
56
  /**
17
57
  * Image detail level for vision requests.
18
58
  */
19
59
  type ImageDetail = "auto" | "low" | "high";
20
- declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openai/OpenAiLanguageModel/Config", {
21
- readonly metadata?: {} | null;
22
- readonly top_logprobs?: number;
23
- readonly user?: string | null;
24
- readonly model?: string;
25
- readonly instructions?: string | null;
26
- readonly prompt?: {
27
- readonly id: string;
28
- readonly version?: string | null;
29
- readonly variables?: {} | null;
30
- } | null;
31
- readonly temperature?: number | null;
32
- readonly top_p?: number | null;
33
- readonly background?: boolean | null;
34
- readonly conversation?: string | {
35
- readonly id: string;
36
- } | null;
37
- readonly service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
38
- readonly include?: readonly ("file_search_call.results" | "web_search_call.results" | "web_search_call.action.sources" | "message.input_image.image_url" | "computer_call_output.output.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | null;
39
- readonly stream_options?: {
40
- readonly include_obfuscation?: boolean;
41
- } | null;
42
- readonly max_output_tokens?: number | null;
60
+ declare const Config_base: Context.ServiceClass<Config, "@effect/ai-openai/OpenAiLanguageModel/Config", {
61
+ readonly metadata?: {
62
+ readonly [x: string]: string;
63
+ } | undefined;
64
+ readonly top_logprobs?: number | undefined;
65
+ readonly user?: string | undefined;
66
+ readonly model?: string | undefined;
67
+ readonly temperature?: number | undefined;
68
+ readonly top_p?: number | undefined;
69
+ readonly background?: boolean | undefined;
70
+ readonly conversation?: string | undefined;
71
+ readonly modalities?: readonly ("text" | "audio")[] | undefined;
72
+ readonly service_tier?: string | undefined;
73
+ readonly seed?: number | undefined;
74
+ readonly include?: readonly ("web_search_call.action.sources" | "message.input_image.image_url" | "code_interpreter_call.outputs" | "reasoning.encrypted_content" | "message.output_text.logprobs")[] | undefined;
75
+ readonly instructions?: string | undefined;
76
+ readonly max_output_tokens?: number | undefined;
43
77
  readonly reasoning?: {
44
- readonly summary?: "auto" | "concise" | "detailed" | null;
45
- readonly effort?: "low" | "high" | "none" | "minimal" | "medium" | "xhigh" | null;
46
- readonly generate_summary?: "auto" | "concise" | "detailed" | null;
47
- } | null;
48
- readonly truncation?: "auto" | "disabled" | null;
49
- readonly parallel_tool_calls?: boolean | null;
50
- readonly safety_identifier?: string | null;
51
- readonly prompt_cache_key?: string | null;
52
- readonly prompt_cache_retention?: "in-memory" | "24h" | null;
53
- readonly store?: boolean | null;
54
- readonly previous_response_id?: string | null;
55
- readonly max_tool_calls?: number | null;
56
- readonly context_management?: readonly {
57
- readonly type: string;
58
- readonly compact_threshold?: number | null;
59
- }[] | null;
78
+ readonly effort?: "low" | "high" | "none" | "minimal" | "medium" | "xhigh" | undefined;
79
+ readonly summary?: "auto" | "concise" | "detailed" | undefined;
80
+ readonly generate_summary?: "auto" | "concise" | "detailed" | undefined;
81
+ } | undefined;
82
+ readonly truncation?: "auto" | "disabled" | undefined;
83
+ readonly store?: boolean | undefined;
84
+ readonly previous_response_id?: string | undefined;
85
+ readonly max_tool_calls?: number | undefined;
60
86
  readonly fileIdPrefixes?: readonly string[] | undefined;
61
87
  readonly text?: {
62
88
  /**
@@ -79,13 +105,34 @@ declare const Config_base: ServiceMap.ServiceClass<Config, "@effect/ai-openai/Op
79
105
  /**
80
106
  * Service definition for OpenAI language model configuration.
81
107
  *
82
- * @since 1.0.0
108
+ * **When to use**
109
+ *
110
+ * Use when you need to provide OpenAI Responses API request defaults through
111
+ * Effect context for language model operations.
112
+ *
113
+ * **Details**
114
+ *
115
+ * Config values are merged with the config object passed to `model`, `make`, or
116
+ * `layer`, with scoped context values taking precedence.
117
+ *
118
+ * @see {@link withConfigOverride} for scoping language model request overrides
119
+ *
83
120
  * @category services
121
+ * @since 4.0.0
84
122
  */
85
123
  export declare class Config extends Config_base {
86
124
  }
87
125
  declare module "effect/unstable/ai/Prompt" {
126
+ /**
127
+ * OpenAI-specific options for file prompt parts.
128
+ *
129
+ * @category request
130
+ * @since 4.0.0
131
+ */
88
132
  interface FilePartOptions extends ProviderOptions {
133
+ /**
134
+ * Provider-specific file options for the OpenAI Responses API.
135
+ */
89
136
  readonly openai?: {
90
137
  /**
91
138
  * The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`. Defaults to `auto`.
@@ -93,7 +140,16 @@ declare module "effect/unstable/ai/Prompt" {
93
140
  readonly imageDetail?: ImageDetail | null;
94
141
  } | null;
95
142
  }
143
+ /**
144
+ * OpenAI-specific options for reasoning prompt parts.
145
+ *
146
+ * @category request
147
+ * @since 4.0.0
148
+ */
96
149
  interface ReasoningPartOptions extends ProviderOptions {
150
+ /**
151
+ * Provider-specific reasoning options for the OpenAI Responses API.
152
+ */
97
153
  readonly openai?: {
98
154
  /**
99
155
  * The ID of the item to reference.
@@ -107,7 +163,16 @@ declare module "effect/unstable/ai/Prompt" {
107
163
  readonly encryptedContent?: string | null;
108
164
  } | null;
109
165
  }
166
+ /**
167
+ * OpenAI-specific options for assistant tool-call prompt parts.
168
+ *
169
+ * @category request
170
+ * @since 4.0.0
171
+ */
110
172
  interface ToolCallPartOptions extends ProviderOptions {
173
+ /**
174
+ * Provider-specific tool-call options for the OpenAI Responses API.
175
+ */
111
176
  readonly openai?: {
112
177
  /**
113
178
  * The ID of the item to reference.
@@ -116,14 +181,23 @@ declare module "effect/unstable/ai/Prompt" {
116
181
  /**
117
182
  * The status of item.
118
183
  */
119
- readonly status?: typeof Generated.Message.Encoded["status"] | null;
184
+ readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
120
185
  /**
121
186
  * The ID of the approval request.
122
187
  */
123
188
  readonly approvalRequestId?: string | null;
124
189
  } | null;
125
190
  }
191
+ /**
192
+ * OpenAI-specific options for tool-result prompt parts.
193
+ *
194
+ * @category request
195
+ * @since 4.0.0
196
+ */
126
197
  interface ToolResultPartOptions extends ProviderOptions {
198
+ /**
199
+ * Provider-specific tool-result options for the OpenAI Responses API.
200
+ */
127
201
  readonly openai?: {
128
202
  /**
129
203
  * The ID of the item to reference.
@@ -132,14 +206,23 @@ declare module "effect/unstable/ai/Prompt" {
132
206
  /**
133
207
  * The status of item.
134
208
  */
135
- readonly status?: typeof Generated.Message.Encoded["status"] | null;
209
+ readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
136
210
  /**
137
211
  * The ID of the approval request.
138
212
  */
139
213
  readonly approvalId?: string | null;
140
214
  } | null;
141
215
  }
216
+ /**
217
+ * OpenAI-specific options for text prompt parts.
218
+ *
219
+ * @category request
220
+ * @since 4.0.0
221
+ */
142
222
  interface TextPartOptions extends ProviderOptions {
223
+ /**
224
+ * Provider-specific text options for the OpenAI Responses API.
225
+ */
143
226
  readonly openai?: {
144
227
  /**
145
228
  * The ID of the item to reference.
@@ -148,17 +231,29 @@ declare module "effect/unstable/ai/Prompt" {
148
231
  /**
149
232
  * The status of item.
150
233
  */
151
- readonly status?: typeof Generated.Message.Encoded["status"] | null;
234
+ readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
152
235
  /**
153
236
  * A list of annotations that apply to the output text.
154
237
  */
155
- readonly annotations?: ReadonlyArray<typeof Generated.Annotation.Encoded> | null;
238
+ readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
156
239
  } | null;
157
240
  }
158
241
  }
159
242
  declare module "effect/unstable/ai/Response" {
243
+ /**
244
+ * OpenAI metadata attached to a complete text response part.
245
+ *
246
+ * @category response
247
+ * @since 4.0.0
248
+ */
160
249
  interface TextPartMetadata extends ProviderMetadata {
250
+ /**
251
+ * Provider-specific metadata returned for the text part.
252
+ */
161
253
  readonly openai?: {
254
+ /**
255
+ * The OpenAI item ID associated with the text part.
256
+ */
162
257
  readonly itemId?: string | null;
163
258
  /**
164
259
  * If the model emits a refusal content part, the refusal explanation
@@ -169,54 +264,162 @@ declare module "effect/unstable/ai/Response" {
169
264
  /**
170
265
  * The status of item.
171
266
  */
172
- readonly status?: typeof Generated.Message.Encoded["status"] | null;
267
+ readonly status?: typeof OpenAiSchema.MessageStatus.Encoded | null;
173
268
  /**
174
269
  * The text content part annotations.
175
270
  */
176
- readonly annotations?: ReadonlyArray<typeof Generated.Annotation.Encoded> | null;
271
+ readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
177
272
  };
178
273
  }
274
+ /**
275
+ * OpenAI metadata emitted when a streamed text part starts.
276
+ *
277
+ * @category response
278
+ * @since 4.0.0
279
+ */
179
280
  interface TextStartPartMetadata extends ProviderMetadata {
281
+ /**
282
+ * Provider-specific metadata returned for the streamed text start.
283
+ */
180
284
  readonly openai?: {
285
+ /**
286
+ * The OpenAI item ID associated with the streamed text part.
287
+ */
181
288
  readonly itemId?: string | null;
182
289
  } | null;
183
290
  }
291
+ /**
292
+ * OpenAI metadata emitted when a streamed text part ends.
293
+ *
294
+ * @category response
295
+ * @since 4.0.0
296
+ */
184
297
  interface TextEndPartMetadata extends ProviderMetadata {
298
+ /**
299
+ * Provider-specific metadata returned for the streamed text end.
300
+ */
185
301
  readonly openai?: {
302
+ /**
303
+ * The OpenAI item ID associated with the streamed text part.
304
+ */
186
305
  readonly itemId?: string | null;
187
- readonly annotations?: ReadonlyArray<typeof Generated.Annotation.Encoded> | null;
306
+ /**
307
+ * The annotations collected for the completed streamed text part.
308
+ */
309
+ readonly annotations?: ReadonlyArray<typeof OpenAiSchema.Annotation.Encoded> | null;
188
310
  } | null;
189
311
  }
312
+ /**
313
+ * OpenAI metadata attached to a complete reasoning response part.
314
+ *
315
+ * @category response
316
+ * @since 4.0.0
317
+ */
190
318
  interface ReasoningPartMetadata extends ProviderMetadata {
319
+ /**
320
+ * Provider-specific metadata returned for the reasoning part.
321
+ */
191
322
  readonly openai?: {
323
+ /**
324
+ * The OpenAI item ID associated with the reasoning part.
325
+ */
192
326
  readonly itemId?: string | null;
327
+ /**
328
+ * Encrypted reasoning content that can be sent back in later requests.
329
+ */
193
330
  readonly encryptedContent?: string | null;
194
331
  } | null;
195
332
  }
333
+ /**
334
+ * OpenAI metadata emitted when a streamed reasoning part starts.
335
+ *
336
+ * @category response
337
+ * @since 4.0.0
338
+ */
196
339
  interface ReasoningStartPartMetadata extends ProviderMetadata {
340
+ /**
341
+ * Provider-specific metadata returned for the streamed reasoning start.
342
+ */
197
343
  readonly openai?: {
344
+ /**
345
+ * The OpenAI item ID associated with the reasoning part.
346
+ */
198
347
  readonly itemId?: string | null;
348
+ /**
349
+ * Encrypted reasoning content that can be sent back in later requests.
350
+ */
199
351
  readonly encryptedContent?: string | null;
200
352
  } | null;
201
353
  }
354
+ /**
355
+ * OpenAI metadata emitted for a streamed reasoning delta.
356
+ *
357
+ * @category response
358
+ * @since 4.0.0
359
+ */
202
360
  interface ReasoningDeltaPartMetadata extends ProviderMetadata {
361
+ /**
362
+ * Provider-specific metadata returned for the streamed reasoning delta.
363
+ */
203
364
  readonly openai?: {
365
+ /**
366
+ * The OpenAI item ID associated with the reasoning part.
367
+ */
204
368
  readonly itemId?: string | null;
205
369
  } | null;
206
370
  }
371
+ /**
372
+ * OpenAI metadata emitted when a streamed reasoning part ends.
373
+ *
374
+ * @category response
375
+ * @since 4.0.0
376
+ */
207
377
  interface ReasoningEndPartMetadata extends ProviderMetadata {
378
+ /**
379
+ * Provider-specific metadata returned for the streamed reasoning end.
380
+ */
208
381
  readonly openai?: {
382
+ /**
383
+ * The OpenAI item ID associated with the reasoning part.
384
+ */
209
385
  readonly itemId?: string | null;
386
+ /**
387
+ * Encrypted reasoning content that can be sent back in later requests.
388
+ */
210
389
  readonly encryptedContent?: string;
211
390
  } | null;
212
391
  }
392
+ /**
393
+ * OpenAI metadata attached to tool-call response parts.
394
+ *
395
+ * @category response
396
+ * @since 4.0.0
397
+ */
213
398
  interface ToolCallPartMetadata extends ProviderMetadata {
399
+ /**
400
+ * Provider-specific metadata returned for the tool call.
401
+ */
214
402
  readonly openai?: {
403
+ /**
404
+ * The OpenAI item ID associated with the tool call.
405
+ */
215
406
  readonly itemId?: string | null;
216
407
  } | null;
217
408
  }
409
+ /**
410
+ * OpenAI metadata attached to document source citations.
411
+ *
412
+ * @category response
413
+ * @since 4.0.0
414
+ */
218
415
  interface DocumentSourcePartMetadata extends ProviderMetadata {
416
+ /**
417
+ * Provider-specific citation metadata for the OpenAI Responses API.
418
+ */
219
419
  readonly openai?: {
420
+ /**
421
+ * Identifies a citation to an uploaded file.
422
+ */
220
423
  readonly type: "file_citation";
221
424
  /**
222
425
  * The index of the file in the list of files.
@@ -227,6 +430,9 @@ declare module "effect/unstable/ai/Response" {
227
430
  */
228
431
  readonly fileId: string;
229
432
  } | {
433
+ /**
434
+ * Identifies a citation to a generated file path.
435
+ */
230
436
  readonly type: "file_path";
231
437
  /**
232
438
  * The index of the file in the list of files.
@@ -237,6 +443,9 @@ declare module "effect/unstable/ai/Response" {
237
443
  */
238
444
  readonly fileId: string;
239
445
  } | {
446
+ /**
447
+ * Identifies a citation to a file inside a container.
448
+ */
240
449
  readonly type: "container_file_citation";
241
450
  /**
242
451
  * The ID of the file.
@@ -248,8 +457,20 @@ declare module "effect/unstable/ai/Response" {
248
457
  readonly containerId: string;
249
458
  } | null;
250
459
  }
460
+ /**
461
+ * OpenAI metadata attached to URL source citations.
462
+ *
463
+ * @category response
464
+ * @since 4.0.0
465
+ */
251
466
  interface UrlSourcePartMetadata extends ProviderMetadata {
467
+ /**
468
+ * Provider-specific URL citation metadata for the OpenAI Responses API.
469
+ */
252
470
  readonly openai?: {
471
+ /**
472
+ * Identifies a citation to a URL.
473
+ */
253
474
  readonly type: "url_citation";
254
475
  /**
255
476
  * The index of the first character of the URL citation in the message.
@@ -261,56 +482,157 @@ declare module "effect/unstable/ai/Response" {
261
482
  readonly endIndex: number;
262
483
  } | null;
263
484
  }
485
+ /**
486
+ * OpenAI metadata attached to finish response parts.
487
+ *
488
+ * @category response
489
+ * @since 4.0.0
490
+ */
264
491
  interface FinishPartMetadata extends ProviderMetadata {
492
+ /**
493
+ * Provider-specific metadata returned when generation finishes.
494
+ */
265
495
  readonly openai?: {
496
+ /**
497
+ * The service tier reported by OpenAI for the response.
498
+ */
266
499
  readonly serviceTier?: "default" | "auto" | "flex" | "scale" | "priority" | null;
267
500
  } | null;
268
501
  }
269
502
  }
270
503
  /**
271
- * @since 1.0.0
504
+ * Creates an OpenAI model descriptor that can be provided with
505
+ * `Effect.provide`.
506
+ *
507
+ * **When to use**
508
+ *
509
+ * Use when you want an OpenAI language model value that carries provider and
510
+ * model metadata and can be supplied directly to an Effect program.
511
+ *
512
+ * @see {@link layer} for creating a `LanguageModel.LanguageModel` layer directly
513
+ * @see {@link make} for constructing the language model service effectfully
514
+ *
272
515
  * @category constructors
516
+ * @since 4.0.0
273
517
  */
274
518
  export declare const model: (model: (string & {}) | Model, config?: Omit<typeof Config.Service, "model">) => AiModel.Model<"openai", LanguageModel.LanguageModel, OpenAiClient>;
275
519
  /**
276
- * Creates an OpenAI language model service.
520
+ * Creates an OpenAI `LanguageModel` service from a model identifier and
521
+ * optional request defaults.
522
+ *
523
+ * **When to use**
524
+ *
525
+ * Use when an Effect needs to construct a `LanguageModel.Service` value backed
526
+ * by `OpenAiClient`.
527
+ *
528
+ * **Details**
529
+ *
530
+ * The returned effect requires `OpenAiClient`. Request defaults from the
531
+ * `config` option are merged with any `Config` service in the context, with
532
+ * context values taking precedence. The service supports both `generateText`
533
+ * and `streamText`.
534
+ *
535
+ * @see {@link layer} for providing the service as a `Layer`
536
+ * @see {@link model} for creating a model descriptor for `Effect.provide`
277
537
  *
278
- * @since 1.0.0
279
538
  * @category constructors
539
+ * @since 4.0.0
280
540
  */
281
541
  export declare const make: (args_0: {
282
542
  readonly model: (string & {}) | Model;
283
543
  readonly config?: Omit<typeof Config.Service, "model"> | undefined;
284
544
  }) => Effect.Effect<LanguageModel.Service, never, OpenAiClient>;
285
545
  /**
286
- * Creates a layer for the OpenAI language model.
546
+ * Creates a layer that provides the OpenAI `LanguageModel.LanguageModel`
547
+ * service.
548
+ *
549
+ * **When to use**
550
+ *
551
+ * Use when composing application layers and you want OpenAI to satisfy
552
+ * `LanguageModel.LanguageModel` while supplying `OpenAiClient` from another
553
+ * layer.
554
+ *
555
+ * **Details**
556
+ *
557
+ * The `config` option supplies request defaults for the selected model. Scoped
558
+ * values from `withConfigOverride` are merged when each request is built and
559
+ * take precedence over these defaults.
560
+ *
561
+ * @see {@link make} for constructing the language model service effectfully
562
+ * @see {@link model} for creating a model descriptor for `Effect.provide`
563
+ * @see {@link withConfigOverride} for scoped request configuration overrides
287
564
  *
288
- * @since 1.0.0
289
565
  * @category layers
566
+ * @since 4.0.0
290
567
  */
291
568
  export declare const layer: (options: {
292
569
  readonly model: (string & {}) | Model;
293
570
  readonly config?: Omit<typeof Config.Service, "model"> | undefined;
294
571
  }) => Layer.Layer<LanguageModel.LanguageModel, never, OpenAiClient>;
295
572
  /**
296
- * Provides config overrides for OpenAI language model operations.
573
+ * Provides scoped config overrides for OpenAI language model operations.
574
+ *
575
+ * **When to use**
576
+ *
577
+ * Use to apply OpenAI Responses API config overrides around one or more
578
+ * language model operations without changing the defaults passed to `model`,
579
+ * `make`, or `layer`.
580
+ *
581
+ * **Details**
582
+ *
583
+ * The override is dual, so it can be used in pipe form or as
584
+ * `withConfigOverride(effect, overrides)`. Overrides are merged with any
585
+ * existing `Config` service in the current context, and the override values take
586
+ * precedence.
587
+ *
588
+ * @see {@link Config} for the scoped configuration service consumed by this function
297
589
  *
298
- * @since 1.0.0
299
590
  * @category configuration
591
+ * @since 4.0.0
300
592
  */
301
593
  export declare const withConfigOverride: {
302
594
  /**
303
- * Provides config overrides for OpenAI language model operations.
595
+ * Provides scoped config overrides for OpenAI language model operations.
596
+ *
597
+ * **When to use**
598
+ *
599
+ * Use to apply OpenAI Responses API config overrides around one or more
600
+ * language model operations without changing the defaults passed to `model`,
601
+ * `make`, or `layer`.
602
+ *
603
+ * **Details**
604
+ *
605
+ * The override is dual, so it can be used in pipe form or as
606
+ * `withConfigOverride(effect, overrides)`. Overrides are merged with any
607
+ * existing `Config` service in the current context, and the override values take
608
+ * precedence.
609
+ *
610
+ * @see {@link Config} for the scoped configuration service consumed by this function
304
611
  *
305
- * @since 1.0.0
306
612
  * @category configuration
613
+ * @since 4.0.0
307
614
  */
308
615
  (overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>>;
309
616
  /**
310
- * Provides config overrides for OpenAI language model operations.
617
+ * Provides scoped config overrides for OpenAI language model operations.
618
+ *
619
+ * **When to use**
620
+ *
621
+ * Use to apply OpenAI Responses API config overrides around one or more
622
+ * language model operations without changing the defaults passed to `model`,
623
+ * `make`, or `layer`.
624
+ *
625
+ * **Details**
626
+ *
627
+ * The override is dual, so it can be used in pipe form or as
628
+ * `withConfigOverride(effect, overrides)`. Overrides are merged with any
629
+ * existing `Config` service in the current context, and the override values take
630
+ * precedence.
631
+ *
632
+ * @see {@link Config} for the scoped configuration service consumed by this function
311
633
  *
312
- * @since 1.0.0
313
634
  * @category configuration
635
+ * @since 4.0.0
314
636
  */
315
637
  <A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>;
316
638
  };