Cross-object insert
Insert events and feedback across object types
POST /v1/insert
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/json
OptionalA mapping from event object type -> object id -> events to insert
experiment
objectA mapping from experiment id to a set of log events and feedback items to insert
dataset
objectA mapping from dataset id to a set of log events and feedback items to insert
project_logs
objectA mapping from project id to a set of log events and feedback items to insert
curl -X POST "https://api.braintrust.dev/v1/insert" \ -H "Authorization: Bearer <token>" \ -H "Content-Type: application/json" \ -d '{ "experiment": { "property1": { "events": [ { "input": null, "output": null, "expected": null, "error": null, "scores": { "property1": 1, "property2": 1 }, "metadata": { "model": "string", "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", "origin": { "object_type": "project_logs", "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb", "id": "string", "_xact_id": "string", "created": "string" }, "_object_delete": true, "_is_merge": true, "_merge_paths": [ [ "string" ] ], "_parent_id": "string", "span_id": "string", "root_span_id": "string", "span_parents": [ "string" ] } ], "feedback": [ { "id": "string", "scores": { "property1": 1, "property2": 1 }, "expected": null, "comment": "string", "metadata": { "property1": null, "property2": null }, "source": "app", "tags": [ "string" ] } ] }, "property2": { "events": [ { "input": null, "output": null, "expected": null, "error": null, "scores": { "property1": 1, "property2": 1 }, "metadata": { "model": "string", "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", "origin": { "object_type": "project_logs", "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb", "id": "string", "_xact_id": "string", "created": "string" }, "_object_delete": true, "_is_merge": true, "_merge_paths": [ [ "string" ] ], "_parent_id": "string", "span_id": "string", "root_span_id": "string", "span_parents": [ "string" ] } ], "feedback": [ { "id": "string", "scores": { "property1": 1, "property2": 1 }, "expected": null, "comment": "string", "metadata": { "property1": null, "property2": null }, "source": "app", "tags": [ "string" ] } ] } }, "dataset": { "property1": { "events": [ { "input": null, "expected": null, "metadata": { "model": "string", "property1": null, "property2": null }, "tags": [ "string" ], "id": "string", "created": "2019-08-24T14:15:22Z", "origin": { "object_type": "project_logs", "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb", "id": "string", "_xact_id": "string", "created": "string" }, "_object_delete": true, "_is_merge": true, "_merge_paths": [ [ "string" ] ], "_parent_id": "string", "span_id": "string", "root_span_id": "string", "span_parents": [ "string" ] } ], "feedback": [ { "id": "string", "comment": "string", "metadata": { "property1": null, "property2": null }, "source": "app", "tags": [ "string" ] } ] }, "property2": { "events": [ { "input": null, "expected": null, "metadata": { "model": "string", "property1": null, "property2": null }, "tags": [ "string" ], "id": "string", "created": "2019-08-24T14:15:22Z", "origin": { "object_type": "project_logs", "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb", "id": "string", "_xact_id": "string", "created": "string" }, "_object_delete": true, "_is_merge": true, "_merge_paths": [ [ "string" ] ], "_parent_id": "string", "span_id": "string", "root_span_id": "string", "span_parents": [ "string" ] } ], "feedback": [ { "id": "string", "comment": "string", "metadata": { "property1": null, "property2": null }, "source": "app", "tags": [ "string" ] } ] } }, "project_logs": { "property1": { "events": [ { "input": null, "output": null, "expected": null, "error": null, "scores": { "property1": 1, "property2": 1 }, "metadata": { "model": "string", "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", "origin": { "object_type": "project_logs", "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb", "id": "string", "_xact_id": "string", "created": "string" }, "_object_delete": true, "_is_merge": true, "_merge_paths": [ [ "string" ] ], "_parent_id": "string", "span_id": "string", "root_span_id": "string", "span_parents": [ "string" ] } ], "feedback": [ { "id": "string", "scores": { "property1": 1, "property2": 1 }, "expected": null, "comment": "string", "metadata": { "property1": null, "property2": null }, "source": "app", "tags": [ "string" ] } ] }, "property2": { "events": [ { "input": null, "output": null, "expected": null, "error": null, "scores": { "property1": 1, "property2": 1 }, "metadata": { "model": "string", "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", "origin": { "object_type": "project_logs", "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb", "id": "string", "_xact_id": "string", "created": "string" }, "_object_delete": true, "_is_merge": true, "_merge_paths": [ [ "string" ] ], "_parent_id": "string", "span_id": "string", "root_span_id": "string", "span_parents": [ "string" ] } ], "feedback": [ { "id": "string", "scores": { "property1": 1, "property2": 1 }, "expected": null, "comment": "string", "metadata": { "property1": null, "property2": null }, "source": "app", "tags": [ "string" ] } ] } } }'
Returns the inserted row ids for the events on each individual object
{ "experiment": { "property1": { "row_ids": [ "string" ] }, "property2": { "row_ids": [ "string" ] } }, "dataset": { "property1": { "row_ids": [ "string" ] }, "property2": { "row_ids": [ "string" ] } }, "project_logs": { "property1": { "row_ids": [ "string" ] }, "property2": { "row_ids": [ "string" ] } } }