angr.llm_client

class angr.llm_client.AgentKind

Bases: Enum

The kind of pydantic-ai Agent to retrieve from the LLMClient cache.

STRING = 'string'
STRUCTURED = 'structured'
class angr.llm_client.LLMClient

Bases: object

A client for interacting with LLMs via pydantic-ai. Used by the decompiler to suggest improved variable names, function names, and types.

__init__(model, api_key=None, api_base=None, max_tokens=4096, temperature=0.0)
Parameters:
  • model (str)

  • api_key (str | None)

  • api_base (str | None)

  • max_tokens (int)

  • temperature (float)

infer_provider(provider)

Infer the provider from the provider name.

Return type:

Provider[Any]

Parameters:

provider (str)

classmethod from_env()

Create an LLMClient from environment variables.

Uses ANGR_LLM_MODEL (required), ANGR_LLM_API_KEY (optional), and ANGR_LLM_API_BASE (optional). Returns None if ANGR_LLM_MODEL is not set.

Return type:

LLMClient | None

completion(messages, **kwargs)

Call the LLM with the given messages and return the response text.

Return type:

str

Parameters:

messages (list[dict[str, str]])

completion_structured(messages, output_type, raise_exc=False, **kwargs)

Call the LLM with the given messages and return a validated Pydantic model. Returns None if the call fails.

Parameters:
  • raise_exc (bool) – If True, exceptions are propagated to the caller instead of being caught.

  • messages (list[dict[str, str]])

  • output_type (type[T])

Return type:

Optional[TypeVar(T)]

completion_json(messages, raise_exc=False, **kwargs)

Call the LLM and parse the response as JSON. Strips markdown code fences if present. Returns None on parse failure. Kept for backwards compatibility; prefer completion_structured().

Parameters:
  • raise_exc (bool) – If True, exceptions are propagated to the caller instead of being caught.

  • messages (list[dict[str, str]])

Return type:

dict | None