Documentation Index
Fetch the complete documentation index at: https://braintrust.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Applies to:
- Plan -
- Deployment -
Summary
Goal: Understand how Braintrust represents prompt version IDs and convert between the raw transaction ID format returned by SDKs and the prettified hex format displayed in the UI. Features: Transaction ID prettification utilities in the Python and JavaScript SDKs for cross-referencing prompt versions between code and UI.How version IDs work
Braintrust uses two formats for the same prompt version ID:- Raw format: A large decimal integer string, such as
"1000197079360977868", returned byprompt.versionin SDKs. - Prettified format: A 16-character lowercase hex string, such as
"38762d010770566c", used in the Braintrust UI.
Convert between formats
Python SDK
Raw to prettified
prettify_xact accepts either an int or a str.
Prettified to raw
load_pretty_xact returns a str. If the input is not exactly 16 characters, it returns the input unchanged.
TypeScript SDK
These functions are exported frombraintrust/util.
Raw to prettified
Prettified to raw
TransactionId type is a string alias. loadPrettyXact returns its input unchanged if it is not exactly 16 characters.
Load a specific prompt version
Both formats can be used withload_prompt and loadPrompt:
version value through to the API. On the backend, Braintrust treats 16-character version strings as prettified transaction IDs and decodes them before lookup.
This normalization is length-based. A non-hex 16-character string will fail during decoding.
Cross-reference with the UI
When logging or displaying a prompt version for a human to find in the Braintrust UI, log the prettified version:How the encoding works
The encoding uses modular multiplication over 64-bit integers:- Interpret the raw transaction ID as an unsigned integer.
- Multiply it by a fixed coprime modulo
2^64:COPRIME = 205891132094649COPRIME_INVERSE = 1522336535492693385MOD = 2^64
- Format the result as a zero-padded 16-character lowercase hexadecimal string.
COPRIME_INVERSE modulo 2^64, and restores the fixed top bits used by Braintrust transaction IDs:
Reference implementations
- Python:
sdk-python/py/src/braintrust/xact_ids.py - TypeScript:
sdk/js/util/xact-ids.ts
Notes
- In JavaScript and TypeScript,
prettifyXactandloadPrettyXactare exported frombraintrust/util. - In Python, the helpers live in
braintrust.xact_idsand are not re-exported from the top-levelbraintrustpackage. load_promptandloadPromptcan accept either the raw decimal version or the 16-character prettified version because the backend normalizes prettified values before lookup.