Ψ
PHANTOM
OpenAI-Compatible API Reference

Developer Documentation & SDKs

Phantom is a 1-line drop-in replacement for OpenAI endpoints. Point your OpenAI SDK or agent runtime to https://phantom.codes/v1 to route traffic through hardware-attested Intel TDX enclaves with zero prompt logs.

1

1-Line Drop-In SDKs

Choose your framework below. All standard OpenAI clients, Vercel AI SDK, LangChain, and IDEs work out of the box.

from openai import OpenAI

# 1. Point standard OpenAI SDK to Phantom's confidential TEE gateway
client = OpenAI(
    base_url="https://phantom.codes/v1",
    api_key="sk-phantom-your-api-key"
)

# 2. Stream tokens with 0% deposit markup and hardware isolation
response = client.chat.completions.create(
    model="deepseek/deepseek-v3.2",
    messages=[
        {"role": "user", "content": "Explain Intel TDX hardware enclaves."}
    ],
    stream=True
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")
2

Authentication

All endpoints under /v1/* require a Bearer token in the standard HTTP Authorization header.

Authorization: Bearer sk-phantom-1234567890abcdef...
3

Endpoints Reference

POST/v1/chat/completions
Streaming & Non-Streaming

Initiate OpenAI-compatible LLM token completions. Automatically detects and applies prompt cache hit discounts.

curl https://phantom.codes/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-phantom-your-key-here" \
  -d '{
    "model": "deepseek/deepseek-v3.2",
    "messages": [{"role": "user", "content": "What are TEE registers?"}],
    "stream": false
  }'
GET/v1/key/balance
Key Quota & Expiry

Fetch your real-time balance in USD and micro-USD, total spent, and expiry timestamp.

curl https://phantom.codes/v1/key/balance \
  -H "Authorization: Bearer sk-phantom-your-key-here"
POST/v1/key/rotate
Zero-Downtime Key Rotation

Atomically deactivates your current API key and issues a replacement key inheriting 100% of your remaining balance and expiry.

curl -X POST https://phantom.codes/v1/key/rotate \
  -H "Authorization: Bearer sk-phantom-your-key-here"
GET/api/v1/attest
Cryptographic Proof

Retrieve real-time Intel TDX Quote v4 registers (RTMR0-3), Hugging Face weight commit hashes, and Merkle root checksums.

curl -s "https://phantom.codes/api/v1/attest?model=deepseek/deepseek-v3.2" | jq .
POST/api/v1/account/grant
$1.00 - $1.50 Verified Grant

Claim $1.00 (1,000,000 micro-USD) of verified compute credits by authenticating with GitHub or Google on /account. If referred by another developer, you receive $1.50 and the referrer receives $1.00 credited automatically.

Claim grant via authenticated session:
curl -X POST "https://phantom.codes/api/v1/account/grant" \
  -H "Content-Type: application/json" \
  -H "Cookie: better-auth.session_token=YOUR_SESSION_COOKIE" \
  -d '{
    "referrer_id": "optional_referrer_user_id"
  }'
4

Cryptographic Response Headers

Every HTTP response carries the enclave receipt identifiers issued by the upstream TEE gateway, forwarded verbatim:

// Response Headers
x-phantom-route: tee-enclave
x-phantom-receipt-id: rcpt-0f173848650be1659407a68d
x-phantom-keyset-digest: sha256:3e8c94d2204afbc999e63ccb8ee18f14...
x-phantom-receipt-verified: upstream-enclave-receipt
x-phantom-zero-logs: true
5

IDE & Coding Agent Setup

Route your coding agent queries through hardware-attested enclaves with zero prompt snooping:

Cursor Setup

Navigate to Cursor Settings → Models → OpenAI API Key:

Override Base URL: https://phantom.codes/v1
API Key: sk-phantom-...
Model Name: deepseek/deepseek-v3.2

Claude Code / Cline / Aider Setup

Set environment variables in your terminal:

export OPENAI_BASE_URL="https://phantom.codes/v1"
export OPENAI_API_KEY="sk-phantom-..."