API & REQUESTS

API reference

Understand the request shape, response fields, and common parameters.

POST/chat/completions

Append 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

FieldTypeDescription
modelstring · optionalAn enabled model ID. If omitted, your saved default model is used.
messagesarray · requiredAn ordered conversation. Each message includes a role and content.
messages[].rolestringA supported role, commonly system, user, assistant, or tool.
messages[].contentstringText content. This release supports text and code; image and audio input are not accepted.
streamboolean · optionalRequests streaming where the chosen model and endpoint support it.
temperaturenumber · optionalControls sampling for models that support it. Check model-specific limits.
toolsarray · optionalTool definitions for compatible models. Your application validates and executes calls.
TypeScript · chat completions
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.

Illustrative JSON response
{
  "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.