Braintrust Experiments API

The Experiments API from Braintrust — 6 operation(s) for experiments.

OpenAPI Specification

braintrust-experiments-api-openapi.yml Raw ↑
openapi: 3.1.1
info:
  version: 1.0.0
  title: Braintrust Acls Experiments API
  description: 'API specification for the backend data server. The API is hosted globally at

    https://api.braintrust.dev or in your own environment.


    You can access the OpenAPI spec for this API at https://github.com/braintrustdata/braintrust-openapi.'
  license:
    name: Apache 2.0
servers:
- url: https://api.braintrust.dev
security:
- bearerAuth: []
- {}
tags:
- name: Experiments
paths:
  /v1/experiment:
    post:
      tags:
      - Experiments
      security:
      - bearerAuth: []
      - {}
      operationId: postExperiment
      description: Create a new experiment. If there is an existing experiment in the project with the same name as the one specified in the request, will return the existing experiment unmodified
      summary: Create experiment
      requestBody:
        description: Any desired information about the new experiment object
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateExperiment'
      responses:
        '200':
          description: Returns the new experiment object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Experiment'
        '400':
          description: The request was unacceptable, often due to missing a required parameter
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '401':
          description: No valid API key provided
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '403':
          description: The API key doesn’t have permissions to perform the request
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '429':
          description: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
          headers:
            Retry-After:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '500':
          description: Something went wrong on Braintrust's end. (These are rare.)
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
    get:
      operationId: getExperiment
      tags:
      - Experiments
      description: List out all experiments. The experiments are sorted by creation date, with the most recently-created experiments coming first
      summary: List experiments
      security:
      - bearerAuth: []
      - {}
      parameters:
      - $ref: '#/components/parameters/AppLimitWithDefaultParam'
      - $ref: '#/components/parameters/StartingAfter'
      - $ref: '#/components/parameters/EndingBefore'
      - $ref: '#/components/parameters/Ids'
      - $ref: '#/components/parameters/ExperimentName'
      - $ref: '#/components/parameters/ProjectName'
      - $ref: '#/components/parameters/ProjectIdQuery'
      - $ref: '#/components/parameters/OrgName'
      responses:
        '200':
          description: Returns a list of experiment objects
          content:
            application/json:
              schema:
                type: object
                properties:
                  objects:
                    type: array
                    items:
                      $ref: '#/components/schemas/Experiment'
                    description: A list of experiment objects
                required:
                - objects
                additionalProperties: false
        '400':
          description: The request was unacceptable, often due to missing a required parameter
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '401':
          description: No valid API key provided
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '403':
          description: The API key doesn’t have permissions to perform the request
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '429':
          description: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
          headers:
            Retry-After:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '500':
          description: Something went wrong on Braintrust's end. (These are rare.)
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
  /v1/experiment/{experiment_id}:
    get:
      operationId: getExperimentId
      tags:
      - Experiments
      description: Get an experiment object by its id
      summary: Get experiment
      security:
      - bearerAuth: []
      - {}
      parameters:
      - $ref: '#/components/parameters/ExperimentIdParam'
      responses:
        '200':
          description: Returns the experiment object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Experiment'
        '400':
          description: The request was unacceptable, often due to missing a required parameter
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '401':
          description: No valid API key provided
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '403':
          description: The API key doesn’t have permissions to perform the request
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '429':
          description: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
          headers:
            Retry-After:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '500':
          description: Something went wrong on Braintrust's end. (These are rare.)
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
    patch:
      operationId: patchExperimentId
      tags:
      - Experiments
      description: Partially update an experiment object. Specify the fields to update in the payload. Any object-type fields will be deep-merged with existing content. Currently we do not support removing fields or setting them to null.
      summary: Partially update experiment
      security:
      - bearerAuth: []
      - {}
      parameters:
      - $ref: '#/components/parameters/ExperimentIdParam'
      requestBody:
        description: Fields to update
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PatchExperiment'
      responses:
        '200':
          description: Returns the experiment object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Experiment'
        '400':
          description: The request was unacceptable, often due to missing a required parameter
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '401':
          description: No valid API key provided
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '403':
          description: The API key doesn’t have permissions to perform the request
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '429':
          description: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
          headers:
            Retry-After:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '500':
          description: Something went wrong on Braintrust's end. (These are rare.)
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
    delete:
      operationId: deleteExperimentId
      tags:
      - Experiments
      description: Delete an experiment object by its id
      summary: Delete experiment
      security:
      - bearerAuth: []
      - {}
      parameters:
      - $ref: '#/components/parameters/ExperimentIdParam'
      responses:
        '200':
          description: Returns the deleted experiment object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Experiment'
        '400':
          description: The request was unacceptable, often due to missing a required parameter
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '401':
          description: No valid API key provided
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '403':
          description: The API key doesn’t have permissions to perform the request
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '429':
          description: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
          headers:
            Retry-After:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '500':
          description: Something went wrong on Braintrust's end. (These are rare.)
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
  /v1/experiment/{experiment_id}/insert:
    post:
      operationId: postExperimentIdInsert
      tags:
      - Experiments
      description: Insert a set of events into the experiment
      summary: Insert experiment events
      security:
      - bearerAuth: []
      - {}
      parameters:
      - $ref: '#/components/parameters/ExperimentIdParam'
      requestBody:
        description: An array of experiment events to insert
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InsertExperimentEventRequest'
      responses:
        '200':
          description: Returns the inserted row ids
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InsertEventsResponse'
        '400':
          description: The request was unacceptable, often due to missing a required parameter
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '401':
          description: No valid API key provided
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '403':
          description: The API key doesn’t have permissions to perform the request
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '429':
          description: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
          headers:
            Retry-After:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '500':
          description: Something went wrong on Braintrust's end. (These are rare.)
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
  /v1/experiment/{experiment_id}/fetch:
    post:
      operationId: postExperimentIdFetch
      tags:
      - Experiments
      description: Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the parameters in the request body rather than in the URL query. For more complex queries, use the `POST /btql` endpoint.
      summary: Fetch experiment (POST form)
      security:
      - bearerAuth: []
      - {}
      parameters:
      - $ref: '#/components/parameters/ExperimentIdParam'
      requestBody:
        description: Filters for the fetch query
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FetchEventsRequest'
      responses:
        '200':
          description: Returns the fetched rows
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FetchExperimentEventsResponse'
        '400':
          description: The request was unacceptable, often due to missing a required parameter
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '401':
          description: No valid API key provided
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '403':
          description: The API key doesn’t have permissions to perform the request
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '429':
          description: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
          headers:
            Retry-After:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '500':
          description: Something went wrong on Braintrust's end. (These are rare.)
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
    get:
      operationId: getExperimentIdFetch
      tags:
      - Experiments
      description: Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the parameters in the URL query rather than in the request body. For more complex queries, use the `POST /btql` endpoint.
      summary: Fetch experiment (GET form)
      security:
      - bearerAuth: []
      - {}
      parameters:
      - $ref: '#/components/parameters/ExperimentIdParam'
      - $ref: '#/components/parameters/FetchLimitParam'
      - $ref: '#/components/parameters/MaxXactId'
      - $ref: '#/components/parameters/MaxRootSpanId'
      - $ref: '#/components/parameters/Version'
      responses:
        '200':
          description: Returns the fetched rows
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FetchExperimentEventsResponse'
        '400':
          description: The request was unacceptable, often due to missing a required parameter
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '401':
          description: No valid API key provided
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '403':
          description: The API key doesn’t have permissions to perform the request
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '429':
          description: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
          headers:
            Retry-After:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '500':
          description: Something went wrong on Braintrust's end. (These are rare.)
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
  /v1/experiment/{experiment_id}/feedback:
    post:
      operationId: postExperimentIdFeedback
      tags:
      - Experiments
      description: Log feedback for a set of experiment events
      summary: Feedback for experiment events
      security:
      - bearerAuth: []
      - {}
      parameters:
      - $ref: '#/components/parameters/ExperimentIdParam'
      requestBody:
        description: An array of feedback objects
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeedbackExperimentEventRequest'
      responses:
        '200':
          description: Returns a success status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeedbackResponseSchema'
        '400':
          description: The request was unacceptable, often due to missing a required parameter
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '401':
          description: No valid API key provided
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '403':
          description: The API key doesn’t have permissions to perform the request
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '429':
          description: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
          headers:
            Retry-After:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '500':
          description: Something went wrong on Braintrust's end. (These are rare.)
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
  /v1/experiment/{experiment_id}/summarize:
    get:
      operationId: getExperimentIdSummarize
      tags:
      - Experiments
      description: Summarize experiment
      summary: Summarize experiment
      security:
      - bearerAuth: []
      parameters:
      - $ref: '#/components/parameters/ExperimentIdParam'
      - $ref: '#/components/parameters/SummarizeScores'
      - $ref: '#/components/parameters/ComparisonExperimentId'
      responses:
        '200':
          description: Experiment summary
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SummarizeExperimentResponse'
        '400':
          description: The request was unacceptable, often due to missing a required parameter
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '401':
          description: No valid API key provided
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '403':
          description: The API key doesn’t have permissions to perform the request
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '429':
          description: Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
          headers:
            Retry-After:
              schema:
                type: string
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
        '500':
          description: Something went wrong on Braintrust's end. (These are rare.)
          content:
            text/plain:
              schema:
                type: string
            application/json:
              schema:
                nullable: true
