Chat API
The Chat Completions API allows you to generate text and conversational responses using a wide variety of LLMs.
https://api.qorebit.ai/v1/chat/completionsRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The ID of the model to use. e.g., openai/gpt-4o |
messages | array | Yes | A list of messages comprising the conversation so far. |
stream | boolean | No | If set, partial message deltas will be sent (SSE). |
temperature | number | No | Sampling temperature between 0 and 2. Default is 1. |
max_tokens | integer | No | The maximum number of tokens to generate in the completion. |
Try it out
JavaScript
Python
cURL
const response = await fetch("https://api.qorebit.ai/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer qb_live_...",
"Content-Type": "application/json"
},
body: JSON.stringify({
"model": "openai/gpt-4o",
"messages": [{ "role": "user", "content": "What is the meaning of life?" }]
})
});Response Example
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "openai/gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}