Ψ
PHANTOM
OpenAI-Compatible API Reference

Developer Documentation & SDKs

Phantom is a drop-in replacement for OpenAI endpoints. Set your base URL to https://phantom.codes/v1 to route traffic through hardware-attested Intel TDX enclaves and confidential proxies.

1

Quickstart Integration

Use the official OpenAI SDK in Python or TypeScript. Simply modify the base_url parameter.

Python (openai >= 1.0.0)● Verified
from openai import OpenAI

client = OpenAI(
    base_url="https://phantom.codes/v1",
    api_key="sk-phantom-your-api-key"
)

response = client.chat.completions.create(
    model="phala/deepseek-v3.2",
    messages=[
        {"role": "user", "content": "Explain confidential compute."}
    ],
    stream=True
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")
TypeScript / Node.js● Verified
import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: 'https://phantom.codes/v1',
  apiKey: 'sk-phantom-your-api-key',
});

const stream = await openai.chat.completions.create({
  model: 'anthropic/claude-3-7-sonnet',
  messages: [{ role: 'user', content: 'Hello Phantom!' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
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": "phala/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=phala/deepseek-v3.2" | jq .
4

Cryptographic Response Headers

Every HTTP response from Phantom includes cryptographic proof headers certifying enclave isolation and model weight integrity:

// Response Headers
x-phantom-tee-enclave: intel-tdx-nvidia-cc-v4
x-phantom-model-attestation: hardware-quote-verified
x-phantom-weight-root: 0x7f2a189db8fcfe7d03923ef1f1295f7c001859c5d0234a5d3f2780e03be16a41
x-phantom-signature: 0x8a10f... (deterministic HMAC signature)
x-phantom-zero-logs: true