Install
The SDK is available on PyPI. The package requires Python 3.12 or later.Examples
Choose the tab matching your model’s API. Save the example asexample.py and run it with python example.py.
- 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.e2ee=True encrypts supported Chat fields to a verified model key and decrypts 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, for supported NEAR TEE models, every returned model report. Gateway TLS identity verification is enabled by default and subsequent requests are pinned to that identity. Failed required checks stop the request. Response-signature verification is explicit: callawait client.verify_response(completion.id) after receiving the completion. It verifies the exact request and response bytes retained by the client against the relevant verified evidence.
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 or the client closes.
To check a deployment without sending a prompt, call await client.verify(model). For custom policies and cache settings, see the Python verification guide.
Streaming
Consume the entire stream before callingverify_response(). This example buffers the text until verification succeeds; use it inside the client context above:
OHTTP
Setohttp=True when constructing the client to encapsulate the Chat HTTP exchange to the attested Gateway:
signing_algo="ecdsa". E2EE is configured independently. Missing or invalid Gateway OHTTP evidence blocks the Chat request.
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
- Python verification guide: policies, encryption, streaming, and errors.
- Python API reference: client options, verification functions, and result fields.
- Runnable Python examples.
- OpenAI SDK integration: Chat Completions and Responses.
- Anthropic SDK integration.
- TypeSafe SDK integration.