---
title: "Chat completion (OpenAI-compatible)"
method: POST
path: "/chat/completions"
tags: ["LLM"]
---

# Chat completion (OpenAI-compatible)

`POST /chat/completions`

## Request

- Base URL: `https://getrun.id/v1`
- URL: `https://getrun.id/v1/chat/completions`
- Auth: HTTP bearer

Jalur LLM synchronous, kompatibel dengan SDK OpenAI — arahkan
`base_url` SDK ke `https://getrun.id/v1`.

Billing per token: saldo direservasi dari `max_tokens`, di-capture
berdasarkan token aktual. Dengan `stream: true`, response berupa
Server-Sent Events dan `usage` dikirim pada chunk terakhir.

Endpoint ini tidak memakai lifecycle task dan tidak memakai webhook.
Error mengikuti format OpenAI (`{"error": {"message", "type", "code"}}`).

## Request body

- object
  - `model` string, required
  - `messages` object[], required
    - `role` 'system' | 'user' | 'assistant' | 'tool', required
    - `content` unknown, required
  - `stream` boolean
  - `max_tokens` integer
  - `temperature` number

## Response `200`

Chat completion (JSON), atau stream SSE bila `stream: true`.

- object: Objek `chat.completion` sesuai format OpenAI.

## Other responses

- `default`: Error berformat OpenAI-compatible.

---

[API](https://skmtc.dev/getrun/apis/getrun-api.md) · [All operations](https://skmtc.dev/getrun/apis/getrun-api/llms.txt) · [OpenAPI document](https://skmtc.dev/getrun/apis/getrun-api/revisions/2e80f8b28c48?raw)
