Skip to content

OpenAIClient

autogen.beta.config.openai.openai_client.OpenAIClient #

OpenAIClient(api_key=None, organization=None, project=None, base_url=None, websocket_base_url=None, timeout=not_given, max_retries=DEFAULT_MAX_RETRIES, default_headers=None, default_query=None, http_client=None, create_options=None)

Bases: LLMClient

Source code in autogen/beta/config/openai/openai_client.py
def __init__(
    self,
    api_key: str | None = None,
    organization: str | None = None,
    project: str | None = None,
    base_url: str | None = None,
    websocket_base_url: str | None = None,
    timeout: Any = not_given,
    max_retries: int = DEFAULT_MAX_RETRIES,
    default_headers: dict[str, str] | None = None,
    default_query: dict[str, object] | None = None,
    http_client: httpx.AsyncClient | None = None,
    create_options: CreateOptions | None = None,
) -> None:
    self._client = AsyncOpenAI(
        api_key=api_key,
        organization=organization,
        project=project,
        base_url=base_url,
        websocket_base_url=websocket_base_url,
        timeout=timeout,
        max_retries=max_retries,
        default_headers=default_headers,
        default_query=default_query,
        http_client=http_client,
    )

    self._create_options = create_options or {}
    self._streaming = self._create_options.get("stream", False)