---
title: "Invoke function"
method: POST
path: "/v1/function/{function_id}/invoke"
tags: ["Functions"]
---

# Invoke function

`POST /v1/function/{function_id}/invoke`

Invoke a function.

## Path parameters

- `function_id` string, uuid, required — Function id

## Request body

- InvokeApi — The request to invoke a function
  - `input` unknown
  - `messages` ChatCompletionMessageParam[] — If the function is an LLM, additional messages to pass along to it
    - union
      - object
        - `content` string
        - `role` 'system', required
        - `name` string
      - object
        - `content` union
          - string
          - ChatCompletionContentPart[]
            - union
              - …
        - `role` 'user', required
        - `name` string
      - object
        - `role` 'assistant', required
        - `content` string, nullable
        - `function_call` object, nullable
          - `arguments` string, required
          - `name` string, required
        - `name` string, nullable
        - `tool_calls` ChatCompletionMessageToolCall[], nullable
          - `id` string, required
          - `function` object, required
            - `arguments` string, required
            - `name` string, required
          - `type` 'function', required
      - object
        - `content` string
        - `role` 'tool', required
        - `tool_call_id` string
      - object
        - `content` string
        - `name` string, required
        - `role` 'function', required
      - object
        - `role` 'model', required
        - `content` string, nullable
  - `parent` union — Options for tracing the function call
    - object — Span parent properties
      - `object_type` 'project_logs' | 'experiment', required
      - `object_id` string, required — The id of the container object you are logging to
      - `row_ids` object, nullable — Identifiers for the row to to log a subspan under
        - `id` string, required — The id of the row
        - `span_id` string, required — The span_id of the row
        - `root_span_id` string, required — The root_span_id of the row
      - `propagated_event` object, nullable — Include these properties in every span created under this parent
    - string — The parent's span identifier, created by calling `.export()` on a span
  - `stream` boolean, nullable — Whether to stream the response. If true, results will be returned in the Braintrust SSE format.
  - `mode` 'auto' | 'parallel' | 'null', nullable — The mode format of the returned value (defaults to 'auto')
  - `version` string — The version of the function

## Response `200`

Function invocation response

- unknown

---

[API](https://skmtc.net/braintrustdata/apis/braintrust-api.md) · [All operations](https://skmtc.net/braintrustdata/apis/braintrust-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/braintrustdata/braintrust-api/versions/9d216c8243fe/schema)
