Functions

Run the specified function with the provided input and return its result. Use version to select a specific function version, parent to attach the call to a trace, and stream to receive results in the Braintrust SSE format.

post/v1/function/{function_id}/invoke

Request

  • Base URL
    https://api.braintrust.dev
  • Auth
    • HTTP bearer
    • or none

Path parameters

function_idstring uuid required

Function id

Request body

request_sourcestring
inputunknown
expectedunknown
metadataobject nullable

Any relevant metadata. This will be logged and available as the metadata argument.

tagsstring[] nullable

Any relevant tags to log on the span.

streamboolean nullable

Whether to stream the response. If true, results will be returned in the Braintrust SSE format.

mode'auto' | 'parallel' | 'json' | 'text' | 'null' nullable

The mode format of the returned value (defaults to 'auto')

strictboolean nullable

If true, throw an error if one of the variables in the prompt is not present in the input

mcp_authobject

Map of MCP server URL to auth credentials

overridesobject nullable

Partial function definition to merge with the function being invoked. Fields are validated against the function type's schema at runtime. For facets: { preprocessor?, prompt?, model? }. For prompts: { model?, ... }.

endpoint_namestring nullable

Name of the AI provider secret to pin this invocation to.

versionstring

The version of the function

Response

Function invocation response. Scorer results follow the ScoreResult schema: a single score defaults to the function name when unnamed; arrays require a unique name for every score.

unknown required

Changes

    • breaking

      the request property became not nullable

    • breaking

      the request property became not nullable

    • breaking

      the request property became not nullable

    • breaking

      the request property /// became not nullable

    • breaking

      the request property /// became not nullable

    • breaking

      the request property /// became not nullable

    • breaking

      the request property ///// became not nullable

    • breaking

      the request property ///// became not nullable

    • breaking

      the request property /// became not nullable

    • breaking

      the request property /// became not nullable

    • breaking

      the request property /// became not nullable

    • breaking

      the request property /// became not nullable

    • breaking

      the request property became not nullable

    • breaking

      the request property / became not nullable

    • breaking

      the request property became not nullable

    • breaking

      the request property became not nullable

    • breaking

      the request property / became not nullable

    • breaking

      the request property // became not nullable

    • breaking

      the request property /// became not nullable

    • breaking

      the request property // became not nullable

    • breaking

      the request property became not nullable

    • breaking

      the request property became not nullable

    • breaking

      the request property became not nullable

    • info

      added the new optional request property