Client and API integration
Connect to BOS API with cURL, Python, Node.js, or a compatible client.
Endpoint, authentication, and protocol
For the OpenAI SDK, use the gateway address including /v1 as the Base URL and authenticate with Authorization: Bearer BOS_API_KEY. The examples below call /v1/chat/completions; an administrator must configure the model and grant it to the current key.
| Client or protocol | Address or endpoint | Authentication |
|---|---|---|
| OpenAI SDK | <GATEWAY_URL>/v1 | Bearer gateway key |
| Chat Completions | POST /v1/chat/completions | Authorization header |
| Compatible third-party client | OpenAI-compatible Base URL | API key setting |
Choose your client
All four tabs use the same endpoint, key, and model. Set BOS_GATEWAY_KEY in your environment, then replace the example endpoint and model ID.
curl --fail-with-body "https://bosapi.example.com/v1/chat/completions" \
-H "Authorization: Bearer $BOS_GATEWAY_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL_ID",
"messages": [
{"role": "user", "content": "Say hello in one sentence."}
]
}'# Install: python -m pip install openai
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["BOS_GATEWAY_KEY"],
base_url="https://bosapi.example.com/v1",
)
response = client.chat.completions.create(
model="YOUR_MODEL_ID",
messages=[
{"role": "user", "content": "Say hello in one sentence."}
],
)
print(response.choices[0].message.content)// Install: npm install openai
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.BOS_GATEWAY_KEY,
baseURL: "https://bosapi.example.com/v1",
});
const response = await client.chat.completions.create({
model: "YOUR_MODEL_ID",
messages: [
{ role: "user", content: "Say hello in one sentence." }
],
});
console.log(response.choices[0].message.content);Base URL https://bosapi.example.com/v1
API Key YOUR_BOS_API_KEY
Model YOUR_MODEL_ID
Protocol OpenAI-compatible / Chat CompletionsResponses and Anthropic Messages
BOS API also exposes protocol routes such as /v1/responses and /v1/messages, but availability depends on the model, channel format, and current key permissions. Chat Completions support does not automatically imply Responses or Messages support.
- Before using Codex, confirm that the model supports Responses.
- For the Anthropic SDK, the Base URL normally uses the gateway origin without /v1; the SDK appends /v1/messages.
- Validate streaming and tool-call behavior separately for each client.
Thinking controls in Messages-to-Chat conversion
For Messages-to-Chat conversion, caller-supplied thinking, reasoning_effort, and enable_thinking are forwarded unchanged, including null and vendor-specific fields inside thinking. BOS adds no defaults and does not validate their types, modes, or budget ranges. The upstream decides whether to accept them; rejection follows upstream error handling. output_config.effort remains a locally consumed compatibility hint and is not mapped to a thinking control.
Credential and troubleshooting boundaries
Gateway keys, console login tokens, key-portal sessions, and upstream provider keys are different credentials. Never place a real key in a URL, browser bundle, screenshot, or shared log.
Match capabilities and procedures to your deployment version. Read the documentation scope