Skip to main content

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+.

PyPI release pending. From the Gateway repository root, install the preview:

python -m pip install ./sdk/python

After publication, install with 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.

Publishing Instructions

  1. Confirm the package version in bloom-litellm-gateway/sdk/python/pyproject.toml.
  2. Build the wheel:
docker compose exec -T litellm /app/.venv/bin/python3 -m pip wheel \
  --no-deps --no-build-isolation \
  --wheel-dir /tmp/bloom-sdk-wheel sdk/python
  1. Install and smoke-test the artifact:
docker compose exec -T litellm /app/.venv/bin/python3 -m pip install \
  --target /tmp/bloom-sdk-install \
  /tmp/bloom-sdk-wheel/bloom_gateway_sdk-<VERSION>-py3-none-any.whl
  1. Authenticate with PyPI using a project-scoped token or trusted publishing.
  2. Upload the wheel with twine upload.
  3. Verify pip install bloom-gateway-sdk from a clean environment.
  4. Replace the dashboard preview block with the PyPI link after publication.

Metadata

Release files for bloom-gateway-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bloom-gateway-sdk 1.0.0
File Size Uploaded Provenance Actions
bloom_gateway_sdk-1.0.0.tar.gz 8.6 kB Without provenance Details for bloom_gateway_sdk-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bloom-gateway-sdk 1.0.0
File Interpreter ABI Platform Actions
bloom_gateway_sdk-1.0.0-py3-none-any.whl Python 3 none any Details for bloom_gateway_sdk-1.0.0-py3-none-any.whl

Total release size: 16.2 kB

Release files / bloom_gateway_sdk-1.0.0.tar.gz

Download URL bloom_gateway_sdk-1.0.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ef501a686248700443a30ae3cbd6276fd376883bd516300e559ac448f6c0ab13
BLAKE2b-256 checksum
How to use checksums
6455a465c57edfc45dd5bbb1a12427abb70ca66e784c993b09bf249ab5831501
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.0-py3-none-any.whl

Download URL bloom_gateway_sdk-1.0.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12cb713b6f8bbb1842bf6e0bdb568a5a1108a0520027015728b13965ee272453
BLAKE2b-256 checksum
How to use checksums
103dac0112a563f2ff2f996055d51c6301f6916db1173c108abe9b8589116252
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.0

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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page