Overview
Complete guide to Tinfoil SDKs for secure AI inference
Welcome to Tinfoil SDKs — Drop-in replacements for OpenAI clients with built-in security verification. Choose your language below and start building with confidential AI in minutes.
Quick Start
1. Install Your Preferred SDK
2. Get Your API Key
Visit the Tinfoil Dashboard to generate your API key.
3. Make Your First Request
Available SDKs
Language | Package | Installation | Status | Documentation |
---|---|---|---|---|
Python | tinfoil | pip install tinfoil | ✅ Stable | Python SDK |
Node.js | tinfoil | npm install tinfoil | ✅ Stable | Node.js SDK |
Swift | TinfoilAI | Swift Package Manager | 🚧 Beta | Swift SDK |
Go | tinfoil-go | go get github.com/tinfoilsh/tinfoil-go | ✅ Stable | Go SDK |
CLI | tinfoil-cli | Various install methods | 🚧 Beta | CLI Tool |
Don’t see an SDK for your language? Contact us at [email protected] and we’ll prioritize adding support for your preferred programming language.
Choose Your SDK
Python SDK
Most Popular - Full async/await support, comprehensive type hints, and extensive documentation. Perfect for ML pipelines and backend services.
Node.js SDK
Web & Backend - TypeScript first design, edge runtime compatible, perfect for modern web applications and serverless functions.
Swift SDK
iOS & macOS - Native Swift implementation with SwiftUI integration, Combine support, and iOS/macOS optimizations.
Go SDK
High Performance - Optimized for concurrent workloads, microservices, and high-throughput applications.
CLI Tool
Command Line - Perfect for scripts, automation, testing, and quick experimentation with Tinfoil models.
What Are Tinfoil SDKs?
Tinfoil provides SDKs that make it easy to integrate confidential AI inference into your applications. Each SDK is designed to be a drop-in replacement for OpenAI clients while adding powerful security guarantees.
Key Benefits
- Automatic Security Verification - Every request verifies you’re connecting to a genuine secure enclave
- Drop-in Compatibility - Replace
openai
imports withtinfoil
- that’s it!
How It Works
- Install any Tinfoil SDK using your language’s package manager
- Replace your OpenAI import with the Tinfoil equivalent
- Use the same API you’re already familiar with
- Get automatic security - attestation verification happens transparently
Why Use Tinfoil SDKs?
TL;DR: Tinfoil clients provide the strongest security guarantees through certificate pinning and in-band verification. For maximum security, always use our SDKs unless you know what you’re doing.
You have two options for connecting to Tinfoil’s confidential AI inference:
- Tinfoil Client SDKs (Recommended) - Our SDKs with built-in in-band security verification
- Direct API Access - Standard POST requests to our endpoints without in-band secure verification
While both approaches work, they offer different security guarantees and user experiences.
In-Band vs Out-of-Band Verification
In-Band Verification
What Tinfoil Clients Do
- Verify attestation during connection setup
- Pin TLS certificates to prevent certificate swapping
- Ensure the same verified enclave handles all requests
- Provide real-time security guarantees
Out-of-Band Verification
What Direct API Access Provides
- Verify attestation separately from API calls
- Manual certificate verification required
- Post-hoc auditability security
- Weaker real-time security guarantees
Why Certificate Pinning Matters
When you use a Tinfoil client, here’s what happens behind the scenes:
1. Initial Attestation Verification
The client performs cryptographic verification that:
- The AI inference server is running in a genuine secure enclave
- The enclave is running the expected code that we published on GitHub and Sigstore
- The TLS certificate for every request corresponds to this verified enclave
2. Certificate Pinning Protection
Once verified, the client “pins” the TLS certificate, which means:
- Prevents certificate swapping - Tinfoil cannot issue a new certificate and redirect your traffic
- Maintains connection integrity - All subsequent requests use the same verified connection
- Real-time security - Every request benefits from the initial attestation verification
3. What Could Go Wrong Without Pinning
With direct API access, a malicious actor (even Tinfoil itself) could theoretically:
- Issue a new TLS certificate
- Route your traffic to a different (non-enclave) inference server
- Process your data without confidentiality guarantees
Auditability Through Certificate Transparency - Even without certificate pinning, you can still detect if Tinfoil has issued a new certificate for an endpoint by monitoring Certificate Transparency (CT) logs. All TLS certificates must be logged in public CT logs, making it possible to audit certificate issuance and detect potential certificate rotation that might indicate an attack.
Security Comparison
Aspect | Tinfoil SDKs | Direct API Access |
---|---|---|
Security Level | Maximum - Automatic in-band verification with certificate pinning | Good - Manual out-of-band verification (requires implementation) |
Setup Complexity | Minimal - Automatic verification | Higher - Manual attestation implementation required |
Flexibility | Limited - Must use SDK API patterns | Maximum - Full control over requests, headers, and processing |
Language Support | Limited to supported languages | Universal - Any language with HTTP support |
Development Speed | Fast - Drop-in OpenAI replacement | Variable - Fast if you skip verification, slower with proper security |
Maintenance | Low - SDK updates handle security | Higher - You maintain verification logic |
When to Use Each Approach
✅ Use Tinfoil Clients When:
- You want maximum security (recommended for all production use)
- You want to migrate from an existing OpenAI SDK with minimal code changes
- You need real-time security guarantees
- You want to focus on your application logic rather than security implementation
⚠️ Consider Direct API Access When:
- You have existing HTTP client infrastructure that’s deeply integrated
- You need custom request/response handling that our SDKs don’t support
- You’re building a proxy or gateway that needs low-level control
- You want to implement your own verification logic for specific compliance requirements
Important: If you choose direct API access, you must implement your own attestation verification to get any security benefits. Without verification, you have no security guarantees and have to trust Tinfoil to have set up the enclave correctly.
Next Steps
- Browse available models in our Model Catalog
- Browse examples for your preferred SDK