Skip to content
tacita.chat
Docs · @tacita/sdk

Developers

@tacita/sdk

A thin TypeScript SDK — a preconfigured OpenAI client, model and preset helpers, and the end-to-end encrypted TEE flow (available once TEE opens for the API).

On this page

You don't need an SDK: the standard OpenAI SDK works as-is (see Developer API). @tacita/sdk adds three small things on top:

  • a client preconfigured for Tacita;
  • model and preset helpers;
  • the full end-to-end encrypted TEE flow, ready for when TEE opens for the API.
npm install @tacita/sdk openai

Client#

createTacitaClient returns a standard OpenAI client with baseURL set to https://api.tacita.chat/v1. Everything in the OpenAI SDK works.

import { createTacitaClient } from "@tacita/sdk";

const tacita = createTacitaClient({ apiKey: process.env.TACITA_API_KEY! });
const r = await tacita.chat.completions.create({
  model: "deepseek-v4.1-flash",
  messages: [{ role: "user", content: "Hi!" }],
});

Models and presets#

import { listModels, presetModel } from "@tacita/sdk";

const { data } = await listModels({ apiKey: process.env.TACITA_API_KEY, type: "text" });
for (const m of data) {
  console.log(m.id, m.pricingKind, m.listPrice.inputPer1MUsd, m.marketPrice?.inputPer1MUsd);
}

const smart = await presetModel("Smart"); // e.g. "claude-sonnet-5.5"

TEE: end-to-end encrypted (not available via API yet)#

TEE through API keys is not available yet. Until it is, createTeeSession throws TeeNotAvailableError. The code is complete and tested, so your app can ship it now and it starts working the day TEE opens:

import { createTeeSession, TeeNotAvailableError } from "@tacita/sdk";

try {
  const session = await createTeeSession({ apiKey: process.env.TACITA_API_KEY!, model: "e2ee-glm-5-3-p" });
  let id = "";
  for await (const part of session.chatStream([{ role: "user", content: "Something private" }])) {
    if (part.content) process.stdout.write(part.content); // decrypted on your machine
    if (part.id) id = part.id;
  }
  console.log("\nsigned by the attested enclave:", await session.verifyResponse(id));
} catch (e) {
  if (e instanceof TeeNotAvailableError) console.log("TEE via API isn't available yet.");
  else throw e;
}

What createTeeSession does:

  1. Attestation. It requests a fresh attestation with a random 32-byte nonce and checks it: the hardware verification passed, your nonce is echoed back, and the enclave's signing key and your nonce are bound into the hardware report (TDX REPORTDATA).
  2. Session key. It generates a one-time key pair that lives only in memory.
  3. Encryption. It encrypts every message to the enclave's key (ECDH secp256k1 → HKDF-SHA256 → AES-256-GCM). Nobody but the enclave can read them, not even Tacita.
  4. Decryption. It decrypts the streamed answer locally.
  5. Signature. verifyResponse(id) checks the enclave's signature over the response.

The low-level helpers are exported too: encryptForModel, decryptFromModel, checkAttestation and verifyResponseSignature.

Errors#

The SDK uses the OpenAI error classes. Codes are listed in Errors & rate limits.