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

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.0
File
baml_bridge-0.22.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
baml_bridge-0.22.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
baml_bridge-0.22.0-cp310-abi3-musllinux_1_1_x86_64.whl CPython 3.10 abi3 Linux musl 1.1+ x86-64 Details
baml_bridge-0.22.0-cp310-abi3-musllinux_1_1_aarch64.whl CPython 3.10 abi3 Linux musl 1.1+ ARM64 Details
baml_bridge-0.22.0-cp310-abi3-manylinux_2_24_aarch64.whl CPython 3.10 abi3 Linux glibc 2.24+ ARM64 Details
baml_bridge-0.22.0-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.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
baml_bridge-0.22.0-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.0-cp310-abi3-win_arm64.whl

Download URL baml_bridge-0.22.0-cp310-abi3-win_arm64.whl
Size 15.8 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
94ac92dfec2beb775e7b79d90573dc14a2a6c276b78241c69094b147d75ef269
BLAKE2b-256 checksum
How to use checksums
006a35470d4e185d5af746c8ea8f5ea7da0b98f2490999101ced7c8988db348f
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.0-cp310-abi3-win_amd64.whl

Download URL baml_bridge-0.22.0-cp310-abi3-win_amd64.whl
Size 16.8 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2919c65db7a5d4d95f69b76e84da57e31a9ff99832c4a198b19e8d5a4b593eff
BLAKE2b-256 checksum
How to use checksums
c65dd517516809de162f70f6f0816aec4c52cf24c25a3d7286908dd86eee0485
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.0-cp310-abi3-musllinux_1_1_x86_64.whl

Download URL baml_bridge-0.22.0-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
2da7576958dc86c7f96f4851444cda124156f0a17122a499159a316c35521c1b
BLAKE2b-256 checksum
How to use checksums
3c0d2c0a4be77754a0a71c8b515e6ce9ecbcc25a61fe768eba26173528348c1a
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.0-cp310-abi3-musllinux_1_1_aarch64.whl

Download URL baml_bridge-0.22.0-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
ca55bdc35fda35d01adfeea8a8d225ff9e7152bf5171d4b4479b0db1d9feb427
BLAKE2b-256 checksum
How to use checksums
bfdeec6d38bdb42ce57b23020e0310861d159d26e4d5acc43ac02f0365a28653
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.0-cp310-abi3-manylinux_2_24_aarch64.whl

Download URL baml_bridge-0.22.0-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
6c14a7c14eaaf87dada116ada2d3ce91b7f54081e23e17a82a157cf7ebe430e5
BLAKE2b-256 checksum
How to use checksums
3389c4b46429095942edb12814246a4d9111a5e92c539c1161dc72a2e4644e8c
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.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL baml_bridge-0.22.0-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
a10c1aa1fd3f4bdb7fda3f2a17a6d9c2d451ae62c2d64f0537ca3de08eb58fcb
BLAKE2b-256 checksum
How to use checksums
de0a9312e5759e272264f730f875b8c371a02373784edc9c885e07a7eab1c70e
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.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL baml_bridge-0.22.0-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
d067b433ab651b524d278290eeed4ce762d8b79fce2750e18e8c2948a01943ae
BLAKE2b-256 checksum
How to use checksums
2b40ef4bb4385fda45a5895b751612af64c706b2de6e5dad5214b970735397e9
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.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL baml_bridge-0.22.0-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
146ce6b0eb36fe78abb98a95886ecc06d188c77c392575cd5a5326bee68f1fc6
BLAKE2b-256 checksum
How to use checksums
b122b15e2c77659440165e42cce45fb1f26adf385dc0dd77f2b72a58cb0f1f3c
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

0.22.1

8 release files

This release

0.22.0 This release

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