Create a chat completion
Generate a model response for a conversation. POST a list of messages; the model returns the next assistant message. Supports streaming, tool calling, and structured outputs.
Authorization
bearerAuth Send your Merius API key as a bearer token: Authorization: Bearer riv_.... Create keys
in the dashboard; the full key is shown once. Keep it server-side.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/chat/completions" \ -H "Content-Type: application/json" \ -d '{ "model": "z-ai/glm-5.1", "messages": [ { "role": "system", "content": "You are concise." }, { "role": "user", "content": "Name three primary colors." } ], "temperature": 0.7 }'{ "id": "chatcmpl-9f3a", "object": "chat.completion", "created": 1768000000, "model": "z-ai/glm-5.1", "choices": [ { "index": 0, "message": { "role": "system", "content": "string" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0 }}{ "error": { "message": "Unknown model: gpt-foo", "type": "invalid_request_error", "param": "model", "code": "model_not_found" }}{ "error": { "message": "Unknown model: gpt-foo", "type": "invalid_request_error", "param": "model", "code": "model_not_found" }}{ "error": { "message": "Unknown model: gpt-foo", "type": "invalid_request_error", "param": "model", "code": "model_not_found" }}{ "error": { "message": "Unknown model: gpt-foo", "type": "invalid_request_error", "param": "model", "code": "model_not_found" }}{ "error": { "message": "Unknown model: gpt-foo", "type": "invalid_request_error", "param": "model", "code": "model_not_found" }}{ "error": { "message": "Unknown model: gpt-foo", "type": "invalid_request_error", "param": "model", "code": "model_not_found" }}Streaming
Stream Merius chat completions token by token as server-sent events, in the OpenAI format. curl, Python, and TypeScript examples.
Create a completion (legacy) POST
Generate a text completion from a prompt. Provided for compatibility; prefer `/chat/completions` for new work — it gives better control over context and system instructions.