Services
Serving tactics over HTTP and calling them back. Import from lllm.services. Guide: Serving; wire format: Service API.
Apps
create_tactic_app
create_tactic_app(tactic: Tactic[Any, Any], *, title: str | None = None, description: str | None = None)
Create a FastAPI app for one tactic.
create_service_app
create_service_app(tactics: Mapping[str, Tactic[Any, Any]] | Sequence[Tactic[Any, Any]], *, title: str = 'LLLM Tactic Service', description: str = '', expose_single_tactic_routes: bool = False)
Create a FastAPI app exposing one or more tactics.
endpoint
Decorator namespace for custom tactic endpoint metadata.
Routes read the request body (raw JSON or the {"input": ..., "context":
...} envelope) and validate it against the tactic input type before
calling the method. get and delete requests may omit the body: the
method then receives the query parameters as a dict of strings (a repeated
key maps to a list), or None when there are none, and that value is not
validated against the tactic input type.
EndpointSpec
dataclass
EndpointSpec(method: HttpMethod, path: str, name: str, mode: EndpointMode = 'run', description: str = '', tags: tuple[str, ...] = tuple())
A domain-specific route a tactic wants to expose.
Clients
RemoteTactic
RemoteTactic(url: str, *, name: str | None = None, input_type: Any = None, output_type: Any = None, timeout: float | None = 30.0, transport: Any = None, async_transport: Any = None, metadata: dict[str, Any] | None = None)
Bases: Tactic[Any, Any]
Call a tactic through its HTTP service endpoints.
When name is omitted it is derived from url: the last path segment
(ignoring a trailing /run, /stream or /info), or else the host
and port, so http://127.0.0.1:8000 becomes 127.0.0.1-8000.
afetch_info
async
afetch_info(**kwargs: Any) -> TacticInfo
Fetch the service-advertised tactic contract asynchronously.
RemoteTacticError
RemoteTacticError(status_code: int, *, error_type: str | None = None, message: str | None = None, tactic: str | None = None, endpoint: str | None = None, request_id: str | None = None, detail: Any = None)
TacticResolver
TacticResolver()
Resolve tactic refs to in-process tactics or HTTP clients.
from_config
classmethod
from_config(path: str | Path) -> 'TacticResolver'
Load URL bindings from a local .lllm/config.toml style file.
Requests and responses
RunRequest
Bases: BaseModel
Canonical request envelope for tactic calls.
RunResponse
Bases: BaseModel
Canonical response envelope for successful tactic calls.
ErrorResponse
Bases: BaseModel
ErrorDetail
Bases: BaseModel
Stable service error body.
call_context_from_data
call_context_from_data(context_data: Mapping[str, Any] | None, *, tactic: Tactic[Any, Any], endpoint: str) -> CallContext
Build the CallContext a served tactic gets from a request's context.
A missing request_id (or call_id) gets a fresh one, a missing
tactic_ref defaults to the tactic's package_ref, endpoint names
the route, and unknown keys are ignored. A malformed context raises
SchemaError.
status_code_for_error
status_code_for_error(exc: Exception) -> int
The HTTP status a tactic service answers with when a call raises exc.
SchemaError and TacticUnsupportedError are 400; anything else is 500.