BroadRouter

Chat Completions API

Updated

The Chat Completions API is OpenAI's HTTP endpoint, POST /v1/chat/completions, that takes a model name and a list of role-tagged messages and returns the model's next message. Its request and response shape became the common format that OpenAI-compatible providers and SDKs reuse.

Also called: Chat Completions, chat completions endpoint, /v1/chat/completions, chat.completions.create

Most LLM code in the wild speaks one dialect: a list of messages in, one message out. That dialect is the Chat Completions API.

How it works

You POST JSON to /v1/chat/completions with a model and a messages array. Each message has a role (system, user, assistant or tool) and content. The reply holds a choices array; each choice carries a message and a finish_reason that says why generation ended, plus a usage block with token counts.

curl https://inference.broadnet.ai/v1/chat/completions \
  -H "Authorization: Bearer $BROADNET_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"broadnet/gemma-4-26b-a4b",
       "messages":[{"role":"system","content":"Answer in one line."},
                   {"role":"user","content":"What is a token?"}]}'

In the OpenAI Python SDK the same call is client.chat.completions.create(...). Optional fields shape the output: max_tokens, temperature, stream, tools, response_format and others.

The API is stateless. OpenAI’s migration guide says that in Chat Completions “conversation state must be managed manually”: your code keeps the history and sends it again each turn. OpenAI’s newer Responses API uses typed items and can carry state server-side, and OpenAI recommends it for new projects on its own platform, but says Chat Completions “remains supported”.

Why it matters

  • Portability. An OpenAI-compatible API usually means this endpoint. Changing provider is often a new base URL, key and model name.
  • Cost. Because the whole history is resent, input tokens grow every turn. Trim or summarise long chats.
  • Field drift. Compatible providers do not all accept every OpenAI field. Unknown fields may be ignored or rejected, so test the ones you depend on.

On BroadNet Inference

BroadNet serves chat at POST /v1/chat/completions on https://inference.broadnet.ai/v1, for DeepSeek V4.1 Flash, GLM 5.3, Qwen3.8 27B and Gemma 4 VL 26B. Streaming uses stream=true and ends with data: [DONE]. Tool calling and structured output are documented for GLM 5.3 and Qwen3.8 27B only. BroadNet’s API reference does not document a Responses endpoint, so use Chat Completions. Start with the curl quickstart or the Python SDK guide.

Common mistakes

  • Sending only the latest user message and expecting the model to remember the chat.
  • Copying OpenAI-only fields to another provider without checking its reference.

Questions

Is the Chat Completions API deprecated?

No. OpenAI's migration guide says "Chat Completions remains supported", while it recommends the newer Responses API for new projects on OpenAI.

Does the Chat Completions API remember earlier messages?

No. It is stateless. OpenAI's guide says conversation state "must be managed manually", so you send the full message history with every request.

Which endpoint does BroadNet Inference use for chat?

POST /v1/chat/completions at the base URL https://inference.broadnet.ai/v1. BroadNet does not document a Responses API endpoint.

Read as MarkdownAsk ChatGPTAsk ClaudeAsk Perplexity