osyra_ome.inference
Private pre-release / network boundary: The currently usable customer surface is offline verification of an existing signed artifact against an out-of-band trust anchor. Memory/network RPC APIs and host snippets on this page describe protocol and interface shape; the public Edge bridge, package publication, and release acceptance remain pending. Do not treat
api.osyra.ai:443examples as a released customer route.
Inference-attestation producer over the edge SSE inference stream (ENG-2554 / N6, ADR-284).
The OSYRA inference-binding producer. It drives an inference through the edge's OpenAI-compatible SSE proxy (``POST /api/v1/inference/stream``); when the gateway has OIR emit enabled, the edge mints the Osyra Inference Receipt (OIR) over the attested context + the produced output and returns it as ``oir_b64`` on the terminal SSE frame. This client streams the delta tokens, assembles the output, and surfaces the receipt — the SDK leg of the attested-memory-I/O spine.
Architecture (ADR-285 / the ENG-2546 round-table, Option C): the OIR is minted by the EDGE/OME, NOT the SDK — the SDK sends the request and the gateway (which holds the platform OIR signing key) emits the receipt. The SDK NEVER fabricates a receipt: when emit is dark (the V1 default) ``oir_b64`` is simply ``None`` (NO STUBS). The relying party verifies the receipt OFFLINE under the published ``oirTrustAnchors`` (the frontend ``verifyOirReceipt`` / a future SDK verifier) — never the SDK.
Transport: edge SSE over HTTP (httpx), with the SAME bearer JWT + ``os-workspace-id`` the gRPC ``OmeClient`` / ``GatedMemoryClient`` use; the edge derives the workspace server-authoritatively from the token. Only transport / auth / malformed-response failures raise; a normal stream returns.
Classes
class InferenceClient
A producer client for the edge inference SSE stream + its OIR receipt.
Construct with the edge inference stream URL (``…/api/v1/inference/stream``) + the same bearer JWT the gRPC ``OmeClient`` uses. Pass an ``http_client`` to inject a custom (or mock) transport; otherwise the client owns one and closes it on :meth:`close` / context exit.
Methods
__init__
def __init__(self, inference_url: str, *, token: str | None = None, workspace_id: str | None = None, timeout_seconds: float = DEFAULT_TIMEOUT_SECONDS, http_client: httpx.Client | None = None) -> Noneclose
def close(self) -> NoneClose the owned HTTP client (a no-op for an injected ``http_client``).
complete
def complete(self, model: str, *, prompt: str | None = None, messages: list[InferenceMessage] | None = None, max_tokens: int | None = None, temperature: float | None = None, top_p: float | None = None, stop: list[str] | None = None) -> InferenceResultDrive an inference to completion and return the assembled output + the OIR receipt.
Consumes the whole SSE stream. Raises :class:`OmeAuthError` / :class:`OmePolicyError` / :class:`OmeTransportError` / :class:`OmeWireFormatError` on auth / policy / transport / malformed failures; a normal stream returns an :class:`InferenceResult` (with ``oir_b64=None`` when the gateway did not emit a receipt).
stream
def stream(self, model: str, *, prompt: str | None = None, messages: list[InferenceMessage] | None = None, max_tokens: int | None = None, temperature: float | None = None, top_p: float | None = None, stop: list[str] | None = None) -> Iterator[str]Yield each delta token as it arrives (the terminal OIR frame carries no delta).
class InferenceMessage
Bases: BaseModel
One OpenAI-shaped chat turn.
Attributes
| Name | Type | Default |
| --- | --- | --- |
| content | str | |
| role | str | |
class InferenceResult
Bases: BaseModel
The assembled outcome of a streamed inference.
``output`` is the ordered concatenation of the delta tokens (the authoritative output the edge hashes into the OIR — ADR-286). ``oir_b64`` is the base64 OIR receipt when the gateway emitted one, else ``None`` (emit dark / not configured — NEVER a fabricated receipt).
Attributes
| Name | Type | Default |
| --- | --- | --- |
| finish_reason | str | None | None |
| oir_b64 | str | None | Field(default=None) |
| output | str | |
| usage | TokenUsage | None | None |
class TokenUsage
Bases: BaseModel
Token accounting reported on the terminal frame (may be absent).
Attributes
| Name | Type | Default |
| --- | --- | --- |
| completion_tokens | int | 0 |
| prompt_tokens | int | 0 |
| total_tokens | int | 0 |