MCPcopy
hub / github.com/openai/openai-python / async_client

Function async_client

tests/conftest.py:65–91  ·  view source on GitHub ↗
(request: FixtureRequest)

Source from the content-addressed store, hash-verified

63
64@pytest.fixture(scope="session")
65async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncOpenAI]:
66 param = getattr(request, "param", True)
67
68 # defaults
69 strict = True
70 http_client: None | httpx.AsyncClient = None
71
72 if isinstance(param, bool):
73 strict = param
74 elif is_dict(param):
75 strict = param.get("strict", True)
76 assert isinstance(strict, bool)
77
78 http_client_type = param.get("http_client", "httpx")
79 if http_client_type == "aiohttp":
80 http_client = DefaultAioHttpClient()
81 else:
82 raise TypeError(f"Unexpected fixture parameter type {type(param)}, expected bool or dict")
83
84 async with AsyncOpenAI(
85 base_url=base_url,
86 api_key=api_key,
87 admin_api_key=admin_api_key,
88 _strict_response_validation=strict,
89 http_client=http_client,
90 ) as client:
91 yield client

Callers

nothing calls this directly

Calls 3

is_dictFunction · 0.90
AsyncOpenAIClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected