Skip to content

Commit cb7b692

Browse files
committed
Extract service_tier from extra_body when not in kwargs
In OpenAI SDK 1.26.0, service_tier is passed via extra_body. Update get_llm_request_attributes to check both kwargs and extra_body for service_tier to support both ways of passing it.
1 parent 03cff8e commit cb7b692

File tree

1 file changed

+5
-0
lines changed
  • instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2

1 file changed

+5
-0
lines changed

instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,12 @@ def get_llm_request_attributes(
230230
GenAIAttributes.GEN_AI_OPENAI_REQUEST_RESPONSE_FORMAT
231231
] = response_format
232232

233+
# service_tier can be passed directly or in extra_body (in SDK 1.26.0 it's via extra_body)
233234
service_tier = kwargs.get("service_tier")
235+
if service_tier is None:
236+
extra_body = kwargs.get("extra_body")
237+
if isinstance(extra_body, Mapping):
238+
service_tier = extra_body.get("service_tier")
234239
attributes[GenAIAttributes.GEN_AI_OPENAI_REQUEST_SERVICE_TIER] = (
235240
service_tier if service_tier != "auto" else None
236241
)

0 commit comments

Comments
 (0)