OpenAI-compatible API request builder
Updated
In short: An OpenAI-compatible request is a POST to the base URL plus /chat/completions, with an Authorization: Bearer header and a JSON body holding model and messages. With the OpenAI SDKs you change only base_url and the key. This builder writes the same request as curl, Python requests, the OpenAI Python SDK, Node fetch and the Node SDK.
The code uses a placeholder: your key is read from an environment variable and is never typed into this page. BroadNet Gemma 4 VL 26B is the default because it runs on the $5 starting credit; the other BroadNet models need a top-up.
Report a wrong price or number (email to info@broadnet.ai, with this page's link and your inputs filled in).
How it works
- Set the base URL (any OpenAI-compatible API) and pick a model, or choose "Custom model" and type an ID.
- Write the system and user messages and set options: temperature, max_tokens, reasoning_effort, streaming with usage, and JSON mode or a tools example.
- Pick an output tab: curl, Python requests, OpenAI Python SDK, Node fetch or OpenAI Node SDK.
- Copy the code, set your key in the environment variable it names, and run it. Copy the page link to share the same request.
Anatomy of a chat completions request
POST https://inference.broadnet.ai/v1/chat/completions
Authorization: Bearer $BROADNET_API_KEY
Content-Type: application/json
{
"model": "broadnet/gemma-4-26b-a4b",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Say hello in English and Arabic."}
],
"max_tokens": 1000,
"stream": true,
"stream_options": {"include_usage": true}
}| Parameter | What it does |
|---|---|
model | The model ID. On BroadNet: broadnet/deepseek-v4.1-flash, broadnet/glm-5.3, broadnet/qwen3.8-27b, broadnet/gemma-4-26b-a4b. |
messages | The conversation: system, user, assistant and tool turns, oldest first. |
temperature | Randomness, 0 to 2. Leave it unset unless you need it. |
max_tokens | Cap on generated tokens, reasoning included. See max tokens. |
reasoning_effort | low, medium or high thinking on reasoning models. |
stream, stream_options | Server-Sent Events; include_usage adds token counts in the last chunk. See streaming. |
response_format | json_object for JSON mode, or json_schema for structured output. |
tools, tool_choice | Functions the model may call. See tool calling. |
Common mistakes
- Base URL with or without
/v1: SDKs append/chat/completionsto the base URL, so the base must end in/v1. - JSON mode without the word "JSON" in the prompt: many servers reject or misbehave. The builder adds an instruction for you.
max_tokenstoo low on a reasoning model: the answer comes back empty withfinish_reason: "length".- Tools on a model that does not support them: on BroadNet, GLM 5.3 and Qwen3.8 27B are listed with tools.
- Hard-coded keys in code or in shared links. Keep keys in environment variables and rotate any that leak; see API keys and IP allow-lists.
Questions
How do I call an OpenAI-compatible API?
Send a POST to BASE_URL/chat/completions with an Authorization: Bearer header and a JSON body with model and messages. With the OpenAI SDKs, set base_url (Python) or baseURL (Node) and your key; the rest of your code stays the same. For BroadNet Inference the base URL is https://inference.broadnet.ai/v1.
How do I convert a curl request to Python?
Fill in the form once and switch tabs: the builder writes the same request as curl, Python requests, the OpenAI Python SDK, Node fetch and the OpenAI Node SDK, with identical parameters.
How do I get token usage when streaming?
Add stream_options: {"include_usage": true}. The last chunk before data: [DONE] carries usage and an empty choices list, so check for both. Streaming chat completions.
What is the difference between JSON mode and structured output?
JSON mode (response_format: {"type": "json_object"}) only promises valid JSON, and the prompt must ask for JSON. Structured output (json_schema with strict: true) makes the reply match your schema. Build a schema with the JSON schema generator.
What does reasoning_effort do?
On reasoning models it sets how long the model thinks before answering: low, medium or high. Reasoning tokens are billed as output and count toward max_tokens, so a low max_tokens can return an empty answer. Why answers come back empty.
Can I use this builder with other providers?
Yes. Any OpenAI-compatible base URL works: type it in Base URL and choose "Custom model" to enter its model ID. Parameter support differs between providers, so check their docs for tools, JSON mode and reasoning_effort.