Skip to documentation
DEVELOPER DOCS / HASHBIDXMODEL ACCESS. ONE INTEGRATION.

THE INTEGRATION GUIDE

Streaming

Set "stream": true in your request body to receive a Server-Sent Events stream. Tokens are delivered incrementally as they are generated.

SSE format

Each line is prefixed with data: followed by a JSON object. The stream ends with data: [DONE]. Incremental content is in choices[0].delta.content. If the stream fails midway, an event with an error field (code is stream_error) is sent and the stream closes without data: [DONE].

Server-sent events
data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" world"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

Anthropic Messages streaming

The /v1/messages endpoint uses Anthropic-style SSE events: message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop, and an error event on failure. Use the Anthropic SDK for the easiest integration.

Python example

Python
from openai import OpenAI

client = OpenAI(api_key="<YOUR_API_KEY>", base_url="https://hashbidx.ai/v1")

stream = client.chat.completions.create(
    model="<MODEL_ID>",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True,
    stream_options={"include_usage": True},
)

for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
    if hasattr(chunk, "usage") and chunk.usage:
        print(f"\nTokens used: {chunk.usage.total_tokens}")

Node.js example

Node.js
import OpenAI from "openai";

const client = new OpenAI({ apiKey: "<YOUR_API_KEY>", baseURL: "https://hashbidx.ai/v1" });

const stream = await client.chat.completions.create({
  model: "<MODEL_ID>",
  messages: [{ role: "user", content: "Tell me a story" }],
  stream: true,
  stream_options: { include_usage: true },
});

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content;
  if (content) process.stdout.write(content);
}

Pass stream_options: {"include_usage": true} to receive, just before data: [DONE], a final chunk whose choices is empty and that carries only token usage. Streaming responses carry no X-HashBid-Cost header; see the Logs page for the charge.

BUILD WITH HASHBIDX

Find your model. Make your first call.

Models & pricing