Libraries
Explore language-specific client-side libraries for using the Tinfoil inference API.
New to Tinfoil? Get started in two steps:
-
Install the SDK for your language:
-
Create a client with your API key:
PythonNode.js
That’s it! The SDK handles attestation verification and follows the OpenAI
interface—just change OpenAI
→ TinfoilAI
in your imports and you’re done.
Security Warning: Never share your API key, be careful to not include it in version control systems, and never bundle it in with front-end client code.
Client Libraries
Tinfoil provides client-side SDKs in multiple languages to help you integrate with our API:
Language | Installation | GitHub |
---|---|---|
Python | pip install tinfoil | tinfoil-python |
Node.js | npm install tinfoil | tinfoil-node |
Swift | Add to dependencies: .package(url: "https://github.com/tinfoilsh/tinfoil-swift", from: "1.0.0") | tinfoil-swift |
Go | go get github.com/tinfoilsh/tinfoil-go | tinfoil-go |
Each library provides a drop-in replacement for the OpenAI client libraries:
- Python:
TinfoilAI
supports the same interface as theOpenAI
Python client - Node.js:
TinfoilAI
supports the same interface as theOpenAI
Node client - Swift:
TinfoilKit
supports the same interface as theOpenAIKit
Swift client - Go:
tinfoil
supports the same interface as theopenai
Go client
Code Examples
Each SDK follows the same interface as its OpenAI counterpart, making it easy to switch from OpenAI to Tinfoil. Just update your imports and API key—the rest of your code stays the same.
The examples below use deepseek-r1-70b
, but the same code
works with any model currently offered on Tinfoil. See Models & Code Examples for
the full list of available models and their capabilities.
Python
The Python SDK is compatible with the OpenAI Python library:
Node.js
The Node.js SDK matches the OpenAI Node library interface:
Swift
Compatible with OpenAIKit:
Go
The Go SDK follows the OpenAI Go library patterns:
CLI
The Tinfoil CLI provides a simple interface for quick tests:
For model-specific examples (chat, embeddings, audio) and advanced configuration options, see the Models & Code Examples page.
Setting credentials via environment variables
All SDKs automatically pick up the following variables (handy for CI):
Variable | Description |
---|---|
TINFOIL_API_KEY | Your secret API key |
TINFOIL_BASE_URL | Override the default base URL at runtime (optional) |
Example: