Skip to Content

Chat completions

POST
/v1/chat/completions

Send a conversation and get the model’s next reply. Copy a text model ID from GET /v1/models into the model field.

To see which features we tested, check the model capability table. For examples of streaming, function calls, and JSON replies, see chat recipes.

Authorization

meikaiToken
headerAuthorizationBearer <token>

Enter your personal Meikai API token.

Request Body

application/json
  1. body
model?string

Copy a text model ID from GET /v1/models. If you leave this out, Meikai uses zai-org/GLM-5.2, which may be unavailable.

messages*array<>

Send the messages in order, oldest first. After running a tool, include the original tool call and its result in your next request.

Items1 <= items
max_tokens?integer

The most tokens the model can use to produce the reply. A token is a small piece of text. Some models use part of this limit to work out the answer.

Range1 <= value
max_completion_tokens?integer

Another way to set the output limit, including any reasoning tokens. Use this or max_tokens, whichever your model supports.

Range1 <= value
reasoning_effort?string

Adjust how much work the model does before answering. Accepted values vary. GPT OSS 20B accepted low in our tests.

temperature?number

Lower values make replies more predictable. Higher values allow more variety. Support varies by model.

Range0 <= value <= 2
top_p?number

Limit the choice of the next token to the most likely ones. For example, 0.9 keeps the smallest set whose probabilities add up to at least 90%. Omit this field on models that do not support it.

Range0 <= value <= 1
stop?|array<string>

Tell the model to stop when it reaches one of these strings. Support varies by model.

stream?boolean

Send the reply in pieces as the model writes it. Each piece arrives as a server-sent event.

Defaultfalse
stream_options?

To use these options, set stream to true.

tools?array<>

Describe the functions your app can run. The model can ask for a function by name. Your app checks the arguments, runs the function, and sends back the result.

tool_choice?|

Let the model choose a tool (auto), prevent tool calls (none), require a tool call (required), or name a specific function. Support varies by model.

response_format?

Describe the JSON you want back, including the fields it must contain. Use a model that supports this option and check its reply in your app.

Response Body

The full reply, or a stream that delivers the reply in pieces.

  1. response
id?string
object?string
created?integer

Time the model created the reply, in seconds since January 1, 1970 (UTC). Some models omit this field.

model?string
choices?array<>
usage?|

Token counts for the messages you sent and the reply the model generated. Some models also report cached or reasoning tokens.

Example Request
curl -X POST 'https://example.com/v1/chat/completions' \  -H 'Authorization: Bearer YOUR_MEIKAI_TOKEN' \  -H 'Content-Type: application/json' \  -d '{  "model": "meta-llama/Llama-3.3-70B-Instruct",  "messages": [    {      "role": "user",      "content": "Explain DNS in two sentences."    }  ],  "max_tokens": 2048}'
Example Response
{  "id": "chatcmpl-example",  "object": "chat.completion",  "model": "meta-llama/Llama-3.3-70B-Instruct",  "choices": [    {      "index": 0,      "message": {        "role": "assistant",        "content": "DNS translates domain names into IP addresses."      },      "finish_reason": "stop"    }  ],  "usage": {    "prompt_tokens": 18,    "completion_tokens": 12,    "total_tokens": 30  }}