Expand description
lm15 — the Rust port of lm15: one canonical request/response model
over the providers declared by lm15-contract. CONTRACT_PIN names the
implementation target, not proof of conformance; see docs/catchup.md.
The map, in playbooks/port.md module order:
- canonical types + serde —
types,serde(Canonical). - errors and provider error normalization —
errors,registry. - auth —
auth(AUTH-1..10: credentials, the policy table, the doctor, stored logins with refresh, the login door) andcloud(the cloud chains, AUTH-11, SigV4, RS256, host settings). - dialects, request side —
wire(the emit path),compat(the preset tables), the fourdialects,adapter(ProviderLM, the named constructors),registry::adapter_for. - response side and stream assembly —
sse,stream; the network —transport,response_stream; the router —router(LMRouter); theblockingfeature mirrors the names. - model listing, the files / batch / cache surfaces (
surfaces), image / speech / video generation, and live sessions (live) — all methods onProviderLM.
Re-exports§
pub use adaptation::Adaptation;pub use adaptation::AdaptationAction;pub use adaptation::AdaptationPolicy;pub use adapter::AnthropicLM;pub use adapter::ClaudeCodeLM;pub use adapter::EventStream;pub use adapter::GeminiLM;pub use adapter::LmBuilder;pub use adapter::OpenAIChatLM;pub use adapter::OpenAICodexLM;pub use adapter::OpenAILM;pub use adapter::ProviderLM;pub use adapter::TypeSafeLM;pub use adapter::XaiLM;pub use auth::default_credentials_path;pub use auth::AccessPolicy;pub use auth::Credential;pub use auth::CredentialFileStore;pub use auth::CredentialProvider;pub use auth::CredentialSource;pub use auth::HostSpec;pub use auth::SourcedCredential;pub use cloud::hosts::HostSettings;pub use compat::AnthropicCompat;pub use compat::OpenAIChatCompat;pub use compat::OpenAIResponsesCompat;pub use dialects::openai_chat::ingest::request_from_openai_chat;pub use dialects::openai_chat::response_from_openai_chat;pub use errors::normalize_error;pub use errors::CollectionLimit;pub use errors::DiagnosticHeaders;pub use errors::ErrorClass;pub use errors::ErrorCode;pub use errors::ErrorMeta;pub use errors::Lm15Error;pub use jobs::BatchJob;pub use jobs::VideoJob;pub use jobs::WaitError;pub use jobs::WaitOptions;pub use jobs::WaitSnapshot;pub use judgments::choice;pub use judgments::choice_described;pub use judgments::judgments;pub use judgments::judgments_named;pub use judgments::score;pub use judgments::score_named;pub use judgments::yes_no;pub use judgments::Judgment;pub use judgments::JudgmentKind;pub use live::LiveEventSource;pub use live::LiveSession;pub use live::Turn;pub use live::TurnEnd;pub use live::TurnLimits;pub use live::TurnView;pub use live::DEFAULT_TURN_MAX_BYTES;pub use live::DEFAULT_TURN_MAX_EVENTS;pub use response_stream::ResponseStream;pub use router::openai_chat_model_string;pub use router::DeclaredProvider;pub use router::LMRouter;pub use router::Resolution;pub use router::RouteRule;pub use router::RouteSource;pub use router::RouterConfig;pub use router::DEFAULT_RULES;pub use router::LITELLM_PROVIDER_PREFIXES;pub use serde::Canonical;pub use testing::LanguageModel;pub use transport::HttpTransport;pub use transport::Timeouts;pub use transport::Transport;pub use transport::TransportResponse;pub use transport::DEFAULT_MAX_CONNECTIONS;pub use wire::TransportRequest;pub use types::*;
Modules§
- adaptation
- MAP-13 adaptation records and synchronous, call-local preparation. A collector never spans an await: build the wire synchronously, then send it.
- adapter
- Provider adapters (playbooks/api-family.md § Providers, direct): one
adapter value,
ProviderLM, and the named constructors —AnthropicLM,OpenAILM,OpenAIChatLM,GeminiLM,XaiLM,ClaudeCodeLM,OpenAICodexLM— each a builder bound to a dialect and an access policy (spec/auth.md AUTH-10: subscription “adapters” are constructors that bind a policy, never a subclass). - auth
- lm15-contract auth surface, module 3a (playbooks/port.md; spec/auth.md, ratified 2026-08-31, amendments through 2026-09-19):
- cloud
- Cloud doors (spec/auth.md AUTH-10
host, AUTH-11 signing). - compat
- Compat values: a server’s wire quirks as data (
lm15/compat.py; spec/auth.md AUTH-10 “for the chat dialect an optional compat value”; playbooks/api-family.md rule 7: a knob exists only when the wire has no other way, and never a new one here — a case that needs one is a report). - dialects
- The four wire dialects (module 4). Each lives in its own directory and
is selected by
dialect_for; the registry maps a provider string to aDialectId, the access policy binds the door. - errors
- Canonical error taxonomy (spec/vocabularies.md § ErrorCode).
- jobs
- Job handles:
BatchJobandVideoJob(api-family § Beyond chat; contractchanges/2026-09-11-job-handles-live-turns-profiles.md§ 1). - judgments
- Declared judgments, equivalent provider schemas, and structured answers (MAP-14). This module is pure; probability totals are deliberately not validated (INV-052).
- live
- Live sessions (module 9; playbooks/api-family.md, the reference’s
lm15.live.AsyncWebSocketLiveSession): a websocket driven by the dialect’sLiveCodec. The codec (config → setup frames, client event → frames, frame → events) is the contract; the session mechanics here are this language’s own. - login
- Managed authentication — sign in once, use everywhere (spec/auth-managed.md AUTH-12–26).
- registry
- The one table of named providers (mirrors
lm15.registry, copied as data — port.md rule 2). A provider string names one wire dialect plus, for bound entries, the compat preset of the server it targets, andadapter_forbinds the three (dialect + policy + compat) into aProviderLMthe way the reference router does. - response_
stream ResponseStream: the assembled stream (playbooks/api-family.md § The core loop; the reference’slm15.result.ResponseStream).- router
LMRouter(playbooks/api-family.md § The core loop; the reference’slm15.router): a lookup table you can read, not a framework. Three resolution rungs in fixed order, then the AUTH-1 credential chain, then one adapter per provider, built lazily and reused.- scoring
- Candidate-sequence likelihood using the server’s chat template and token trie.
MAP-14 §4: tokenize candidates with a terminator, batch all trie nodes in ONE
completions request, add raw path log-probabilities, normalize only once.
The pure hooks work without a transport;
completeis an async driver whose callback owns authentication, HTTP errors, and reply diagnostics. - serde
- Canonical JSON serde (docs/serde-rules.md, spec/invariants.md § Serde leniency).
- sse
- Server-Sent Events (the reference’s
lm15/sse.py): bytes in, events out. The parser is incremental so a transport can feed it as chunks arrive;parse_sseis the one-shot form over a whole body. - stop
- Score-preserving client-side stop with an explicit source-closure protocol.
The driver must close/drop its actual source immediately on
close_source. - stream
- Stream materialization (the reference’s
lm15/result.py): one engine every port shares, push-based because Rust has no generators. - surfaces
- Shared pieces of the endpoint surfaces (modules 7–8: files, batch,
cache, generation, video): the multipart encoders of
lm15/providers/common.py, byte-for-byte (the harness compares multipart bodies with only the boundary normalized), the timestamp fold, and the readiness tables copied as data. - testing
- Deterministic test doubles. No network, environment, or global registry.
- tooling
- A static public-surface snapshot, driven by canonical vocabularies and provider declarations rather than runtime language introspection.
- transport
- The HTTP transport under
complete/stream(the reference’slm15/transports): bytes in, bytes out, nothing of the lm15 type system. - types
- Canonical types (spec/types.md) with construction-time invariants
(spec/invariants.md). Every type carries public fields, a
Defaultwhere the spec gives one, and avalidate()that enforces the INV-* rules; factory constructors validate and returnResult. - wire
- The request side every dialect plugs into (module 4 W0; the fixed architecture of the module plan).