Endpoints
Chat completions
POST /chat/completions generates a reply from a list of messages, streamed or in one piece.
POST /api/v1/chat/completions
Requires the models:invoke permission. The request and response follow the OpenAI Chat Completions format.
Request body
| Field | Type | Notes |
|---|---|---|
model |
string | Required. A model id from GET /models. |
messages |
array | Required. The conversation: system, user and assistant messages. |
stream |
boolean | Stream the reply as server-sent events. Default false. |
max_tokens |
integer | The most tokens to generate, up to your plan's limit. max_completion_tokens is also accepted. |
temperature |
number | Sampling temperature. |
top_p |
number | Nucleus sampling. |
stop |
string or array | Sequences that end the reply. |
seed |
integer | Best-effort reproducible sampling. |
response_format |
object | Ask for JSON output where the model supports it. |
frequency_penalty, presence_penalty |
number | Repetition controls. |
Not supported: n other than 1, and tools / tool_choice. A request using them gets 400 unsupported_parameter.
Example
curl https://alphaproxy.ai/api/v1/chat/completions \
-H "Authorization: Bearer $ALPHAPROXY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_ID",
"messages": [
{"role": "system", "content": "You answer in one short paragraph."},
{"role": "user", "content": "What is fine-tuning good for?"}
],
"max_tokens": 300
}'
from openai import OpenAI
client = OpenAI(base_url="https://alphaproxy.ai/api/v1", api_key="sk_...")
reply = client.chat.completions.create(
model="MODEL_ID",
messages=[
{"role": "system", "content": "You answer in one short paragraph."},
{"role": "user", "content": "What is fine-tuning good for?"},
],
max_tokens=300,
)
print(reply.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://alphaproxy.ai/api/v1", apiKey: process.env.ALPHAPROXY_API_KEY });
const reply = await client.chat.completions.create({
model: "MODEL_ID",
messages: [
{ role: "system", content: "You answer in one short paragraph." },
{ role: "user", content: "What is fine-tuning good for?" },
],
max_tokens: 300,
});
console.log(reply.choices[0].message.content);
Streaming
Set "stream": true to receive the reply as it's generated, as server-sent events in the OpenAI format, ending with data: [DONE].
stream = client.chat.completions.create(
model="MODEL_ID",
messages=[{"role": "user", "content": "Write a haiku about owning your model."}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
Response headers
Every response carries X-AlphaProxy-Request-ID. Include it when you contact support about a request.