Invoke a prompt
Useinvoke() to call a deployed prompt by its slug:
input parameter values map to template variables in your prompt. For example, {{text}} in your prompt gets replaced with the text value from input.
The Ruby SDK doesn’t support server-side invocation. Instead, load a prompt and build it locally, then call your own LLM client. See Build prompts locally.
Use within a trace
When calling prompts from instrumented code, they automatically nest within your parent trace:Handle tool calls
When a prompt includes tools, the response contains tool calls that your code must handle:Version prompts
Every prompt save creates a new version with a unique ID. Pin specific versions in production code:invoke() and Braintrust::Prompt.load use the latest version.
Use environments
Environments separate dev, staging, and production configurations. UseloadPrompt() with the environment parameter to fetch the prompt version assigned to a specific environment:
invoke() does not accept an environment parameter. To execute an environment-pinned prompt server-side via invoke(), resolve the version with loadPrompt() first and pass it to invoke():loadPrompt() if you need to pick up environment reassignments.Build prompts locally
Usebuild() to compile a prompt’s template without making an API call. This is useful for testing or generating messages to pass to your own LLM client:
build() method returns the compiled messages, model, and parameters without executing the prompt.
In Ruby, identify the project by name (
project:) or by UUID (project_id:). Providing neither raises an ArgumentError. After loading, prompt.version returns the resolved version’s transaction ID, which you can pass to Braintrust::Prompt.load(version:) to re-pin the exact same version later.Stream responses
Enable streaming to receive responses incrementally:Manage from the CLI
Use thebt CLI to browse and test deployed prompts without opening the UI.
Browse prompts:
bt functions invoke to call a prompt and see its output directly from the terminal:
Use the REST API
Call prompts directly via HTTP.In the examples below, organizations on the EU data plane should replace
api.braintrust.dev with api-eu.braintrust.dev.Next steps
- Deploy functions to deploy tools and workflows alongside prompts
- Manage environments to separate dev and production prompts
- Monitor deployments to track prompt performance in production
- Write prompts to create and test prompts before deployment