# ExAgent v0.1.0 - Table of Contents

> An agent framework for Elixir — structured output, tool-calling and streaming, powered by the BEAM.

## Pages

- [ExAgent](readme.md)
- [LICENSE](license.md)

## Modules

- [ExAgent.Message.Part](ExAgent.Message.Part.md): Request & response part structs.
- [ExAgent.Message.Part.Retry](ExAgent.Message.Part.Retry.md): A retry prompt: validation errors (list of maps) or a plain message,
sent back to the model so it can correct itself.

- [ExAgent.Message.Part.System](ExAgent.Message.Part.System.md): A system / instruction prompt part.
- [ExAgent.Message.Part.Text](ExAgent.Message.Part.Text.md): A plain text chunk returned by the model.
- [ExAgent.Message.Part.Thinking](ExAgent.Message.Part.Thinking.md): A reasoning / chain-of-thought part (provider-dependent).
- [ExAgent.Message.Part.ToolCall](ExAgent.Message.Part.ToolCall.md): The model asking the agent to run a tool.
- [ExAgent.Message.Part.ToolReturn](ExAgent.Message.Part.ToolReturn.md): The return value of a tool call, fed back to the model.
- [ExAgent.Message.Part.User](ExAgent.Message.Part.User.md): A user prompt part (text or multimodal content list).
- [ExAgent.Message.Request](ExAgent.Message.Request.md): A message sent *to* the model.
- [ExAgent.Message.Response](ExAgent.Message.Response.md): A message returned *by* the model.
- [ExAgent.Message.Usage](ExAgent.Message.Usage.md): Token accounting for a single model response.

- Agent &amp; Loop
  - [ExAgent](ExAgent.md): An agent: model + instructions + tools + output spec, runnable as a loop that
alternates between **calling the model** and **executing tools** until a final
result is produced.
  - [ExAgent.RunContext](ExAgent.RunContext.md): The context object threaded through dynamic instructions, tool calls and
output validators during a single run.
  - [ExAgent.UsageLimits](ExAgent.UsageLimits.md): Run-level safety net: caps on requests and token usage, enforced before each
model request.

- Messages
  - [ExAgent.Message](ExAgent.Message.md): Message and part types exchanged between the agent and a model.

- Tools &amp; Output
  - [ExAgent.OutputSchema](ExAgent.OutputSchema.md): Structured output via Ecto schemas and changesets.
  - [ExAgent.Schema](ExAgent.Schema.md): Convert Elixir type expressions (as written in `::` annotations / typespecs)
into JSON Schema fragments — the foundation for `deftool` and structured
output.
  - [ExAgent.Tool](ExAgent.Tool.md): A tool the model may call.
  - [ExAgent.Tools](ExAgent.Tools.md): Define tools as plain Elixir functions, with their JSON Schema derived from
`::` type annotations and `@doc` strings — no hand-written schemas.

- Models
  - [ExAgent.Model](ExAgent.Model.md): Behaviour that every provider model implements.
  - [ExAgent.ModelProfile](ExAgent.ModelProfile.md): **Advisory** declaration of what a given model/provider supports, so callers
and future capabilities can negotiate gracefully per model — e.g. whether the
provider can do native JSON-schema output, forced tool calls, or extended
thinking.
  - [ExAgent.ModelRequestParameters](ExAgent.ModelRequestParameters.md): The per-request contract handed to a model. It bundles the tools the agent
has prepared (function tools + output tools), the negotiated output mode, and
the structured-output schema (if any).
  - [ExAgent.ModelSettings](ExAgent.ModelSettings.md): Per-request knobs sent to the model. Provider-specific options that are not
first-class fields can be carried in the immutable `:extra` map.

- Providers
  - [ExAgent.Models.Anthropic](ExAgent.Models.Anthropic.md): Anthropic Messages API provider, or any endpoint that speaks the same format
(e.g. Z.AI's `/api/anthropic`, which serves GLM models natively in Anthropic
form).
  - [ExAgent.Models.OpenAI](ExAgent.Models.OpenAI.md): OpenAI Chat Completions provider. Talks the real API over Req.
  - [ExAgent.Models.OpenRouter](ExAgent.Models.OpenRouter.md): [OpenRouter](https://openrouter.ai) provider.
  - [ExAgent.Models.Test](ExAgent.Models.Test.md): A deterministic, in-process model for development and tests.
  - [ExAgent.Providers.Anthropic](ExAgent.Providers.Anthropic.md): Implementation for providers that speak the **Anthropic Messages API**:
`POST {base_url}/v1/messages`.
  - [ExAgent.Providers.OpenAIChat](ExAgent.Providers.OpenAIChat.md): Shared implementation for any provider that speaks the OpenAI **Chat
Completions** wire format (`/v1/chat/completions`). This covers OpenAI itself
and OpenRouter (and DeepSeek, Groq, Together, etc.).
  - [ExAgent.Providers.SSE](ExAgent.Providers.SSE.md): Turn a Req asynchronous response into a lazy `Stream` of Server-Sent-Events.

- Capabilities &amp; Telemetry
  - [ExAgent.Capability](ExAgent.Capability.md): Composable middleware that observes/transforms an agent run at well-defined
points. This is ExAgent's "capabilities" spine, modelled the Elixir way: a
behaviour whose callbacks default to no-ops via `use ExAgent.Capability`, so
a capability overrides only the hooks it cares about.
  - [ExAgent.Telemetry](ExAgent.Telemetry.md): Telemetry event helpers.

- Exceptions
  - [ExAgent.ModelRetry](ExAgent.ModelRetry.md): A tool or output validator can return/raise this to ask the model to try
again. In Elixir we mostly use `{:error, reason}` tuples, but this exception
exists for the rescue-based escape hatch.

  - [ExAgent.RequestError](ExAgent.RequestError.md): Structured error returned by providers for transport/API failures.
  - [ExAgent.UnexpectedModelBehavior](ExAgent.UnexpectedModelBehavior.md): Raised/returned when the model behaves in a way the loop cannot recover from
(retries exhausted, no progress, usage limits hit).

