Skip to content

fix,docs(provider/azure):allow 'azure' as a key for providerOptions#11073

Merged
lgrammel merged 38 commits intovercel:mainfrom
tsuzaki430:tsuz/azure-provider-option-reasoning-encrypted-content
Jan 5, 2026
Merged

fix,docs(provider/azure):allow 'azure' as a key for providerOptions#11073
lgrammel merged 38 commits intovercel:mainfrom
tsuzaki430:tsuz/azure-provider-option-reasoning-encrypted-content

Conversation

@tsuzaki430
Copy link
Copy Markdown
Collaborator

@tsuzaki430 tsuzaki430 commented Dec 11, 2025

Background

This PR addresses #10917.

When using Azure OpenAI reasoning models via the Responses API, the SDK currently only handles reasoning parts when their providerOptions live under the openai key. Azure Responses, however, expose reasoning parts and providerMetadata under the azure namespace. This mismatch causes the SDK to log a warning about "non-OpenAI reasoning parts" and drop encrypted reasoning traces instead of passing them through to the client.

Summary

This PR makes the Responses provider options handling in @ai-sdk/openai configurable and switches Azure Responses to use providerOptions.azure so that reasoning parts and providerMetadata stay in sync.

Concretely:

  • OpenAI provider
    Extend the Responses input conversion so that the provider options key (openai, azure, etc.) is configurable instead of being hard-coded to openai.
    Keep the existing OpenAI behavior unchanged by continuing to use the openai key by default.

  • Azure provider
    Update the Azure Responses integration to use the azure provider key when reading/writing Responses providerOptions.
    However, to maintain backward compatibility, providerOptions.openai remains available.
    This makes Azure reasoning parts and providerMetadata.azure consistent and prevents encrypted reasoning traces from being treated as unsupported "non-OpenAI reasoning".

  • Docs & migration
    Update the Azure provider docs to explain that the Responses API now available providerOptions.azure providerOptions.openai and returns providerMetadata.azure.
    Add a migration note to the 6.0 migration guide describing the change from openaiazure for Azure Responses.

    • content/providers/01-ai-sdk-providers/04-azure.mdx
    • content/docs/08-migration-guides/24-migration-guide-6-0.mdx
  • Examples & tests

    • Add ai-core examples for reasoning.encrypted_content for both OpenAI and Azure Responses.
    • Update existing Azure examples to use providerOptions.azure for Responses.
    • Add fixtures and tests to cover Azure/OpenAI Responses with encrypted reasoning, ensuring we don’t regress on this behavior.
      • packages/azure/src/__fixtures__/azure-reasoning-encrypted-content.1.chunks.txt
      • packages/azure/src/__fixtures__/azure-reasoning-encrypted-content.1.json
      • packages/openai/src/responses/__fixtures__/openai-reasoning-encrypted-content.1.chunks.txt
      • packages/openai/src/responses/__fixtures__/openai-reasoning-encrypted-content.1.json
    • add test case.
      • packages/openai/src/responses/convert-to-openai-responses-input.ts
      • packages/openai/src/responses/openai-responses-language-model.test.ts

Manual Verification

  • new tests in examples/ai-core

    • pnpm tsx src/generate-text/azure-reasoning-encrypted-content.ts
    • pnpm tsx src/generate-text/openai-reasoning-encrypted-content.ts
    • pnpm tsx src/generate-text/azure-provider-options-name-openai-compatible.ts
    • pnpm tsx src/stream-text/azure-reasoning-encrypted-content.ts
    • pnpm tsx src/stream-text/openai-reasoning-encrypted-content.ts
    • pnpm tsx src/stream-text/azure-provider-options-name-openai-compatible.ts
  • fix existing tests and re-try in examples/ai-core.

    • pnpm tsx src/generate-text/azure-image.ts
    • pnpm tsx src/generate-text/azure-responses-reasoning-summary.ts
    • pnpm tsx src/stream-text/azure-fullstream-logprobs.ts
    • pnpm tsx src/stream-text/azure-responses-reasoning-summary.ts
  • fix existing tests and re-try in examples/next-openai.

    • pnpm run dev & http://localhost:3000/test-azure-code-interpreter-annotation-download
      (fix examples/next-openai/app/api/chat-azure-code-interpreter-annotation-download/route.ts)

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Future Work

N/A

Related Issues

Fixes #10917.

Reference #10983.
fix(google-vertex): allow 'vertex' as a key for providerOptions

@vercel-ai-sdk vercel-ai-sdk bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label provider/azure Issues related to the @ai-sdk/azure provider labels Dec 11, 2025
@tsuzaki430 tsuzaki430 changed the title fix(provider/openai):Switch Azure Responses to providerOptions.azure fix(provider/openai),docs(azure,migrate):Switch Azure Responses to providerOptions.azure Dec 11, 2025
@tsuzaki430 tsuzaki430 marked this pull request as ready for review December 13, 2025 07:54
@tsuzaki430
Copy link
Copy Markdown
Collaborator Author

