Skip to main content

cohere-tng

Python SDK for TNG — drop-in OHTTP encryption for httpx with TEE attestation verification. Built as a native Rust extension via PyO3.

Install

pip install cohere-tng

Usage

Sync

import httpx
import cohere_tng

transport = cohere_tng.Transport(verify={
    "model": "passport",
    "as_provider": "ita",
    "ita_jwks_addr": "https://portal.trustauthority.intel.com",
    "policy_ids": ["my-policy"],
})

with httpx.Client(transport=transport) as client:
    resp = client.get("https://api.example.com/v1/chat")
    print(resp.json())

    # Attestation token is available as a response header
    token = resp.headers.get("x-tng-attestation-token")

Async

import httpx
import cohere_tng

transport = cohere_tng.AsyncTransport(verify={
    "model": "passport",
    "as_provider": "ita",
    "ita_jwks_addr": "https://portal.trustauthority.intel.com",
    "policy_ids": ["my-policy"],
})

async with httpx.AsyncClient(transport=transport) as client:
    resp = await client.get("https://api.example.com/v1/chat")
    print(resp.json())

Response streaming

with httpx.Client(transport=transport) as client:
    with client.stream("POST", url, json=payload) as resp:
        for chunk in resp.iter_bytes():
            process(chunk)

Request streaming

Request bodies provided as generators are streamed through OHTTP without buffering the entire payload in memory:

def audio_chunks():
    with open("recording.wav", "rb") as f:
        while chunk := f.read(8192):
            yield chunk

with httpx.Client(transport=transport) as client:
    resp = client.post(url, content=audio_chunks())

Configuration

Both verify and ohttp follow the same schema as TNG's configuration.

  • verify (required) — Attestation verification config dict. Pass None to explicitly disable verification — not recommended for production.
  • ohttp (optional) — OHTTP config dict (forward_headers, tls_ca_certs, etc.).

Development

python3 -m venv .venv
.venv/bin/pip install maturin httpx
.venv/bin/maturin develop
.venv/bin/pytest tests/

How it works

The cohere-tng package embeds TNG's Rust OHTTP implementation directly into the Python process via PyO3. When you make a request through cohere_tng.Transport:

  1. The TEE running the TNG egress is verified via remote attestation (e.g. Intel Trust Authority) before any data is sent.
  2. The request is encrypted using OHTTP (Oblivious HTTP) in-process.
  3. The encrypted payload is sent to the TNG egress inside the verified TEE.
  4. The egress decrypts and forwards the request to the actual backend.
  5. The response follows the reverse path, decrypted in-process before being returned to httpx. The attestation token is included as an x-tng-attestation-token response header.

Both request and response bodies are streamed — large payloads are never fully buffered in memory.

Acknowledgements

cohere-ai/tng is a fork of inclavare-containers/tng. Licensed under Apache-2.0.

Metadata

Release files for cohere-tng 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for cohere-tng 0.6.0
File
cohere_tng-0.6.0-cp38-abi3-manylinux_2_28_aarch64.whl CPython 3.8 abi3 Linux glibc 2.28+ ARM64 Details
cohere_tng-0.6.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
cohere_tng-0.6.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
cohere_tng-0.6.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details

Total release size: 25.0 MB

Release files / cohere_tng-0.6.0-cp38-abi3-manylinux_2_28_aarch64.whl

Download URL cohere_tng-0.6.0-cp38-abi3-manylinux_2_28_aarch64.whl
Size 6.5 MB
Tags CPython 3.8 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
47e3cba71570f6a402123e87ec281d2a067de2dd7d52804c8731caac7ec892c9
BLAKE2b-256 checksum
How to use checksums
8d834cc3e36aa7999b31c12fc228bdd3b8344e7660626224436d5f6cb2becd95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2026.

Transparency log

Release files / cohere_tng-0.6.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL cohere_tng-0.6.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 6.6 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
dc7e99c4cf797a76eb83ecbda60704b206886f9f7b9dd4c98946aae380137666
BLAKE2b-256 checksum
How to use checksums
10a0284ce8281c39ea5dcb5132f442452def4368541fe8c9665513133c629591
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2026.

Transparency log

Release files / cohere_tng-0.6.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL cohere_tng-0.6.0-cp38-abi3-macosx_11_0_arm64.whl
Size 5.8 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
92dfd6204b87a479da8e78e861484d9e6de8f8390d89f18aa80ec61945d71463
BLAKE2b-256 checksum
How to use checksums
fc599425c698504d4f18f08cdbdd0bb8b82032aab3f2c99ffb404b052a8d3dd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2026.

Transparency log

Release files / cohere_tng-0.6.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL cohere_tng-0.6.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 6.0 MB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1473b28644716706bddd3a6b284fbe7641893ceba25e69e7b6ac9abe9959b975
BLAKE2b-256 checksum
How to use checksums
11895497411a727a0134d6d426a153fabc049e1e2994df1a1443f3a7c3d4e3fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 27, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.0

4 release files

0.7.0

4 release files

This release

0.6.0 This release

4 release files

0.5.0

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page