Reference/API/Logs
POST
/v1/project_logs/{project_id}/insert

Insert project logs events

Insert a set of events into the project logs

/v1/project_logs/{project_id}/insert

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header

Request Body

application/jsonOptional

An array of project logs events to insert

events
Required
array<Any properties in object, object>

A list of project logs events to insert

Path Parameters

project_id
Required
string

Project id

Format: "uuid"
curl -X POST "https://api.braintrust.dev/v1/project_logs/497f6eca-6276-4993-bfeb-53cbbbba6f08/insert" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      {
        "input": null,
        "output": null,
        "expected": null,
        "error": null,
        "scores": {
          "property1": 1,
          "property2": 1
        },
        "metadata": {
          "property1": null,
          "property2": null
        },
        "tags": [
          "string"
        ],
        "metrics": {
          "start": 0,
          "end": 0,
          "prompt_tokens": 0,
          "completion_tokens": 0,
          "tokens": 0,
          "caller_functionname": null,
          "caller_filename": null,
          "caller_lineno": null,
          "property1": 0,
          "property2": 0
        },
        "context": {
          "caller_functionname": "string",
          "caller_filename": "string",
          "caller_lineno": 0,
          "property1": null,
          "property2": null
        },
        "span_attributes": {
          "name": "string",
          "type": "llm",
          "property1": null,
          "property2": null
        },
        "id": "string",
        "created": "2019-08-24T14:15:22Z",
        "_object_delete": true,
        "_is_merge": false,
        "_parent_id": "string"
      }
    ]
  }'

Returns the inserted row ids

{
  "row_ids": [
    "string"
  ]
}

GET
/v1/project_logs/{project_id}/fetch

Fetch project logs (GET form)

Fetch the events in a project logs. Equivalent to the POST form of the same path, but with the parameters in the URL query rather than in the request body

/v1/project_logs/{project_id}/fetch

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header

Path Parameters

project_id
Required
string

Project id

Format: "uuid"

Query Parameters

limitinteger | null

limit the number of traces fetched

