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.
Quickstart Integration
Use the official OpenAI SDK in Python or TypeScript. Simply modify the base_url parameter.
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="")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 || '');
}Authentication
All endpoints under /v1/* require a Bearer token in the standard HTTP Authorization header.
Authorization: Bearer sk-phantom-1234567890abcdef...Endpoints Reference
/v1/chat/completionsInitiate 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
}'/v1/key/balanceFetch 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"
/v1/key/rotateAtomically 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"
/api/v1/attestRetrieve 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 .
Cryptographic Response Headers
Every HTTP response from Phantom includes cryptographic proof headers certifying enclave isolation and model weight integrity: