Skip to main content

baml_bridge

Python bindings for the BAML runtime (powered by bex_engine).

baml_bridge is the bridge layer that generated baml_sdk packages import at runtime: it provides the BamlRuntime singleton, the protobuf encoder/decoder and the function/method factories.

from baml_bridge import BamlRuntime

rt = BamlRuntime.initialize_runtime(
    root_path=".",
    files={"main.baml": baml_source},
)

This package is generally consumed indirectly via the code generated by baml-cli generate --target python — direct use is reserved for runtime authors and bridge tests.

Python callback execution

Passing a Python callable to BAML uses the environment of the call that invokes it. Reusing a callback across threads, event loops, or requests does not retain its registration environment.

BAML entry Python callback Execution environment
Synchronous Synchronous Calling Python thread, with its current context
Synchronous Coroutine result Bridge-owned worker loop, with copied caller context
Asynchronous Synchronous or coroutine result Originating application loop, with copied entry context

Each dispatch of an async entry receives a separate copy of its application ContextVars. Callback writes do not change the awaiting task's context or another dispatch's context. An async callback need not run in the caller's exact asyncio.Task.

A synchronous entry blocks its calling thread, including any application loop running there. Coroutine callbacks of that entry must use resources of their executing worker loop. Awaiting resources owned by the blocked loop is unsupported.

Returned BAML closures support closure(...) and await closure.call_async(...). Passing a closure back into BAML preserves its native function handle. Each new invocation selects its own environment.

Cancelling a BAML call cancels executing coroutine callbacks on their owning loops. Callback tasks retain their arguments and context until their bodies and async cleanup finish. Cancellation does not interrupt a synchronous Python body. A callback that suppresses cancellation may finish later; its result does not revive the cancelled BAML call.

Requirements

  • Python 3.10+
  • protobuf >= 6.31.1

License

Apache-2.0

Metadata

Release files for baml-bridge 0.22.1

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

Built distributions (wheels)

Table of built distributions (wheels) for baml-bridge 0.22.1
File
baml_bridge-0.22.1-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
baml_bridge-0.22.1-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
baml_bridge-0.22.1-cp310-abi3-musllinux_1_1_x86_64.whl CPython 3.10 abi3 Linux musl 1.1+ x86-64 Details
baml_bridge-0.22.1-cp310-abi3-musllinux_1_1_aarch64.whl CPython 3.10 abi3 Linux musl 1.1+ ARM64 Details
baml_bridge-0.22.1-cp310-abi3-manylinux_2_24_aarch64.whl CPython 3.10 abi3 Linux glibc 2.24+ ARM64 Details
baml_bridge-0.22.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
baml_bridge-0.22.1-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
baml_bridge-0.22.1-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 123.4 MB

Release files / baml_bridge-0.22.1-cp310-abi3-win_arm64.whl

Download URL baml_bridge-0.22.1-cp310-abi3-win_arm64.whl
Size 15.8 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
3ab30394b0be895f31af89698785eed99a7d22349c13a648c8b410ff200c0c89
BLAKE2b-256 checksum
How to use checksums
4db33506191239ffd5555f72a4015c7a01cc01d556c3662c2c3c4c689390fbdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / baml_bridge-0.22.1-cp310-abi3-win_amd64.whl

Download URL baml_bridge-0.22.1-cp310-abi3-win_amd64.whl
Size 16.8 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
a15916796cb6e133deff179dcef54f67580234a0cf26ab708b7bae5873dfa090
BLAKE2b-256 checksum
How to use checksums
dc0c6099eb3fad7640f61495c0cba68aa08f63a837bf14d631cabd66b1daefc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / baml_bridge-0.22.1-cp310-abi3-musllinux_1_1_x86_64.whl

Download URL baml_bridge-0.22.1-cp310-abi3-musllinux_1_1_x86_64.whl
Size 15.9 MB
Tags CPython 3.10 Linux musl 1.1+ x86-64 abi3
SHA-256 checksum
How to use checksums
ed74061e4728fa51fc652481618b0b6d7169cf2093203367829474085f4f6f41
BLAKE2b-256 checksum
How to use checksums
e0ed61fbb856fd766ffc3ac3aa655e26bdf5bb6d5db792047b01e5d13a717382
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / baml_bridge-0.22.1-cp310-abi3-musllinux_1_1_aarch64.whl

Download URL baml_bridge-0.22.1-cp310-abi3-musllinux_1_1_aarch64.whl
Size 14.8 MB
Tags CPython 3.10 Linux musl 1.1+ ARM64 abi3
SHA-256 checksum
How to use checksums
288bf828073902508dfec6883af49df51f59413c38a6f8390a7d9fc3841da2f5
BLAKE2b-256 checksum
How to use checksums
ab3a48bc1b9ac2ef0bec1b785128c0d9fc1f475d46b2653c444c5b5ed39c1a41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / baml_bridge-0.22.1-cp310-abi3-manylinux_2_24_aarch64.whl

Download URL baml_bridge-0.22.1-cp310-abi3-manylinux_2_24_aarch64.whl
Size 14.6 MB
Tags CPython 3.10 Linux glibc 2.24+ ARM64 abi3
SHA-256 checksum
How to use checksums
71fe668e08d9f886918e69dbb86cce5935855f71dcf48f0c32063c1f70c056f1
BLAKE2b-256 checksum
How to use checksums
ceed5d01d6bb528f4a76a2c8cf45cd94526709140e7660a6a7de6ff19e6b9f91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / baml_bridge-0.22.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL baml_bridge-0.22.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 15.7 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
8b4461734caabc34189abd2cf0c2ce3ccc51997057676e7990f36cc46b1af6aa
BLAKE2b-256 checksum
How to use checksums
5960b76f4920587ec1335d515d828ddc5c3ecdbe3f113b2592ac6fe6aac2db45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / baml_bridge-0.22.1-cp310-abi3-macosx_11_0_arm64.whl

Download URL baml_bridge-0.22.1-cp310-abi3-macosx_11_0_arm64.whl
Size 14.4 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4dc919c599a6754e9df7ae72aeb179dfe9ac6e137417bd0df4413eef4af85962
BLAKE2b-256 checksum
How to use checksums
8faa513c0822bb369faf7fb47b84d52df2874908d6e377c304d2f23794f30a05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / baml_bridge-0.22.1-cp310-abi3-macosx_10_12_x86_64.whl

Download URL baml_bridge-0.22.1-cp310-abi3-macosx_10_12_x86_64.whl
Size 15.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
898440b445e8fe328a2809fccf6a3d3874611178d52f163983526ced223889ad
BLAKE2b-256 checksum
How to use checksums
925ce7c02533f1716bf4d30cf80b4392776b6558268c0fc66574e0feab9aeace
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release history Release notifications | RSS feed

0.22.2

8 release files

This release

0.22.1 This release

8 release files

0.22.0

8 release files

0.20.1

8 release files

0.20.0

8 release files

0.19.0

8 release files

0.17.0

8 release files

0.16.0

8 release files

0.15.0

8 release files

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