tinfoil
TypeScript icon, indicating that this package has built-in type declarations

0.4.4 • Public • Published

Tinfoil Node Client

Build Status NPM version

A Node.js wrapper around the OpenAI client that verifies enclave attestation and certificate fingerprints when using Tinfoil inference.

Installation

npm install tinfoil

Quick Start

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'
});

Running the Chat Example

To run the streaming chat example:

  1. Clone the repository

  2. Install dependencies:

npm install
  1. Optionally create a .env file with your configuration:
TINFOIL_ENCLAVE=enclave.example.com
TINFOIL_REPO=org/model-repo
OPENAI_API_KEY=your-api-key
  1. Run the example:
cd examples/chat
npx ts-node main.ts

The example demonstrates streaming chat completions with the Tinfoil API wrapper.

Runtime Support

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.

API Documentation

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.

Reporting Vulnerabilities

Please report security vulnerabilities by either:

We aim to respond to security reports within 24 hours and will keep you updated on our progress.

Package Sidebar

Install

npm i tinfoil

Weekly Downloads

88

Version

0.4.4

License

AGPL-3.0-or-later

Unpacked Size

79.1 kB

Total Files

12

Last publish

Collaborators

  • tanyav