Skip to content

[Bug]: Foundry Router - gen_ai.response.model is not the served model #273

Description

Component

Distro

Description

Opening the issue here, while it could be originating from a change on the Foundry Responses API too.

As opposed to the evidences shown in this feature #234

... my Azure Foundry Project endpoint reports the model-router name (eg "model-router-2025-11-18") in the "x-ms-served-model" header
instead of the model selected for the generation ("gpt-5.6-sol-2026-07-09"),
which is correctly reported as "model_name" in the response body metadata.

The served model from headers taking precedence, the most important information is lost.

Image

Expected Behavior

Expected : the span attribute gen_ai.response.model should contain the model actually inferred ("gpt-5.6-sol-2026-07-09" in my case)

In any case, I think the fix should be upstream (Foundry or opentelemetry-python-genai),
and not a local workaround in the current project.

Option #1 : Revert Foundry API (ModelRouterControls=V1Preview) to its initial contract and report the model actually inferred through the "x-ms-served-model" header :

no change to the current codebase
no change to the upstream contribution open-telemetry/opentelemetry-python-genai#305

Option #2 : Capture the model name from the response body in the upstream https://github.com/open-telemetry/opentelemetry-python-genai/blob/main/instrumentation/opentelemetry-instrumentation-genai-langchain/src/opentelemetry/instrumentation/genai/langchain/callback_handler.py#L537

Steps to Reproduce

  1. Clone the repo
  2. export BASE_URL=https://myfoundry.services.ai.azure.com/api/projects/defaultproject
  3. export MODEL_NAME=my-model-router-deployment
  4. uv run --with langchain-openai python samples/langchain/sample_foundry_responses_api.py

Environment

[project]
name = "microsoft-opentelemetry"
version = "1.3.9"

Additional Context

No response

Activity

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