components:
  parameters:
    EndingBefore:
      schema:
        $ref: '#/components/schemas/EndingBefore'
      required: false
      description: 'Pagination cursor id.


        For example, if the initial item in the last page you fetched had an id of `foo`, pass `ending_before=foo` to fetch the previous page. Note: you may only pass one of `starting_after` and `ending_before`'
      name: ending_before
      in: query
    ExperimentIdParam:
      schema:
        $ref: '#/components/schemas/ExperimentIdParam'
      required: true
      description: Experiment id
      name: experiment_id
      in: path
    StartingAfter:
      schema:
        $ref: '#/components/schemas/StartingAfter'
      required: false
      description: 'Pagination cursor id.


        For example, if the final item in the last page you fetched had an id of `foo`, pass `starting_after=foo` to fetch the next page. Note: you may only pass one of `starting_after` and `ending_before`'
      name: starting_after
      in: query
    FetchLimitParam:
      schema:
        $ref: '#/components/schemas/FetchLimitParam'
      required: false
      description: '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.'
      name: limit
      in: query
    ExperimentName:
      schema:
        $ref: '#/components/schemas/ExperimentName'
      required: false
      description: Name of the experiment to search for
      name: experiment_name
      in: query
      allowReserved: true
    Version:
      schema:
        $ref: '#/components/schemas/Version'
      required: false
      description: '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.'
      name: version
      in: query
    AppLimitWithDefaultParam:
      schema:
        $ref: '#/components/schemas/AppLimitWithDefaultParam'
      required: false
      description: Limit the number of objects to return
      name: limit
      in: query
    Ids:
      schema:
        $ref: '#/components/schemas/Ids'
      required: false
      description: Filter search results to a particular set of object IDs. To specify a list of IDs, include the query param multiple times
      name: ids
      in: query
    ComparisonExperimentId:
      schema:
        $ref: '#/components/schemas/ComparisonExperimentId'
      required: false
      description: The experiment to compare against, if summarizing scores and metrics. If omitted, will fall back to the `base_exp_id` stored in the experiment metadata, and then to the most recent experiment run in the same project. Must pass `summarize_scores=true` for this id to be used
      name: comparison_experiment_id
      in: query
    SummarizeScores:
      schema:
        $ref: '#/components/schemas/SummarizeScores'
      required: false
      description: Whether to summarize the scores and metrics. If false (or omitted), only the metadata will be returned.
      name: summarize_scores
      in: query
    MaxXactId:
      schema:
        $ref: '#/components/schemas/MaxXactId'
      required: false
      description: '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.'
      name: max_xact_id
      in: query
    ProjectIdQuery:
      schema:
        $ref: '#/components/schemas/ProjectIdQuery'
      required: false
      description: Project id
      name: project_id
      in: query
    OrgName:
      schema:
        $ref: '#/components/schemas/OrgName'
      required: false
      description: Filter search results to within a particular organization
      name: org_name
      in: query
      allowReserved: true
    ProjectName:
      schema:
        $ref: '#/components/schemas/ProjectName'
      required: false
      description: Name of the project to search for
      name: project_name
      in: query
      allowReserved: true
    MaxRootSpanId:
      schema:
        $ref: '#/components/schemas/MaxRootSpanId'
      required: false
      description: '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.'
      name: max_root_span_id
      in: query
  schemas:
    MetricSummary:
      type: object
      properties:
        name:
          type: string
          description: Name of the metric
        metric:
          type: number
          description: Average metric across all examples
        unit:
          type: string
          description: Unit label for the metric
        diff:
          type: number
          description: Difference in metric between the current and comparison experiment
        improvements:
          type: integer
          minimum: 0
          description: Number of improvements in the metric
        regressions:
          type: integer
          minimum: 0
          description: Number of regressions in the metric
      required:
      - name
      - metric
      - unit
      - improvements
      - regressions
      description: Summary of a metric's performance
    InsertExperimentEventRequest:
      type: object
      properties:
        events:
          type: array
          items:
            $ref: '#/components/schemas/InsertExperimentEvent'
          description: A list of experiment events to insert
      required:
      - events
    OrgName:
      type: string
      description: Filter search results to within a particular organization
    Experiment:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the experiment
        project_id:
          type: string
          format: uuid
          description: Unique identifier for the project that the experiment belongs under
        name:
          type: string
          description: Name of the experiment. Within a project, experiment names are unique
        description:
          type: string
          nullable: true
          description: Textual description of the experiment
        created:
          type: string
          nullable: true
          format: date-time
          description: Date of experiment creation
        repo_info:
          $ref: '#/components/schemas/RepoInfo'
        commit:
          type: string
          nullable: true
          description: Commit, taken directly from `repo_info.commit`
        base_exp_id:
          type: string
          nullable: true
          format: uuid
          description: Id of default base experiment to compare against when viewing this experiment
        deleted_at:
          type: string
          nullable: true
          format: date-time
          description: Date of experiment deletion, or null if the experiment is still active
        dataset_id:
          type: string
          nullable: true
          format: uuid
          description: Identifier of the linked dataset, or null if the experiment is not linked to a dataset
        dataset_version:
          type: string
          nullable: true
          description: Version number of the linked dataset the experiment was run against. This can be used to reproduce the experiment after the dataset has been modified.
        internal_metadata:
          type: object
          nullable: true
          properties:
            dataset_filter:
              type: object
              nullable: true
              additionalProperties:
                nullable:

# --- truncated at 32 KB (78 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/braintrust/refs/heads/main/openapi/braintrust-experiments-api-openapi.yml