Skip to main content
Version: latest

agrag.agents.model.build_chat_model

build_chat_model(config:LLMClientConfig, *, max_retries:int | None = None) -> Any

Translate one LLMClientConfig into a LangChain chat model.

Covers anthropic, openai, openai-generic (mapped to ChatOpenAI with base_url set), and google-ai. The remaining LLMProvider values are valid for BAML but have no agent-side mapping yet.

Parameters:

  • config (LLMClientConfig) – The provider, model, api_key, and base_url to use.
  • max_retries (int | None) – Retries of one model call after a failed attempt. None keeps the provider library's default.

Returns:

  • Any – A constructed, ready-to-call BaseChatModel.

Raises: