documentation
chat completions
Generate text with the familiar OpenAI chat-completions shape.POST /v1/chat/completions
Send an ordered messages array and a Brok language model. The response uses the OpenAI chat-completions shape.
curl https://api.brok.fyi/v1/chat/completions \
-H "Authorization: Bearer $BROK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"brok-2.3","messages":[{"role":"user","content":"hello"}]}'common parameters
modelRequired. A language model or stable alias.messagesRequired. System, user, assistant, and tool messages in conversation order.streamOptional boolean. Returns SSE chunks when true.temperatureOptional sampling control.max_tokensOptional maximum generated tokens.toolsOptional OpenAI-compatible function tools.tool_choiceOptional tool selection policy.
read the output and usage
const text = data.choices[0].message.content;
const inputTokens = data.usage.prompt_tokens;
const outputTokens = data.usage.completion_tokens;Save x-brok-request-id. It connects application logs to the exact row in Brok Usage.