The LLM layer normalizes communication with language models across all supported providers. Your agent code uses provider-agnostic contracts (Documentation Index
Fetch the complete documentation index at: https://afk.arpan.sh/llms.txt
Use this file to discover all available pages before exploring further.
LLMRequest / LLMResponse) while built-in adapters handle the provider-specific details.
The LLMBuilder
Create LLM clients with the builder pattern:Middleware
The LLM layer supports middleware for intercepting and transforming requests and responses. Use middleware for logging, tracing, caching, and custom request/response handling.Built-in middleware
Custom middleware
Middleware protocols
| Protocol | Operation | Signature |
|---|---|---|
LLMChatMiddleware | Non-streaming chat | async (call_next, req: LLMRequest) -> LLMResponse |
LLMEmbedMiddleware | Embeddings | async (call_next, req: EmbeddingRequest) -> EmbeddingResponse |
LLMStreamMiddleware | Streaming chat | (call_next, req: LLMRequest) -> AsyncIterator[LLMStreamEvent] |
Supported providers
OpenAI
GPT-4.1, GPT-4.1-mini, GPT-4.1-nano, o-series
Anthropic
Claude Opus and Sonnet families
LiteLLM
100+ providers via the LiteLLM proxy
LLMClient interface. Your agent code never touches provider-specific types.
Example model choices
Use these as starting points, then verify model availability, pricing, and context limits with your provider account.| Scenario | Starting point |
|---|---|
| General purpose | OpenAI gpt-4.1-mini |
| Complex reasoning | OpenAI gpt-4.1 or Anthropic claude-opus-4-5 |
| Cost-sensitive | OpenAI gpt-4.1-nano |
| Non-OpenAI/Anthropic model | LiteLLM adapter |
| Custom or self-hosted | Custom adapter |
How agents use the LLM layer
You rarely buildLLMClient directly. Agents resolve their model automatically:
Next steps
Contracts
LLMRequest / LLMResponse — what flows across the boundary.
Adapters
Built-in providers and custom adapter registration.