BlazeInferDocs
Integrations

OpenAI Python SDK

Use the official OpenAI Python SDK with BlazeInfer.

SupportedTested with: openai 2.54.0 and 3.42.1 · Last verified: 2026-11-02

The OpenAI Python SDK works with BlazeInfer by changing the base URL and the key.

Install and configure

pip install openai
export BLAZE_API_KEY="blz_..."
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://blaze.e2enetworks.net/v1",
    api_key=os.environ["BLAZE_API_KEY"],
)

response = client.chat.completions.create(
    model="google/gemma-4-31b-it",
    messages=[{"role": "user", "content": "Say hello in one sentence."}],
)
print(response.choices[0].message.content)

Streaming and tools

Streaming and tool calling (tools=[...]) work as they do with OpenAI. See Streaming and Tool calling.

stream = client.chat.completions.create(
    model="google/gemma-4-31b-it",
    messages=[{"role": "user", "content": "Count to five."}],
    stream=True,
)

for chunk in stream:
    if not chunk.choices:   # the final chunk only carries usage
        continue
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)

When you do not send stream_options, BlazeInfer ends the stream with a usage chunk that has an empty choices list. Guard against it as shown above.

Read the key from the environment

Do not hard-code the key. Use os.environ["BLAZE_API_KEY"] as above, and never ship it to a browser.

On this page