Skip to content

HTTP client

MimirClient speaks to a mimir serve server with the same methods as Mimir, so code, decision tools and adapters take either. It needs only the base install, and api_key defaults to $MIMIR_API_KEY. Connection errors, timeouts and 429, 502, 503, 504 and 529 responses are retried with exponential backoff that honours Retry-After; other errors raise a ServerResponseError subclass keeping the status and body. Usable as a context manager; close it when done.

from mimir import MimirClient

with MimirClient("https://mimir.internal") as remote:
    result = remote.choose("...", "Which team?", options=["billing", "security"])

mimir.client.http.MimirClient

Bases: Decider

Client for a MIMIR server, with the same interface as the local engine.

Parameters:

Name Type Description Default
base_url str

Server URL, e.g. https://mimir.internal.

required
api_key str | None

Bearer token; defaults to $MIMIR_API_KEY.

None
timeout_s float

Timeout for each HTTP request.

30.0
max_retries int

Retries after the first attempt for retryable failures.

2
backoff_s float

Base delay of the exponential backoff.

0.5
transport BaseTransport | None

Custom httpx transport, e.g. for testing.

None
async_transport AsyncBaseTransport | None

Custom httpx async transport, e.g. for testing.

None