Chat Completions
POST https://gateway.primex.work/v1/chat/completions
The OpenAI-compatible chat endpoint. Works with the OpenAI SDKs and any tool that
targets /v1/chat/completions.
Request
curl https://gateway.primex.work/v1/chat/completions \
-H "Authorization: Bearer prx-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{"role": "system", "content": "You are concise."},
{"role": "user", "content": "What is Primex?"}
],
"temperature": 0.7
}'
Streaming
Set "stream": true to receive server-sent events (data: chunks ending with
data: [DONE]):
stream = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "Write a haiku."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
Streamed responses are billed the same way as non-streamed ones, and Primex's broken-stream guard ensures a stream that dies carrying only a provider error does not charge you — see Billing.
Tool / function calling
Standard OpenAI tools / tool_choice are supported and forwarded to the model.
{
"model": "gpt-5.5",
"messages": [{"role": "user", "content": "Weather in Paris?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}]
}
Response
{
"id": "chatcmpl-…",
"object": "chat.completion",
"model": "gpt-5.5",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "Primex is an AI gateway…"},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 21, "completion_tokens": 14, "total_tokens": 35}
}
Billing is metered from the usage token counts. See Models for
per-model rates.