API reference

Chat completions

POST /v1/chat/completions: the request body, the response, and code in several languages.

Endpoint

POST https://openllmbuddy-proxy.openllmbuddy.workers.dev/v1/chat/completions

Sends a conversation to your instance and returns the model's next message. It follows the OpenAI chat completions format, so OpenAI SDKs and tools work as they are.

Show examples for

Request body

A JSON object. Other OpenAI parameters not listed here are passed to the model server as you send them.

FieldTypeRequiredDescription
modelstringYesAny name works: each instance serves one model, and the proxy sends the name your instance serves. Using the model id below keeps your logs readable.
messagesarrayYesChat turns: [{ "role": "system" | "user" | "assistant", "content": "..." }, ...].
streambooleanNotrue streams the reply as server-sent events. Token usage arrives in the last chunk.
max_tokensintegerNoUpper limit on the reply's length, in tokens.
temperaturenumberNoSampling temperature (0–2). Leave it out to use the model's default.
top_pnumberNoNucleus sampling (0–1). Often used with temperature.
stopstring | arrayNoText that ends the reply when the model writes it.
Example body
json
{
  "model": "qwen3.8-27b-fable",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "temperature": 1,
  "top_p": 0.95,
  "max_tokens": 512
}

About the model field

Each instance serves one model, so you can send any name: we replace it with the name your instance serves. Using the model id (here qwen3.8-27b-fable) keeps your logs readable. See Models.

Response

A standard OpenAI chat completion. Read the reply from choices[0].message.content.

FieldMeaning
idAn id for this completion.
objectAlways "chat.completion".
createdWhen it was made, in Unix seconds.
modelThe model your instance serves.
choices[].message.contentThe reply text.
choices[].finish_reason"stop" when the model finished, "length" when it hit max_tokens.
usageprompt_tokens, completion_tokens and total_tokens for this request.
Example response
json
{
  "id": "chatcmpl-example",
  "object": "chat.completion",
  "created": 1779715432,
  "model": "qwen3.8-27b-fable",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The assistant reply is in choices[0].message.content."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 48,
    "total_tokens": 60
  }
}

Code examples

cURL
bash
curl -s https://openllmbuddy-proxy.openllmbuddy.workers.dev/v1/chat/completions \
  -H 'Authorization: Bearer ob_sk_000000000000000000000000000000000000000000000001' \
  -H 'Content-Type: application/json' \
  -d '{"model":"qwen3.8-27b-fable","messages":[{"role":"user","content":"Hello!"}]}'

Tip

Long replies take time. Set your client's timeout to a few minutes, or use streaming to see the reply as it is written.