Expand description
Reach an OpenAI-compatible model server from anywhere over p2p.
The iroh types stay out of the public surface deliberately: callers
hold Tickets and handles, so an iroh major upgrade is this crate’s
problem, not its dependents’. The same rule shapes the error types:
failures arrive as ServeError / ConnectError variants a caller
can match a retry policy against, with the transport’s own error
reachable only as an opaque source.
§Features
serde (off by default) implements Serialize and Deserialize for
Ticket — as its canonical string, the same text Display prints
and FromStr reads, never as a struct — and for PipeStatus,
PeerView and NetworkMetrics, the first as the identifiers
PipeStatus::as_str already freezes and the other two as their own
fields. For an embedder that renders a status page from a JSON DTO;
the CLI has no use for it.
§Diagnostics
This crate emits tracing events and installs no subscriber. A
library that installed one would take the choice away from the binary it
is linked into, and would silence or duplicate whatever that binary had
already set up; modelpipe-cli installs one under -v, and any other
embedder does whatever it already does. Without a subscriber the events
cost a global atomic read apiece and go nowhere.
What they say is bounded on purpose. The serve side emits one info
line per exchange — method, path, backend status, outcome, elapsed — and
one per peer arriving and leaving. No event carries a token, a ticket,
a header value, or a query string, which is the same discipline the
hand-written Debug impls on Ticket and
TokenPolicy exist for: a credential in a log file is a credential
that leaked, and a log file is the easiest place in a system to forget
that. The property is asserted rather than intended — the tests drive a
request whose credential and query string are distinctive strings, and
then look for them in the captured output.
Structs§
- Connect
Handle - A live connect side.
- Connect
Options - Options for
connect. Same contract asServeOptions. - Network
Metrics - What the transport underneath a pipe has been doing, as plain numbers.
- Peer
View - One connected peer, as the serve side sees it.
- Serve
Handle - A live serve side.
- Serve
Options - Options for
serve. - Ticket
- A pairing ticket: how one machine finds and authenticates another’s listener.
Enums§
- Close
Reason - Why a pipe reached
PipeStatus::Closed. - Connect
Error - Why
connectfailed. Same contract asServeError: variants a retry policy can match on, transport details behindsource. - Named
Token Refusal - Why a token could not be held under a name.
- Pipe
Status - What the transport is doing right now.
- Serve
Error - Why
servefailed. - Ticket
Parse Error - Why a ticket string failed to parse. Deliberately coarse: a ticket is pasted or scanned, so the advice is one line — re-copy it, or, when the format is newer than this build, upgrade.
- Token
Policy - How the serve side authenticates requests.
Functions§
- connect
- Bind a local port that transparently is the remote backend. Point any
OpenAI-compatible client at
ConnectHandle::base_url, with the serve side’s bearer token as the API key. - serve
- Expose the OpenAI-compatible server at
backend_url(e.g.http://127.0.0.1:11434) to holders of the returned handle’s ticket.