Skip to main content

Crate modelpipe

Crate modelpipe 

Source
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§

ConnectHandle
A live connect side.
ConnectOptions
Options for connect. Same contract as ServeOptions.
NetworkMetrics
What the transport underneath a pipe has been doing, as plain numbers.
PeerView
One connected peer, as the serve side sees it.
ServeHandle
A live serve side.
ServeOptions
Options for serve.
Ticket
A pairing ticket: how one machine finds and authenticates another’s listener.

Enums§

CloseReason
Why a pipe reached PipeStatus::Closed.
ConnectError
Why connect failed. Same contract as ServeError: variants a retry policy can match on, transport details behind source.
NamedTokenRefusal
Why a token could not be held under a name.
PipeStatus
What the transport is doing right now.
ServeError
Why serve failed.
TicketParseError
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.
TokenPolicy
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.