Skip to content

OpenAI Java SDK issues with Azure OpenAI #715

Closed

Description

@s-jepsen

We're using openai-java library version 4.17.0 through Spring AI.

The SDK is adding a lot of "x-stainless-*" headers - and recently Azure OpenAI has set a limit of max 10 headers for a request.

https://learn.microsoft.com/en-us/azure/foundry-classic/foundry-models/faq#do-foundry-models-support-custom-api-headers--we-append-custom-headers-to-our-api-requests-and-are-seeing-http-431-failure-errors-

Error:
Azure OpenAI responds with a 431 http error.

Solution:
Make telemetry headers opt-in?

Activity

  1. dpiet-oai commented on Oct 16, 2026

    @dpiet-oai
    Contributor

    Addressed by #1199, now merged. The change adds a JVM-wide telemetry opt-out with -Dopenai.disableTelemetry=true, which also works when a framework such as Spring AI constructs the client. Applications that construct clients directly can use .disableTelemetry(true) on the client builder.

    This suppresses SDK-generated X-Stainless-* headers and the SDK User-Agent, while preserving caller-supplied headers and authentication. An explicit builder setting overrides the JVM property. The change is merged; this comment does not identify a published release containing it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions