documentation
use the OpenAI SDK
Point the official SDK at Brok with two configuration values.Python
Use the official OpenAI package. Keep your existing client code and change the API key plus base URL.
# pip install openai
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["BROK_API_KEY"],
base_url="https://api.brok.fyi/v1",
timeout=60.0,
max_retries=2,
)
response = client.chat.completions.create(
model="brok-2.3",
messages=[{"role": "user", "content": "hello"}],
)
print(response.choices[0].message.content)JavaScript
// npm install openai
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.BROK_API_KEY,
baseURL: "https://api.brok.fyi/v1",
timeout: 60_000,
maxRetries: 2,
});
const response = await client.chat.completions.create({
model: "brok-2.3",
messages: [{ role: "user", content: "hello" }],
});
console.log(response.choices[0].message.content);compatibility, stated precisely
Brok supports the OpenAI SDK shapes used by models, chat completions, Responses, image generation, speech, and files. It does not claim every endpoint in the OpenAI platform. Use Brok REST routes for video, music, search, tools, and MCP.
- GET
/v1/modelsList available Brok models - POST
/v1/chat/completionsChat, tools, vision, and streaming - POST
/v1/responsesResponses API, including streaming - POST
/v1/images/generationsImage generation - POST
/v1/audio/speechText to speech - GET/POST
/v1/filesList and upload files