HTTP SSE (Server-Sent Events) Access
To provide broader compatibility and a more convenient access method, the Bitseek Chat gateway also supports streaming calls via the HTTP SSE (Server-Sent Events) protocol.
This interface is designed to be fully compatible with OpenAI's Chat Completions API. This means you can use any OpenAI-compatible client library (such as the official openai libraries for Python and Node.js) to connect easily by pointing the base_url (or baseURL) to our service address.
Endpoint
- URL:
https://chat-proxy.bitseek.ai/v1/chat/completions - Method:
POST - Headers:
Content-Type: application/jsonAccept: text/event-streamAuthorization: Bearer <API-KEY>
Request Body
The request body follows OpenAI's chat/completions format. You must set the stream parameter to true.
Example:
{
"messages": [
{
"role": "user",
"content": "Hello, please introduce yourself."
}
],
"stream": true
}
Client Examples
See Client Examples for implementation examples in various languages including cURL, Python, Node.js, and Java.
General Code Explanation
base_url/baseURL: This is the most critical parameter. You must set it to the API address provided by Bitseek Chat. Note the path differences required by different libraries (/v1for Python/Node.js, no path for the Java library).api_key/token: Provide your valid API key for authentication.stream: true: This flag enables the SSE streaming response.chunk: Eachchunkobject received from the stream is consistent with the OpenAI SDK'sChatCompletionChunkstructure, allowing you to easily extract incremental content.
Data Stream Format
Each event returned by the server is a data: field containing an OpenAI-compatible JSON string. The stream is terminated by a special data: [DONE] event. The client libraries handle the parsing of these events automatically.