Skip to main content
The Tinfoil SDKs are drop-in replacements for OpenAI clients with automatic security verification on every connection. Available for Python, TypeScript/Node, Go, and Swift. The CLI can also act as a reverse proxy.

Available SDKs

LanguagePackageInstallationDocumentation
Pythontinfoilpip install tinfoilPython SDK
JavaScripttinfoilnpm install tinfoilJavaScript SDK
SwiftTinfoilAISwift Package ManagerSwift SDK
Gotinfoil-gogo get github.com/tinfoilsh/tinfoil-goGo SDK
CLItinfoil-cliVarious install methodsCLI Tool
If you’d like to see an SDK for a different language or runtime, please reach out at [email protected] and we’ll prioritize adding support for it.

Why you should use the SDKs

The SDKs make it easy to integrate Tinfoil into your applications without having to worry about encryption, attestation verification, or other security pitfalls. All the privacy and integrity features offered by Tinfoil are automatically verified for you and all connections are blocked in case of verification failure. Each SDK is designed to be a drop-in replacement for OpenAI clients. This means you can continue to use the chat completions or responses API formats with Tinfoil models. However, not all backend features are supported or enabled for all models. If you experience issues, please don’t hesitate to contact us.

Quick start

Step 1: Install the client SDK

Start by installing one of the Tinfoil SDKs:
pip install tinfoil

Step 2: Get a Tinfoil API key

Go to the Tinfoil Dashboard to generate an API key. You can also read our documentation on generating an API key.

Step 3: Make an inference request

from tinfoil import TinfoilAI

client = TinfoilAI(api_key="<YOUR_API_KEY>")

# Same API as OpenAI - automatic security
response = client.chat.completions.create(
    model="<MODEL_NAME>",
    messages=[{"role": "user", "content": "Hello world"}]
)

print(response.choices[0].message.content)
If you are currently using the OpenAI SDK in your codebase, all you need is to swap out the package import and model name. Our SDKs preserve the same code syntax and parameters.
Security Note: Direct API access requires manual attestation verification to ensure security. Without verification, you have no cryptographic proof that your data is processed in a secure enclave. While we still provide auditability through attestation transparency, this only allows for post-hoc verification of the connection and is a much weaker guarantee.
You can access the Tinfoil inference endpoint directly via HTTPS. However, this approach is not recommended in production for two reasons:
  1. Our SDKs perform automatic security verification that prevents man-in-the-middle attacks. When you access our API directly (without our SDKs), there is no guarantee of privacy.
  2. Our SDKs automatically choose the best secure router / enclave and perform load balancing. Performance can degrade if you do direct API access to our inference endpoints.
We continue to maintain compatibility with direct HTTPS connection for debugging purposes and simple testing (e.g., doing inference requests via cURL).
curl -X POST https://inference.tinfoil.sh/v1/chat/completions \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<MODEL_NAME>",
    "messages": [{"role": "user", "content": "Hello world"}]
  }'