Skip to main content
A model client is the object that actually talks to an LLM provider. Motus ships four of them (OpenAI, Anthropic, Gemini, OpenRouter), all implementing the same BaseChatClient interface. You pick a client, pass it into ReActAgent, and switch providers later by changing the import and the model name; the agent code does not move.

Supported providers

Each client reads its env var automatically if you do not pass api_key. They all also accept arbitrary **kwargs that are forwarded to the underlying provider SDK (timeout, max_retries, default_headers, and so on).

Creating a client

Local models

OpenAIChatClient works with any OpenAI-compatible server. Point base_url at your local service:
No API key is required when the server does not enforce authentication.

Prompt caching

AnthropicChatClient supports Anthropic’s prompt caching. Set cache_policy on the agent; see Prompt caching on the Agents page for the full table of options and TTLs. On providers that do not implement prompt caching (OpenAI, Gemini, OpenRouter), cache_policy is a no-op.

Reasoning

Models with extended thinking (Opus 4.6, Sonnet 4.6, and others) are controlled by the reasoning parameter on the agent. See Reasoning on the Agents page for ReasoningConfig.auto(), effort=, budget_tokens=, and ReasoningConfig.disabled().

Message and completion types

The two types every client reads and writes. ReActAgent handles them for you, so most of the time you only need to construct them when you write a custom agent or call a client by hand.

ChatMessage

The unified message format that every client reads and writes. Use the factory methods for each role:
user_message and assistant_message accept an optional base64_image for vision inputs.

ChatCompletion

The return value of client.create() and client.parse(). The fields a caller usually reads: Call completion.to_message() to turn a completion into a ChatMessage you can append to conversation history.

Calling a client directly

Every client implements two async methods. ReActAgent calls these for you; you only reach for them when building a custom agent or running a one-off completion.