View on GitHub
tinfoilsh/tinfoil-rs
Overview
The Tinfoil Rust SDK is a thin wrapper around theasync-openai crate that provides secure communication with Tinfoil enclaves. It uses the same types and request/response shapes as async-openai and adds automatic verification that the endpoint is running in a secure Tinfoil enclave, TLS certificate pinning, and attestation validation.
Installation
New to Rust? Start here - Project Setup
New to Rust? Start here - Project Setup
If you don’t have a Cargo project yet, create one:The minimum supported Rust version is 1.87.
Cargo.toml:
Migration from async-openai
Migrating from async-openai to Tinfoil is a small change — the SDK exposes the same chat / audio / embeddings handlers under tinfoil::Client:
tinfoil::Client derefs to async_openai::Client, so all OpenAI methods (client.chat(), client.embeddings(), client.audio(), …) work unchanged.
Usage
tinfoil::chat, tinfoil::audio, and tinfoil::embeddings — all re-exports of the corresponding async_openai::types::* modules.
Model Examples
Below are specific examples for current Tinfoil model categories.Chat Models
GLM-5.2
GLM-5.2
Qwen3-VL 30B
Qwen3-VL 30B
Gemma 4 31B
Gemma 4 31B
Llama 3.3 70B
Llama 3.3 70B
GPT-OSS 120B
GPT-OSS 120B
Audio Models
Embedding Models
Nomic Embed Text
Nomic Embed Text
The
embed_batch shortcut takes a list of strings, preserves input order, and returns Vec<Vec<f32>>.Vendor Extensions
Tinfoil exposes a few request/response fields the upstream OpenAI schema does not (for exampleweb_search_options, pii_check_options, structured-output regex / choice constraints, and custom finish_reason values). To use them without async-openai rejecting the response, send the request through client.chat_relaxed():
web_search_call) verbatim:
Advanced Functionality
For advanced use cases requiring manual verification or direct HTTP access, useSecureClient:
API Documentation
This library is a thin wrapper around theasync-openai crate that can be used with Tinfoil. All methods and types are identical. See the async-openai documentation for complete API usage.
