Commit 04c89b1
authored
feat,docs(openai,azure):provide Responses API providerMetadata types at the provider-specific metadata / reasoning part metadata (#12010)
## Background
The Responses API attaches provider-specific metadata to messages and
reasoning parts, but until now there were no exported, typed helpers for
accessing this metadata in a type-safe way from client code.
As a result, users had to rely on untyped or loosely typed access to
`providerMetadata`, especially when working with response IDs, logprobs,
service tier information, or reasoning-related metadata.
## Summary
This PR adds and documents typed providerMetadata helpers for the
Responses API at the message and reasoning level.
- Export new providerMetadata types for both OpenAI and Azure:
- `OpenaiResponsesProviderMetadata`
- `OpenaiResponsesReasoningProviderMetadata`
- `AzureResponsesProviderMetadata`
- `AzureResponsesReasoningProviderMetadata`
- Ensure providerMetadata construction is type-checked internally using
`satisfies`.
- Update OpenAI and Azure provider documentation with:
- Typed examples for accessing message-level providerMetadata.
- New sections describing typed providerMetadata in reasoning parts.
- Update examples to demonstrate practical usage of the new types
(e.g. `responseId`, `logprobs`, `serviceTier`,
`reasoningEncryptedContent`).
No behavior changes are introduced; this change improves type safety,
documentation, and developer ergonomics.
## Manual Verification
### examples in `examples/ai-functions`
Edited for add types and run tests.
- pnpm tsx src/generate-text/azure-reasoning-encrypted-content.ts
- pnpm tsx src/generate-text/azure-reasoning.ts
- pnpm tsx src/generate-text/openai-logprobs.ts
- pnpm tsx src/generate-text/openai-reasoning-encrypted-content.ts
- pnpm tsx src/generate-text/openai-reasoning.ts
- pnpm tsx src/generate-text/openai-responses-previous-response-id.ts
- pnpm tsx src/stream-text/azure-fullstream-logprobs.ts
- pnpm tsx src/stream-text/azure-reasoning-encrypted-content.ts
- pnpm tsx src/stream-text/azure-reasoning.ts
- pnpm tsx src/stream-text/openai-fullstream-logprobs.ts
- pnpm tsx src/stream-text/openai-reasoning-encrypted-content.ts
- pnpm tsx src/stream-text/openai-reasoning.ts
- pnpm tsx src/stream-text/openai-responses-service-tier.ts
### examples in `examples/next-openai`
Edited for add types and run tests.
- http://localhost:3000/chat-openai-previous-response-id
## Related Issues
#10266
---------
Co-authored-by: tsuzaki430 <tsuzaki430@users.noreply.github.com>1 parent 1e2dbc0 commit 04c89b1
File tree
23 files changed
+618
-272
lines changed- .changeset
- content/providers/01-ai-sdk-providers
- examples
- ai-functions/src
- generate-text
- stream-text
- next-openai/app
- api/chat-openai-previous-response-id
- chat-openai-previous-response-id
- packages
- azure/src
- openai/src
- responses
23 files changed
+618
-272
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
| 258 | + | |
| 259 | + | |
258 | 260 | | |
259 | | - | |
260 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
261 | 266 | | |
262 | 267 | | |
263 | | - | |
264 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
265 | 271 | | |
266 | | - | |
| 272 | + | |
267 | 273 | | |
268 | | - | |
269 | | - | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
270 | 277 | | |
271 | | - | |
272 | | - | |
| 278 | + | |
273 | 279 | | |
274 | | - | |
275 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
276 | 286 | | |
277 | 287 | | |
278 | 288 | | |
| |||
929 | 939 | | |
930 | 940 | | |
931 | 941 | | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
932 | 988 | | |
933 | 989 | | |
934 | 990 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| 325 | + | |
| 326 | + | |
325 | 327 | | |
326 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
327 | 332 | | |
328 | 333 | | |
329 | 334 | | |
330 | | - | |
331 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
332 | 338 | | |
333 | | - | |
| 339 | + | |
334 | 340 | | |
335 | | - | |
336 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
337 | 344 | | |
338 | | - | |
339 | | - | |
| 345 | + | |
340 | 346 | | |
341 | | - | |
342 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
343 | 353 | | |
344 | 354 | | |
345 | 355 | | |
| |||
652 | 662 | | |
653 | 663 | | |
654 | 664 | | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
655 | 710 | | |
656 | 711 | | |
657 | 712 | | |
| |||
Lines changed: 39 additions & 47 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
3 | 2 | | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 11 | + | |
| 12 | + | |
39 | 13 | | |
40 | 14 | | |
41 | | - | |
42 | | - | |
| 15 | + | |
| 16 | + | |
43 | 17 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 18 | + | |
| 19 | + | |
47 | 20 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | 21 | | |
56 | 22 | | |
57 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
58 | 50 | | |
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
Lines changed: 25 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
17 | 39 | | |
0 commit comments