Install
The SDK is available on crates.io. Use Rust stable and Cargo. Add the SDK to your application:Examples
Choose the tab matching your model’s API. These examples assume a project with Tokio and serde_json; use them insrc/main.rs.
- Chat Completions
- Responses
- Messages
- System One
Call a supported NEAR TEE model with E2EE enabled, then verify the completion.
E2EE
End-to-end encryption is disabled by default. Sete2ee: true to encrypt supported Chat fields to a verified model key and decrypt the response automatically.
E2EE requires a NEAR vLLM model with attestation enabled. Other providers use Gateway-only verification; set e2ee: false for those models.
Verification
Before sending Chat, the client verifies the Gateway and every returned model report for supported models. Gateway TLS identity verification is enabled by default and subsequent requests are pinned to that identity. Normal HTTPS certificate validation remains enabled. Failed required checks stop the request. Response-signature verification is explicit: callclient.verify_response(id).await? after receiving the completion. The client retains the exact request and response bytes automatically, including encrypted wire bytes when E2EE is enabled.
See Verification for receipt IDs and signature kinds.
Response records expire 60 minutes after the full response is read, by default. Verify each response before its record expires.
To check a deployment without sending a prompt, call client.verify(model).await?. For custom policies and cache settings, see the Rust verification guide.
Streaming and HTTP transport
Usechat_request() with "stream": true, then send(reqwest::Request) to obtain an InferenceResponse. Consume its body through HTTP EOF, including bytes after SSE [DONE], before calling verify_response() with the completion ID from an SSE data event. Dropping a partial stream leaves no verifiable receipt. Output displayed before verification succeeds is not yet signature-verified.
Rust exposes its own reqwest transport API rather than an OpenAI SDK adapter. Body chunks are SSE bytes and need not correspond to complete events or UTF-8 strings. The streaming guide and Gateway client example show how to consume responses and verify receipts. Use create_response() for Responses JSON, or response_request() with send() for Responses streaming.
OHTTP
Setohttp: true when constructing the client to encapsulate the Chat HTTP exchange to the attested Gateway:
SigningAlgo::Ecdsa. E2EE is configured independently. Missing or invalid Gateway OHTTP evidence blocks Chat.
OHTTP supports Chat Completions, Responses, and Messages through the Gateway; System One does not support OHTTP. Attestation and signature requests remain regular HTTPS. The endpoint must expose
/ohttp at the same origin. Outer authorization headers and the client’s network address are not hidden by OHTTP.Examples and reference
- Rust verification guide: policies, encryption, streaming, TLS binding, and errors.
- Rust API reference: client options, verification functions, defaults, and result fields.
- Runnable Rust examples: Gateway and direct clients, standalone verification, and JSON/SSE.