Parameter Binding
The bind parameter injects infrastructure dependencies (database connections, configuration, auth context) into your endpoint functions without exposing them in the remote function signature.
Basic Usage
Late Binding with Callables
Use callables (lambdas or functions) for dependencies that should be evaluated fresh on each call:
Key Concepts
Excluded from Remote Signature
Bound parameters don’t appear in the registered function signature, so remote tests only need to provide business logic parameters:
# Function definition
@endpoint(bind={"db": lambda: get_db(), "config": AppConfig()})
def query_data(db, config, input: str, session_id: str = None):
...
# Remote signature (what tests see)
query_data(input: str, session_id: str = None)Evaluation Timing
- Static values: Evaluated once at decoration time
- Callables: Evaluated fresh on each function call
No Override
Bound parameters won’t override explicitly provided values:
Resource Cleanup
The SDK automatically handles cleanup for generator-based dependencies:
When to Use bind vs Framework DI
Use bind for SDK endpoints that need the same dependencies in local execution and remote tests, or when working outside a web framework. Use framework DI (e.g., FastAPI’s Depends()) for HTTP endpoints where the framework manages the request lifecycle. The two can coexist on the same dependency:
Next steps
- Map inputs and outputs for the business parameters that remain in the remote signature.
- See Examples for a database-backed endpoint using
bind.