Skip to content

AnthropicClient

autogen.beta.config.anthropic.anthropic_client.AnthropicClient #

AnthropicClient(api_key=None, base_url=None, timeout=None, max_retries=2, default_headers=None, http_client=None, create_options=None, prompt_caching=True)

Bases: LLMClient

Source code in autogen/beta/config/anthropic/anthropic_client.py
def __init__(
    self,
    api_key: str | None = None,
    base_url: str | None = None,
    timeout: float | None = None,
    max_retries: int = 2,
    default_headers: dict[str, str] | None = None,
    http_client: httpx.AsyncClient | None = None,
    create_options: CreateOptions | None = None,
    prompt_caching: bool = True,
) -> None:
    self._client = AsyncAnthropic(
        api_key=api_key,
        base_url=base_url,
        timeout=timeout if timeout is not None else NOT_GIVEN,
        max_retries=max_retries,
        default_headers=default_headers,
        http_client=http_client,
    )

    self._create_options = {k: v for k, v in (create_options or {}).items() if k != "stream"}
    self._streaming = (create_options or {}).get("stream", False)
    self._prompt_caching = prompt_caching