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.