Bloom Gateway SDK for Python
bloom-gateway-sdk is a dependency-free helper for applications that call the
Bloom Gateway's OpenAI-compatible inference API. It builds the Gateway's
bloom request extension and parses Bloom metadata from responses; your
application continues to own HTTP transport through the OpenAI SDK, httpx,
or another client.
Install
Requires Python 3.10+.
pip install bloom-gateway-sdk
Call the Gateway
Create a Gateway virtual key and keep it on the server. Pass it to an
OpenAI-compatible client pointed at the Gateway; do not expose virtual keys in
browser or mobile applications. Use a concrete provider/model identifier as
the request model.
from openai import OpenAI
from bloom_sdk import BloomOverrides
client = OpenAI(api_key=api_key, base_url="https://gateway.bloomfactory.ai/v1")
response = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
extra_body={"bloom": BloomOverrides(routing_type="smart").to_dict()},
)
The OpenAI SDK supplies the bearer authentication from api_key. To send the
Bloom-branded virtual-key header and optional attribution headers instead, use
BloomHeaders with the transport client you already use.
from bloom_sdk import BloomHeaders
headers = BloomHeaders(api_key=api_key, client_id="support-bot").to_dict()
BloomHeaders rejects ambiguous attribution pairs: choose client_id or
agent_id, and trace_id or session_id.
Request controls
BloomOverrides validates and serializes the stable Gateway controls. Omitted
fields are omitted from the request, allowing the Gateway's saved defaults to
apply.
from bloom_sdk import BloomOverrides
overrides = BloomOverrides(
prompt_compaction="compact",
semantic_cache_enabled=True,
routing_type="smart",
routing_task="coding",
routing_preference="quality",
)
body = {"bloom": overrides.to_dict()}
Supported values are compact, prune, trim, or none for
prompt_compaction; strict or smart for routing_type; and cost,
latency, or quality for routing_preference. Smart Routing uses the
concrete model supplied to the request as its routing baseline.
Parse responses
For a non-streaming response from a transport client, use BloomResponse to
read Bloom response headers and echoed body metadata. Missing metadata remains
None.
from bloom_sdk import BloomResponse
bloom = BloomResponse.from_response(http_response)
print(bloom.call_id)
print(bloom.response_cost_float())
print(bloom.routing_task)
if bloom.compaction and bloom.compaction.enabled:
print(bloom.compaction.chars_removed)
For streaming responses, parse the initial SSE response headers with
BloomStreamResponse.from_headers(). When the final chunk is available, use
BloomStreamResponse.from_stream(headers, final_chunk) to combine header and
final-chunk metadata.
from bloom_sdk import BloomStreamResponse
bloom = BloomStreamResponse.from_stream(stream_headers, final_chunk)
print(bloom.call_id, bloom.request_id)
Scope
This SDK is for direct Gateway inference calls only. It does not provide HTTP transport, retries, key or workspace management, dashboard API calls, Bloom API telemetry lookups, or control-plane routes.
Metadata
Release files for bloom-gateway-sdk 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bloom_gateway_sdk-1.0.1.tar.gz | 8.3 kB | Without provenance | Details for bloom_gateway_sdk-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bloom_gateway_sdk-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for bloom_gateway_sdk-1.0.1-py3-none-any.whl |
Total release size: 15.5 kB
Release files / bloom_gateway_sdk-1.0.1.tar.gz
| Download URL | bloom_gateway_sdk-1.0.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0001e5ed645fed8f3edb9fdaefb9d153f0ac449f5d5f0b3b01df51b343e16366
|
|
BLAKE2b-256 checksum How to use checksums |
55e63367141ac6bd3867147e47ef37cc9f0bd735aa570cc80b660b054cae010c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / bloom_gateway_sdk-1.0.1-py3-none-any.whl
| Download URL | bloom_gateway_sdk-1.0.1-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68291a4452ed62f8266ef398c0dfc7623c42357dcf29979e49877c40a2e0cf83
|
|
BLAKE2b-256 checksum How to use checksums |
81ebd652e9ef6fe610f29daeac345c2626b169b76ed865d4e43b951606a207d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for bloom-gateway-sdk 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.