Skip to main content
bt functions manages function definitions stored in Braintrust — tools, scorers, LLM functions, and more.
bt functions list                          # List all functions
bt functions view my-function              # View a function
bt functions invoke my-function            # Invoke a function
bt functions push my_tools.ts              # Upload a TypeScript function file
bt functions push src/tools.py             # Upload a Python function file
bt functions pull --slug my-scorer         # Download a function to a local file

bt functions push

Upload local TypeScript or Python function definitions to Braintrust. The CLI discovers functions registered via the Braintrust SDK, bundles them, and uploads them to the API. TypeScript bundling: bt functions push uses esbuild (resolved from your project’s node_modules) to bundle TypeScript/JavaScript files. The packages braintrust, autoevals, @braintrust/*, and all node_modules dependencies are marked external by default and are not inlined into the bundle. Python source collection: For Python files, the CLI collects .py source files within the project root and uploads them as-is. Function discovery: The CLI runs your file through the Braintrust SDK to discover registered functions. Functions are registered using builder methods such as project.tools.create() and project.scorers.create(), which populate a global registry that push reads at upload time. Zod and Pydantic schemas: Parameter schemas defined with Zod (TypeScript) or Pydantic (Python) are serialized and stored alongside the function definition in Braintrust.
bt functions push my_tools.ts
bt functions push src/tools.py src/scorers.py
bt functions push --language javascript my_tools.ts
bt functions push --if-exists replace my_tools.ts
bt functions push --external-packages lodash,axios my_tools.ts

Flags

FlagEnv varDefaultDescription
--file <PATH>BT_FUNCTIONS_PUSH_FILESFile or directory path(s) to scan (repeatable; comma-delimited)
--if-exists <MODE>BT_FUNCTIONS_PUSH_IF_EXISTSerrorBehavior when slug already exists: error, replace, or ignore
--language <LANG>BT_FUNCTIONS_PUSH_LANGUAGEautoForce language: auto, javascript, or python
--external-packages <PKGS>BT_FUNCTIONS_PUSH_EXTERNAL_PACKAGESAdditional packages to exclude from JS bundling (repeatable; space or comma-delimited)
--runner <RUNNER>BT_FUNCTIONS_PUSH_RUNNEROverride runner binary (e.g. tsx, vite-node, python)
--tsconfig <PATH>BT_FUNCTIONS_PUSH_TSCONFIGtsconfig path for the JS runner and bundler
--requirements <PATH>BT_FUNCTIONS_PUSH_REQUIREMENTSPython requirements file
--create-missing-projectsBT_FUNCTIONS_PUSH_CREATE_MISSING_PROJECTStrueCreate referenced projects when they do not exist
--terminate-on-failureBT_FUNCTIONS_PUSH_TERMINATE_ON_FAILUREfalseStop after the first hard failure
--yes / -ySkip confirmation prompts

bt functions pull

Download function definitions from Braintrust to local files. Target functions by slug or ID, choose the output language, and control what happens when local files already exist.
bt functions pull --slug my-scorer                    # Pull a specific function by slug
bt functions pull --slug scorer-a --slug scorer-b     # Pull multiple functions
bt functions pull --language python                   # Output as Python
bt functions pull --output-dir ./functions            # Write to a custom directory
bt functions pull --force                             # Overwrite local files

Flags

FlagEnv varDefaultDescription
--slug <SLUG> / -sBT_FUNCTIONS_PULL_SLUGFunction slug(s) to pull (repeatable; comma-delimited)
--id <ID>BT_FUNCTIONS_PULL_IDFunction ID selector (mutually exclusive with --slug)
--language <LANG>BT_FUNCTIONS_PULL_LANGUAGEtypescriptOutput language: typescript or python
--output-dir <PATH>BT_FUNCTIONS_PULL_OUTPUT_DIR./braintrustDestination directory for generated files
--project-id <ID>BT_FUNCTIONS_PULL_PROJECT_IDFilter by project ID
--version <VERSION>BT_FUNCTIONS_PULL_VERSIONVersion selector
--forceBT_FUNCTIONS_PULL_FORCEfalseOverwrite local files even when dirty
--verbosefalseShow skipped files in output