Fetch queries may be paginated if the total result size is expected to be large (e.g. project_logs which accumulate over a long time). Note that fetch queries only support pagination in descending time order (from latest to earliest _xact_id. Furthermore, later pages may return rows which showed up in earlier pages, except with an earlier _xact_id. This happens because pagination occurs over the whole version history of the event log. You will most likely want to exclude any such duplicate, outdated rows (by id) from your combined result set.

The limit parameter controls the number of full traces to return. So you may end up with more individual rows than the specified limit if you are fetching events containing traces.

Minimum: 0

max_xact_idstring

DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards.

Together, max_xact_id and max_root_span_id form a pagination cursor

Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple (_xact_id, root_span_id). See the documentation of limit for an overview of paginating fetch queries.

max_root_span_idstring

DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards.

Together, max_xact_id and max_root_span_id form a pagination cursor

Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple (_xact_id, root_span_id). See the documentation of limit for an overview of paginating fetch queries.

versionstring

Retrieve a snapshot of events from a past time

The version id is essentially a filter on the latest event transaction id. You can use the max_xact_id returned by a past fetch as the version to reproduce that exact fetch.

curl -X GET "https://api.braintrust.dev/v1/project_logs/497f6eca-6276-4993-bfeb-53cbbbba6f08/fetch?limit=0&max_xact_id=string&max_root_span_id=string&version=string" \
  -H "Authorization: Bearer <token>"

Returns the fetched rows

{
  "events": [
    {
      "id": "string",
      "_xact_id": "string",
      "created": "2019-08-24T14:15:22Z",
      "org_id": "a40f5d1f-d889-42e9-94ea-b9b33585fc6b",
      "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
      "log_id": "g",
      "input": null,
      "output": null,
      "expected": null,
      "error": null,
      "scores": {
        "property1": 1,
        "property2": 1
      },
      "metadata": {
        "property1": null,
        "property2": null
      },
      "tags": [
        "string"
      ],
      "metrics": {
        "start": 0,
        "end": 0,
        "prompt_tokens": 0,
        "completion_tokens": 0,
        "tokens": 0,
        "caller_functionname": null,
        "caller_filename": null,
        "caller_lineno": null,
        "property1": 0,
        "property2": 0
      },
      "context": {
        "caller_functionname": "string",
        "caller_filename": "string",
        "caller_lineno": 0,
        "property1": null,
        "property2": null
      },
      "span_id": "string",
      "span_parents": [
        "string"
      ],
      "root_span_id": "string",
      "is_root": true,
      "span_attributes": {
        "name": "string",
        "type": "llm",
        "property1": null,
        "property2": null
      },
      "origin": {
        "object_type": "experiment",
        "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb",
        "id": "string",
        "_xact_id": "string"
      }
    }
  ],
  "cursor": "string"
}

POST
/v1/project_logs/{project_id}/fetch

Fetch project logs (POST form)

Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the parameters in the request body rather than in the URL query

/v1/project_logs/{project_id}/fetch

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header

Request Body

application/jsonOptional

Filters for the fetch query

limitinteger | null

limit the number of traces fetched

Fetch queries may be paginated if the total result size is expected to be large (e.g. project_logs which accumulate over a long time). Note that fetch queries only support pagination in descending time order (from latest to earliest _xact_id. Furthermore, later pages may return rows which showed up in earlier pages, except with an earlier _xact_id. This happens because pagination occurs over the whole version history of the event log. You will most likely want to exclude any such duplicate, outdated rows (by id) from your combined result set.

The limit parameter controls the number of full traces to return. So you may end up with more individual rows than the specified limit if you are fetching events containing traces.

Minimum: 0

cursorstring | null

An opaque string to be used as a cursor for the next page of results, in order from latest to earliest.

The string can be obtained directly from the cursor property of the previous fetch query

max_xact_idstring | null

DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards.

Together, max_xact_id and max_root_span_id form a pagination cursor

Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple (_xact_id, root_span_id). See the documentation of limit for an overview of paginating fetch queries.

max_root_span_idstring | null

DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards.

Together, max_xact_id and max_root_span_id form a pagination cursor

Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple (_xact_id, root_span_id). See the documentation of limit for an overview of paginating fetch queries.

filtersarray<object> | null

NOTE: This parameter is deprecated and will be removed in a future revision. Consider using the /btql endpoint (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering.

A list of filters on the events to fetch. Currently, only path-lookup type filters are supported.

versionstring | null

Retrieve a snapshot of events from a past time

The version id is essentially a filter on the latest event transaction id. You can use the max_xact_id returned by a past fetch as the version to reproduce that exact fetch.

Path Parameters

project_id
Required
string

Project id

Format: "uuid"
curl -X POST "https://api.braintrust.dev/v1/project_logs/497f6eca-6276-4993-bfeb-53cbbbba6f08/fetch" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "limit": 0,
    "cursor": "string",
    "max_xact_id": "string",
    "max_root_span_id": "string",
    "filters": [
      {
        "type": "path_lookup",
        "path": [
          "string"
        ],
        "value": null
      }
    ],
    "version": "string"
  }'

Returns the fetched rows

{
  "events": [
    {
      "id": "string",
      "_xact_id": "string",
      "created": "2019-08-24T14:15:22Z",
      "org_id": "a40f5d1f-d889-42e9-94ea-b9b33585fc6b",
      "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
      "log_id": "g",
      "input": null,
      "output": null,
      "expected": null,
      "error": null,
      "scores": {
        "property1": 1,
        "property2": 1
      },
      "metadata": {
        "property1": null,
        "property2": null
      },
      "tags": [
        "string"
      ],
      "metrics": {
        "start": 0,
        "end": 0,
        "prompt_tokens": 0,
        "completion_tokens": 0,
        "tokens": 0,
        "caller_functionname": null,
        "caller_filename": null,
        "caller_lineno": null,
        "property1": 0,
        "property2": 0
      },
      "context": {
        "caller_functionname": "string",
        "caller_filename": "string",
        "caller_lineno": 0,
        "property1": null,
        "property2": null
      },
      "span_id": "string",
      "span_parents": [
        "string"
      ],
      "root_span_id": "string",
      "is_root": true,
      "span_attributes": {
        "name": "string",
        "type": "llm",
        "property1": null,
        "property2": null
      },
      "origin": {
        "object_type": "experiment",
        "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb",
        "id": "string",
        "_xact_id": "string"
      }
    }
  ],
  "cursor": "string"
}

POST
/v1/project_logs/{project_id}/feedback

Feedback for project logs events

Log feedback for a set of project logs events

/v1/project_logs/{project_id}/feedback

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header

Request Body

application/jsonOptional

An array of feedback objects

feedback
Required
array<object>

A list of project logs feedback items

Path Parameters

project_id
Required
string

Project id

Format: "uuid"
curl -X POST "https://api.braintrust.dev/v1/project_logs/497f6eca-6276-4993-bfeb-53cbbbba6f08/feedback" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "feedback": [
      {
        "id": "string",
        "scores": {
          "property1": 1,
          "property2": 1
        },
        "expected": null,
        "comment": "string",
        "metadata": {
          "property1": null,
          "property2": null
        },
        "source": "app"
      }
    ]
  }'

Returns a success status

{
  "status": "success"
}

On this page