A Node.js wrapper around the OpenAI client that verifies enclave attestation and certificate fingerprints when using Tinfoil inference.
npm install tinfoil
import { TinfoilAI } from 'tinfoil';
const client = new TinfoilAI({
enclave: 'enclave.example.com', // or use TINFOIL_ENCLAVE env var
repo: 'org/model-repo', // or use TINFOIL_REPO env var
apiKey: 'your-api-key' // or use OPENAI_API_KEY env var
});
// Uses identical method calls as the OpenAI client
const completion = await client.chat.completions.create({
messages: [{ role: 'user', content: 'Hello!' }],
model: 'llama3-3-70b'
});
To run the streaming chat example:
-
Clone the repository
-
Install dependencies:
npm install
- Optionally create a
.env
file with your configuration:
TINFOIL_ENCLAVE=enclave.example.com
TINFOIL_REPO=org/model-repo
OPENAI_API_KEY=your-api-key
- Run the example:
cd examples/chat
npx ts-node main.ts
The example demonstrates streaming chat completions with the Tinfoil API wrapper.
Supports Node.js 18+, Deno, Bun, Cloudflare Workers, and more. Browser usage is disabled by default for security. See OpenAI Node.js client for complete runtime compatibility.
This library is a drop-in replacement for the official OpenAI Node.js client that can be used with Tinfoil. All methods and types are identical. See the OpenAI client for complete API usage and documentation.
Please report security vulnerabilities by either:
-
Emailing security@tinfoil.sh
-
Opening an issue on GitHub on this repository
We aim to respond to security reports within 24 hours and will keep you updated on our progress.