Chat Completions
Endpoint (v2 & v3)
POST /v3/chat/completions # Rust (utama)POST /v2/chat/completions # Go (cadangan)POST /v1/chat/completions # alias v3Settings lengkap untuk
opencode.json, baseURL v2/v3, dan fallback: lihat Settings API.
Request
{ "model": "bt/qwen3.8-flash", "messages": [ {"role": "system", "content": "Kamu asisten yang membantu."}, {"role": "user", "content": "Halo!"} ], "temperature": 0.7, "max_tokens": 2048}Response
{ "id": "chatcmpl-xxx", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Halo! Ada yang bisa saya bantu?" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 15, "completion_tokens": 10, "total_tokens": 25 }}Parameter
| Parameter | Type | Default | Description |
|---|---|---|---|
model | string | required | Model ID (prefix bt/) |
messages | array | required | Array pesan |
temperature | number | 0.7 | Sampling temperature |
max_tokens | integer | 2048 | Maks token output |
stream | boolean | false | Enable streaming |