API reference
Understand the request shape, response fields, and common parameters.
/chat/completionsAppend this path to your configured base URL. The reference follows a common chat-completions request shape; supported fields depend on the selected model and endpoint.
Authentication
Send a bearer key in the Authorization header and JSON with Content-Type: application/json. Keep the credential on your server.
Request body
| Field | Type | Description |
|---|---|---|
model | string · optional | An enabled model ID. If omitted, your saved default model is used. |
messages | array · required | An ordered conversation. Each message includes a role and content. |
messages[].role | string | A supported role, commonly system, user, assistant, or tool. |
messages[].content | string | Text content. This release supports text and code; image and audio input are not accepted. |
stream | boolean · optional | Requests streaming where the chosen model and endpoint support it. |
temperature | number · optional | Controls sampling for models that support it. Check model-specific limits. |
tools | array · optional | Tool definitions for compatible models. Your application validates and executes calls. |
const response = await fetch(
`${process.env.PRISMHUB_BASE_URL}/chat/completions`,
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PRISMHUB_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "provider/model-id",
messages: [
{ role: "user", content: "Build something brilliant." },
],
}),
},
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();Reference template. Set a configured base URL ending in /api/v1, a server-side key, and a supported model identifier. This page sends no API requests.
Example response
This is an illustrative response shape. Actual responses include the selected model, PrismHub request identifier, and metered usage.
{
"id": "example-response-id",
"object": "chat.completion",
"model": "provider/model-id",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "What would you like to build?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 9,
"total_tokens": 33
}
}Streaming and tools
Streaming responses commonly use server-sent events. Accumulate content carefully and handle interruptions. Tool definitions describe actions; the model does not execute them. Validate tool arguments and permissions in your own application.