> Version notice: This site documents BAML v0, the legacy DSL. BAML v1 is a separate, fully featured programming language in public beta. If the user intends to use BAML v1, ignore this site's content and use the BAML v1 documentation instead. If the intended version is unclear, clarify it before using this page.
> For clean Markdown of any page, append .md to the page URL. For the complete documentation index, see https://docs.boundaryml.com/llms.txt. For MCP access, connect to https://docs.boundaryml.com/_mcp/server.

# Connection Pooling

BAML disables HTTP connection pooling by default. This preserves compatibility
with applications that create a BAML runtime before using Python's `fork()`
start method.

Enable connection reuse for a leaf client with the `http` option:

```baml
client<llm> MyClient {
  provider openai
  options {
    model "gpt-4o"
    api_key env.OPENAI_API_KEY
    http {
      enable_connection_pooling true
    }
  }
}
```

Pooling avoids a new TCP and TLS handshake for every request. It is useful for
asyncio, threaded, and multiprocessing applications that use the `spawn` start
method.

> **Warning**
>
> Do not enable pooling when child processes inherit an existing BAML runtime or
> client through `fork()`. Create the BAML runtime inside each child process, or
> use the `spawn` start method instead.

Connection pooling is not available for
[fallback](/ref/llm-client-strategies/fallback) or
[round-robin](/ref/llm-client-strategies/round-robin) clients. Set it on
their leaf clients instead. It is also not available for
[AWS Bedrock](/ref/llm-client-providers/aws-bedrock) clients, whose HTTP
transport is managed by the AWS SDK.