Skip to main content

OpenGradient Local — a drop-in, self-verifying private-inference proxy for AI agents. Point your OpenAI SDK at it; it routes prompts through OpenGradient's decentralized network of attestable Nitro TEE gateways and cryptographically verifies every response before a single token reaches your code.

Project description

OpenGradient Local

Drop-in, self-verifying private inference for AI agents.

Point any OpenAI SDK at og-local with one env var. It routes your prompts to OpenGradient's network of attestable TEE gateways and cryptographically verifies every response before a single token reaches your code — so you trust math, not us, the host, or the network. Your agent's code doesn't change.

Quickstart

# install (needs Python 3.11+; uv grabs one for you)
uv tool install opengradient-local        # or: pipx install opengradient-local

# run — logs you in (browser) the first time, then serves in the background
og-local

Point your agent at it:

export OPENAI_BASE_URL=http://127.0.0.1:11434/v1
export OPENAI_API_KEY=og-local            # ignored; your Chat login authenticates
from openai import OpenAI

client = OpenAI()  # picks up the env vars above
r = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Explain TEE attestation in one line."}],
)
print(r.choices[0].message.content)

That's it. Every response is verified before you see it — check the X-OpenGradient-Verified: true header (and the opengradient_verification block on the body). Streaming works too; it's verified before the first token replays.

Useful commands: og-local stop, og-local status, og-local endpoint (prints the env vars), og-local logout. Run sudo og-local endpoint once if you'd like a prettier http://opengradient.inference:11434/v1 base URL.


How it works

  your agent ──OpenAI SDK──▶ og-local ──HPKE-encrypted──▶ relay ──▶ TEE gateway
                                 ▲         (sees only ciphertext)     (runs the LLM,
                                 │                                     signs in-enclave)
                                 └──── verifies the enclave's signature, then replies
  1. Discover — picks a TEE from the on-chain registry (endpoint, encryption key, signing key, pcrHash).
  2. Encrypt — HPKE/Oblivious-HTTP-encrypts the request; the relay (which pays per call against your Chat account) only sees ciphertext.
  3. Verify — checks the enclave's RSA-PSS signature over the request/response hashes before handing anything back.

Trust chain: reproducible build → PCRs → on-chain registry (pcrHash + signing key) → per-response signature. The registry only admits a TEE whose Nitro attestation matches a known-good build. Pin it tighter with --expected-pcr <hash> to refuse any gateway whose pcrHash differs.

The protocol (registry discovery, OHTTP, verification) lives in the OpenGradient SDK (OhttpRelayClient, TEERegistry, verify_response), so this process and the web client share one implementation. This repo adds login + the local OpenAI-compatible server.

Commands

Command What it does
og-local Set up on first run, then serve (detached). The one command you need.
og-local stop Stop the background server.
og-local status Login + network config + whether the server is running.
og-local endpoint Print the agent env vars (sudo to also map opengradient.inference).
og-local login Authorize / re-authorize this device.
og-local setup Re-run the setup wizard.
og-local serve -f Run blocking in the foreground (for systemd/Docker).
og-local logout Remove the saved session.

Lifecycle

  • Background by default. Setup/login runs in the foreground, then it detaches and frees your terminal. Logs: ~/.opengradient/local/server.log. Use --foreground to block instead.
  • Stays signed in. The access token auto-refreshes. If you sign out in the Chat app, the next request tells you to run og-local login.
  • Survives a dead node. If the chosen TEE goes offline, it reselects another from the registry and retries once.

Configuration

Session + prefs live in ~/.opengradient/local/ (override with OG_LOCAL_HOME).

Env var Flag Default Purpose
OG_LOCAL_PORT --port 11434 Bind port.
OG_LOCAL_HOST --host 127.0.0.1 Bind host.
OG_LOCAL_TEE_ID --tee-id Pin a specific registry TEE.
OG_LOCAL_EXPECTED_PCR_HASH --expected-pcr Refuse any TEE whose pcrHash differs.
OG_LOCAL_APP_URL --app-url https://chat.opengradient.ai Chat app origin for login.

Notes & limitations

  • OpenAI-compatible only (/v1/chat/completions, /v1/models); an Anthropic /v1/messages shim is a planned follow-up.
  • Verify-before-emit trades a little first-token latency for the guarantee that no unverified token leaves the machine.
  • Payment via your Chat account (the relay settles x402 server-side) — no wallet or key lives here. For a self-custodial wallet path, see the SDK's og.LLM.

Development

git clone https://github.com/OpenGradient/local && cd local
uv sync --all-groups
uv run pytest
uv run ruff check . && uv run mypy og_local

Protocol-level crypto is tested in the SDK repo against the real tee-gateway recipient code, guaranteeing wire compatibility.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opengradient_local-0.1.4.tar.gz (266.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opengradient_local-0.1.4-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file opengradient_local-0.1.4.tar.gz.

File metadata

  • Download URL: opengradient_local-0.1.4.tar.gz
  • Upload date:
  • Size: 266.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for opengradient_local-0.1.4.tar.gz
Algorithm Hash digest
SHA256 593a3b307e306a2232d5035bd730dde7291a2b0e5dcc999abf6c52596eb36bbe
MD5 e0958b0a5fea15b4defcf3bdcb9fa305
BLAKE2b-256 150a46d0c278b3d97c034253f333325517fe9695a2552895a9d60b007ce35039

See more details on using hashes here.

File details

Details for the file opengradient_local-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: opengradient_local-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for opengradient_local-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fecbd96b1936af09ec1856faf9d1b0bb4d4c87cfbce6007cb8e7bf276241279f
MD5 d7ae2a022bcf93b8aa7a49c7c60271d1
BLAKE2b-256 4f215ec4f09c3390db43f15d97af08c741c231858acf39b5a23b4b2c68a013d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page