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/completions

Request Body

ParameterTypeRequiredDescription
modelstringYesThe ID of the model to use. e.g., openai/gpt-4o
messagesarrayYesA list of messages comprising the conversation so far.
streambooleanNoIf set, partial message deltas will be sent (SSE).
temperaturenumberNoSampling temperature between 0 and 2. Default is 1.
max_tokensintegerNoThe maximum number of tokens to generate in the completion.

Try it out

JavaScript
Python
cURL
JavaScript
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

JSON Response
{
  "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
  }
}