Skip to main content

View on GitHub

tinfoilsh/tinfoil-go

Overview

The Tinfoil Go SDK is a wrapper around the OpenAI Go client that provides secure communication with Tinfoil enclaves. It has the same API as the OpenAI SDK with additional security features including automatic verification that the endpoint is running in a secure Tinfoil enclave and encryption of request bodies to the verified enclave with EHBP.
V3 attestation verification in the Go SDK, including the installation below, is beta while deployment is ongoing.

Installation

The minimum supported Go version is 1.27.2.

Migration from OpenAI

Migrating from OpenAI to Tinfoil is straightforward. The client is designed to be compatible with the OpenAI Go client:
All method signatures remain the same since tinfoil.NewClient() returns a standard OpenAI client with built-in security features.

Usage

Model Examples

Below are specific examples for each supported model. Click on any model to see its configuration and usage example.

Chat Models

Audio Models

Transcription

Audio Q&A

Embedding Models

Advanced Functionality

For advanced use cases requiring manual verification or direct HTTP access, pin an enclave with NewClientWithOptions and use the client’s verification and HTTP methods:
HTTPClient() only sends requests to the verified enclave and encrypts request bodies to it. To pin the enclave’s TLS certificate instead, add tinfoil.WithTransport(tinfoil.TransportTLS).

API Documentation

This library is a drop-in replacement for the official OpenAI Go client that can be used with Tinfoil. All methods and types are identical. See the OpenAI Go client documentation for complete API usage and documentation.