-
Notifications
You must be signed in to change notification settings - Fork 462
Open
Labels
Description
Tracer Version(s)
3.14.0
Python Version(s)
3.13.7
Pip Version(s)
pip 25.2
Bug Report
When using ddtrace, listing models with openai library fails.
Reproduction Code
from ddtrace import config, patch
patch(openai=True)
import os
from openai import AsyncOpenAI, AuthenticationError, OpenAIError
import asyncio
async def t() -> bool:
"""Set up OpenRouter from a config entry."""
client = AsyncOpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=os.getenv("API_KEY"),
)
try:
async for _ in client.with_options(timeout=10.0).models.list():
break
except AuthenticationError as err:
print(f"Invalid API key: {err}")
except OpenAIError as err:
raise err
print("All good!")
asyncio.run(t())
Error Logs
/tmp/tmp.ENiFEPIQZR/main.py:18: RuntimeWarning: coroutine '_patched_endpoint_async.<locals>.patched_endpoint' was never awaited
async for _ in client.with_options(timeout=10.0).models.list():
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
File "/tmp/tmp.ENiFEPIQZR/main.py", line 26, in <module>
asyncio.run(t())
~~~~~~~~~~~^^^^^
File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/tmp/tmp.ENiFEPIQZR/main.py", line 18, in t
async for _ in client.with_options(timeout=10.0).models.list():
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
TypeError: 'async for' requires an object with __aiter__ method, got coroutine
Libraries in Use
annotated-types==0.7.0
anyio==4.10.0
bytecode==0.17.0
certifi==2025.8.3
ddtrace==3.14.0
distro==1.9.0
envier==0.6.1
h11==0.16.0
httpcore==1.0.9
httpx==0.28.1
idna==3.10
importlib_metadata==8.7.0
jiter==0.10.0
legacy-cgi==2.6.3
openai==1.107.2
opentelemetry-api==1.37.0
protobuf==6.32.1
pydantic==2.11.9
pydantic_core==2.33.2
sniffio==1.3.1
tqdm==4.67.1
typing-inspection==0.4.1
typing_extensions==4.15.0
wrapt==1.17.3
zipp==3.23.0
Operating System
No response