Skip to main content
Direct model endpoints are experimental and are not recommended for new integrations or production verification workflows. Use the NEAR AI Cloud Gateway instead.
Independent requests to the same direct hostname can reach different serving instances. An attestation report does not establish deployment evidence for a later completion, and a later signature lookup can return 404. Do not use direct response signatures as a production verification gate. Use DirectInferenceClient only when maintaining an existing direct integration.

Install

The package requires Node.js 24 or later.

Send and verify an E2EE Chat Completion

Before sending the completion, the SDK verifies each model-attestation report returned by that endpoint. It does not request Gateway evidence. It encrypts supported Chat fields to a key from the verified model evidence and decrypts the response automatically.
verifyResponse() is explicit. For a streaming completion, consume the entire stream first, then call it with the completion ID so the SDK can verify the exact response bytes.

Add OHTTP

Set ohttp: true to encapsulate Chat requests and responses with OHTTP. OHTTP uses the SDK’s default Ed25519 signing algorithm; it is not compatible with signingAlgo: 'ecdsa'.
The Chat and verifyResponse() calls stay the same. The SDK verifies the direct endpoint’s signed OHTTP configuration before sending Chat; a missing or invalid configuration blocks the request. For a direct endpoint, both OHTTP and E2EE are scoped to the model service.
OHTTP applies only to Chat. Attestation and signature requests remain regular HTTPS. The configured endpoint or proxy must expose /ohttp at the same origin. Authorization and custom headers sent on the outer request, along with the client’s network address, are not hidden by OHTTP.

Node, browser, and proxy integrations

The example uses @nearai/inference-sdk/node. Direct endpoint TLS binding is not currently enabled; normal HTTPS certificate validation still applies. For a browser or an application proxy, import from @nearai/inference-sdk. Configure the same explicit baseUrl for the endpoint your application uses.

Examples

See the Inference SDK examples and setup instructions for runnable direct-endpoint projects.
  • DirectInferenceClient: streaming and non-streaming Chat with E2EE and response verification.
  • OpenAI SDK integration: use DirectInferenceClient.fetch with the OpenAI client.
  • Manual verification: verify model attestations and response signatures directly. This example sends plaintext Chat bodies over HTTPS without E2EE.

Next steps

Verification

Understand the attestation and response-signature checks behind this flow.

E2EE Chat

Learn the protocol when you need to manage encryption yourself.