Skip to main content

SDK snippets

Replace YOUR_ZEALLM_KEY with a revealed virtual key and gpt-4o-mini with a model your key can access. Default base URL: http://localhost:8080/v1.

Python (OpenAI SDK)​

from openai import OpenAI

client = OpenAI(
api_key="YOUR_ZEALLM_KEY",
base_url="http://localhost:8080/v1",
)

resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello from ZeaLLM"}],
)
print(resp.choices[0].message.content)

Node.js (OpenAI SDK)​

import OpenAI from "openai";

const client = new OpenAI({
apiKey: process.env.ZEALLM_API_KEY,
baseURL: "http://localhost:8080/v1",
});

const resp = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello from ZeaLLM" }],
});

console.log(resp.choices[0]?.message?.content);

cURL​

curl http://localhost:8080/v1/chat/completions \
-H "Authorization: Bearer YOUR_ZEALLM_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role":"user","content":"Hello from ZeaLLM"}]
}'

Customer and tag attribution​

curl http://localhost:8080/v1/chat/completions \
-H "Authorization: Bearer YOUR_ZEALLM_KEY" \
-H "x-zeallm-customer-id: end-user-123" \
-H "x-zeallm-tags: cost-center-42,experiment-a" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hi"}]}'

Embeddings​

client.embeddings.create(model="text-embedding-3-small", input="hello")

Speech-to-text​

with open("audio.wav", "rb") as f:
t = client.audio.transcriptions.create(model="YOUR_TRANSCRIBE_GROUP", file=f)
print(t.text)

Text-to-speech​

speech = client.audio.speech.create(
model="YOUR_TTS_GROUP", voice="alloy", input="Hello",
)
speech.stream_to_file("out.mp3")

Realtime​

WebSocket — not covered by the OpenAI REST client alone. See Realtime and GET /openapi.json for HTTP operations.

Supported HTTP operations: chat (stream/non-stream), embeddings, responses, STT, TTS, model listing. See first request and audio.