Chat Completions
POST
/v1/chat/completionsUse an OpenAI Chat Completions-compatible shape for text, multimodal input, and tool calls.
This is the recommended text endpoint for a first integration. Available fields depend on the selected model and Provider route.
Core request fields
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | A model ID returned by /v1/models. |
messages | array | Yes | Conversation messages; content can be a string or a multimodal content array. |
stream | boolean | No | Returns an SSE stream when true. |
temperature | number | No | Sampling control when supported by the model and route. |
max_tokens | integer | No | Output token limit subject to model capability. |
tools | array | No | OpenAI-style function tool definitions. |
response_format | object | No | Structured output request when supported by the model and route. |
Non-streaming examples
curl
curl https://api.noxgate.net/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [{"role": "user", "content": "Hello"}],
"stream": false
}'Python
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://api.noxgate.net/v1",
)
response = client.chat.completions.create(
model="YOUR_MODEL_ID",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-your-api-key",
baseURL: "https://api.noxgate.net/v1",
});
const response = await client.chat.completions.create({
model: "YOUR_MODEL_ID",
messages: [{ role: "user", content: "Hello" }],
});
console.log(response.choices[0]?.message?.content);Streaming
With stream=true, the response uses text/event-stream. Process each data event and treat data: [DONE] as normal completion. The gateway may send comment heartbeats while the connection is idle.
curl · SSE
curl https://api.noxgate.net/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}' \
-NSuccessful response
JSON
{
"id": "chatcmpl_example",
"object": "chat.completion",
"model": "YOUR_MODEL_ID",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello!"},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 3,
"total_tokens": 11
}
}Usage notes
- Start with a non-streaming text request to verify the key, Base URL, and model ID.
- Multimodal input, tool calls, and structured output require support from the selected model.
- Do not assume every Provider supports the same optional fields.