I have reviewed this pull request (self-review)

@lgrammel
Copy link
Copy Markdown
Collaborator

The breaking change is a major issue, because users will have stored UI message histories with the old data. We had a similar problems with Vertex/Google.

@aayush-kapoor can you review / guide given that the situation here is somewhat similar to google/vertex?

@tsuzaki430
Copy link
Copy Markdown
Collaborator Author

@lgrammel

Thanks for calling this out — I agree that making this a breaking change would be a major issue, especially for users who already have stored UI histories with the old providerOptions shape.
I hadn’t fully considered the impact on existing stored data when I opened this PR. After your comment, I went through the 6.0 migration guide and the Google / Vertex providers, and I noticed you handled a very similar case there with a backwards-compatible approach.

@aayush-kapoor

I’ll adjust this PR to follow the same pattern as Google / Vertex. Once I push the update, could you take a look and let me know if I’m aligning with the approach correctly?

@tsuzaki430 tsuzaki430 marked this pull request as draft December 13, 2025 11:53
@tsuzaki430 tsuzaki430 changed the title fix(provider/openai),docs(azure,migrate):Switch Azure Responses to providerOptions.azure fix(provider/azure),docs(azure,migrate):allow 'azure' as a key for providerOptions Dec 13, 2025
@tsuzaki430 tsuzaki430 changed the title fix(provider/azure),docs(azure,migrate):allow 'azure' as a key for providerOptions fix,docs(provider/azure):allow 'azure' as a key for providerOptions Dec 13, 2025
@tsuzaki430 tsuzaki430 marked this pull request as ready for review December 14, 2025 07:27
@tsuzaki430
Copy link
Copy Markdown
Collaborator Author

I have reviewed this pull request (self-review)


@aayush-kapoor
By referring to the code in PR #10983, I was able to confidently introduce compatibility between openai and azure.
I also tried to adjust the handling of the providerOptionsName variable to align with your implementation.

When you have a moment, I’d appreciate it if you could take a look.

@tsuzaki430 tsuzaki430 marked this pull request as draft December 22, 2025 15:17
@tsuzaki430 tsuzaki430 marked this pull request as ready for review December 22, 2025 16:20
@tsuzaki430
Copy link
Copy Markdown
Collaborator Author

Merged the latest commits and resolved conflicts and build errors.
Re-ran manual tests and confirmed there were no issues.

@lgrammel
Copy link
Copy Markdown
Collaborator

@tsuzaki430 thanks and sorry for the delay, was busy with ai sdk (and now will only have a very limited time in the next couple of weeks)

my main question is how backwards compat is solved. i.e. if someone has stored ui message data for azure with openai provider options already, will it still work without changes after this pull request lands?

@tsuzaki430
Copy link
Copy Markdown
Collaborator Author

tsuzaki430 commented Dec 23, 2025

@lgrammel

Thank you for the question, and congratulations on the AI SDK v6 release!🎉

In the case of Google and Vertex, the implementation first attempts to resolve the provider options as vertex, and if that is null, it falls back to resolving them as google.
I followed the same approach for the relationship between openai and azure.

I’ve confirmed that tests continue to work correctly even when using the openai provider name as-is.

As for data that was previously stored with openai as the provider for Azure, I haven’t been able to test that scenario directly. However, based on this fallback approach, I believe it should continue to work without requiring changes.

@tsuzaki430 tsuzaki430 marked this pull request as draft December 25, 2025 11:07
@tsuzaki430 tsuzaki430 marked this pull request as ready for review December 25, 2025 11:58
@tsuzaki430
Copy link
Copy Markdown
Collaborator Author

Merged the latest commits and resolved conflicts and build errors.
Re-ran manual tests and confirmed there were no issues.

@fvdnabee
Copy link
Copy Markdown

fvdnabee commented Jan 5, 2026

Thank you for fixing this! We currently can't switch to the responses API for reasoning models on azure openai due to this issue. Looking forward to getting the issue resolved. Is there anything I can help with to get this merged?

@lgrammel lgrammel merged commit 55cd1a4 into vercel:main Jan 5, 2026
17 of 18 checks passed
@tsuzaki430
Copy link
Copy Markdown
Collaborator Author

@fvdnabee @lgrammel

Thanks so much for reviewing and merging this! 😊

@tsuzaki430 tsuzaki430 deleted the tsuz/azure-provider-option-reasoning-encrypted-content branch January 7, 2026 11:30
@fvdnabee
Copy link
Copy Markdown

fvdnabee commented Jan 9, 2026

I can confirm encrypted reasonings are now processed and send back to azure openai's responses api, thank you for fixing this 👍

@tsuzaki430
Copy link
Copy Markdown
Collaborator Author

@fvdnabee

Thank you for your message.
I'm happy this PR helps for your environments.😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label provider/azure Issues related to the @ai-sdk/azure provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Azure OpenAI Encrypted Reasoning Traces Stripped

3 participants