Skip to main content

Chat Completions

The chat completions endpoint generates a model response for a conversation. It is OpenAI-compatible, so the request and response shapes match the OpenAI Chat Completions API.

POST https://api.shisa.ai/openai/v1/chat/completions
MethodPOST
AuthAuthorization: Bearer YOUR_API_KEY
Content-Typeapplication/json

Request body

FieldTypeRequiredDescription
modelstringrequiredA Shisa model ID, e.g. shisa-ai/shisa-v2.1-llama3.3-70b. See Models.
messagesarrayrequiredThe conversation so far, as an ordered list of message objects.
streambooleanoptionalWhen true, partial tokens are streamed as Server-Sent Events. Default false.
temperaturenumberoptionalSampling temperature. Higher is more random; lower is more deterministic.

Because the endpoint is OpenAI-compatible, the standard sampling parameters (such as top_p, max_tokens, stop, presence_penalty, and frequency_penalty) are also accepted and behave as in the OpenAI API.

Message object

Each entry in messages has a role and content:

FieldTypeDescription
rolestringOne of system, user, or assistant.
contentstringThe message text.
{
"model": "shisa-ai/shisa-v2.1-llama3.3-70b",
"messages": [
{ "role": "system", "content": "You are a helpful assistant fluent in Japanese and English." },
{ "role": "user", "content": "日本の四季について教えてください。" }
],
"temperature": 0.7,
"stream": false
}

Response

With "stream": false, the endpoint returns a single chat completion object. The generated reply is at choices[0].message.content.

{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1700000000,
"model": "shisa-ai/shisa-v2.1-llama3.3-70b",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "日本には四つの季節があります……" },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 32,
"completion_tokens": 128,
"total_tokens": 160
}
}
note

The example values above are illustrative — IDs, timestamps, and token counts vary per request.

Streaming response

With "stream": true, the endpoint returns Server-Sent Events. Each event is a chunk whose new text is at choices[0].delta.content; the stream ends with a data: [DONE] sentinel.

data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"日本"}}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"には"}}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]

The official OpenAI SDKs handle this framing for you — see the quickstart for streaming examples in Python and Node.

Errors

Authentication and request errors are returned with a standard HTTP status code and a JSON body. See Errors for the shared error format and status codes, and Authentication for header requirements.

Next steps

  • Models — pick the right tier for your workload.
  • Pricing — how tokens are billed.
  • SDKs — using the OpenAI SDKs with Shisa.