Skip to main content

baml-cli serve

Start a BAML-over-HTTP API server that exposes your functions via HTTP endpoints.

Usage​

baml-cli serve [OPTIONS]
tip

For development with hot-reload, use baml-cli dev instead.

Options​

OptionDescriptionDefault
--from <PATH>Path to baml_src directory./baml_src
--port <PORT>Server port2024
--no-version-checkSkip version mismatch checkfalse

Endpoints​

Function Calls​

# Call a function
POST /call/:function_name

curl -X POST \
"http://localhost:2024/call/MyFunctionName" \
-H "Content-Type: application/json" \
-d '{"arg1": "value1", "arg2": "value2"}'
# Stream results
POST /stream/:function_name

curl -X POST \
"http://localhost:2024/stream/MyFunctionName" \
-H "Content-Type: application/json" \
-d '{"arg1": "value1", "arg2": "value2"}'

Debugging​

EndpointDescription
GET /docsSwagger UI documentation
GET /openapi.jsonOpenAPI specification
GET /_debug/pingHealth check
GET /_debug/statusServer status

Authentication​

Set BAML_PASSWORD environment variable to enable authentication.

Use header: x-baml-api-key

curl -X POST \
http://localhost:2024/call/MyFunctionName \
-H "Content-Type: application/json" \
-H "x-baml-api-key: ${BAML_PASSWORD}" \
-d '{"arg1": "value1"}'

Examples​

# Start with defaults
baml-cli serve

# Custom port and source
baml-cli serve --from /path/to/baml_src --port 3000

# Test server
curl http://localhost:2024/_debug/ping

Limitations​

Currently not supported:

  • TypeBuilder API
  • Collector API
  • Modular API
  • Custom trace annotations

See Also​