Documentation
Prism is fully compatible with the OpenAI SDK. Any tool or library that speaks the OpenAI API format — Python, JavaScript, LangChain, whatever you already have — works against Prism out of the box. The only change required is the base URL and API key.
Quickstart
Point the official OpenAI SDK at Prism instead of OpenAI, and use any Prism model id in place of a model name — including Gemini models, through the same client.
Python
from openai import OpenAI
client = OpenAI(
base_url="https://your-prism-domain.com/api/v1",
api_key="sk-dprism-...",
)
completion = client.chat.completions.create(
model="openai/gpt-5.4-mini",
messages=[{"role": "user", "content": "Hello!"}],
)
print(completion.choices[0].message.content)JavaScript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://your-prism-domain.com/api/v1",
apiKey: "sk-dprism-...",
});
const completion = await client.chat.completions.create({
model: "openai/gpt-5.4-mini",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(completion.choices[0].message.content);Swap providers by changing only the model string — openai/gpt-5.4-mini and gemini/gemini-flash-lite-latest both work through the exact same client, same method calls, same response shape.
Authentication
Create an API key from your dashboard and use it as your SDK's api_key— or send it directly as a bearer token if you're calling the HTTP API yourself. Keys are shown once at creation — store them somewhere safe.
Authorization: Bearer sk-dprism-...Available models
| Model ID | Provider | Type | Tokens/1M input | Tokens/1M output |
|---|---|---|---|---|
openai/gpt-5.4-nano | openai | chat | 26.67 | 166.67 |
openai/gpt-5.4-mini | openai | chat | 100.00 | 600.00 |
gemini/gemini-flash-lite-latest | gemini | chat | 33.33 | 200.00 |
gemini/gemini-flash-latest | gemini | chat | 200.00 | 1200.00 |
gemini/gemini-3.1-flash-lite-image | gemini | image | 33.33 | 4000.00 |
openai/gpt-image-1-mini | openai | image | 266.67 | 1066.67 |
Streaming
Pass stream: true (or stream=Truein Python) to any chat model and the SDK's normal streaming iterator works unchanged — no different code path than talking to OpenAI directly.
stream = client.chat.completions.create(
model="gemini/gemini-flash-lite-latest",
messages=[{"role": "user", "content": "Write a haiku about the ocean."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="")The final chunk carries usage and a billingfield, same as the non-streaming response — that's when the call is actually billed, since token usage for a streamed response is only known once it finishes.
Image generation
POST /api/v1/images/generations, or client.images.generate() in the SDK. Image models are billed in tokens exactly like chat models — see the model table above.
image = client.images.generate(
model="gemini/gemini-3.1-flash-lite-image",
prompt="A watercolor painting of a mountain lake at sunrise",
)
# image.data[0].b64_json is the base64-encoded imageBilling
Your account holds a single token balance. Every call — chat or image — is billed based on the actual input/output token counts the provider returns, deducted from your balance. Different models consume tokens at different rates — see the model table above for tokens per 1M input/output tokens on each model.
A call is rejected with 402 if your balance is at or below zero before the call starts. Because the exact usage of a call is only known after it completes, a single large completion can take your balance slightly negative — check your logs for exact token usage per call. Balances are credited manually — contact the Prism team to top up.
Raw HTTP
If you'd rather not use an SDK, the endpoints are plain JSON over HTTPS.
cURL
curl https://your-prism-domain.com/api/v1/chat/completions \
-H "Authorization: Bearer sk-dprism-..." \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-flash-lite-latest",
"messages": [{ "role": "user", "content": "Hello!" }]
}'Response
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1730000000,
"model": "openai/gpt-5.4-mini",
"choices": [
{ "index": 0, "message": { "role": "assistant", "content": "..." }, "finish_reason": "stop" }
],
"usage": { "prompt_tokens": 12, "completion_tokens": 34, "total_tokens": 46 },
"billing": { "cost_usd": 0.000163, "tokens_deducted": 0.021733 }
}Errors
| Status | Meaning |
|---|---|
| 401 | Missing, invalid, or revoked API key. |
| 400 | Malformed request, unknown model, or wrong endpoint for that model's type. |
| 402 | Token balance exhausted. |
| 502 | The upstream provider (OpenAI/Gemini) returned an error. |