> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getbasalt.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Trace

> Create a trace



## OpenAPI

````yaml POST /monitor/trace
openapi: 3.1.0
info:
  title: Basalt API
  description: Basalt API
  version: 0.2.1
servers:
  - url: https://api.getbasalt.ai
    description: Basalt Endpoint API
security:
  - bearerAuth: []
paths:
  /monitor/trace:
    post:
      summary: Create a trace
      description: Create a trace
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type:
                    - string
                    - 'null'
                  description: The name of the trace
                  example: qa-chatbot
                featureSlug:
                  type: string
                  description: The slug of the feature in Basalt.
                  example: qa-chatbot
                chainSlug:
                  type: string
                  description: >-
                    Deprecated: Use featureSlug instead. The slug of the feature
                    in Basalt.
                  example: qa-chatbot
                  deprecated: true
                input:
                  anyOf:
                    - type: string
                    - type: object
                      additionalProperties: {}
                    - type: array
                      items: {}
                    - type: 'null'
                  description: The input of the trace
                  example: What is the capital of France?
                output:
                  anyOf:
                    - type: string
                    - type: object
                      additionalProperties: {}
                    - type: array
                      items: {}
                    - type: 'null'
                  description: The output of the trace
                  example: Paris
                idealOutput:
                  anyOf:
                    - type: string
                    - type: object
                      additionalProperties: {}
                    - type: array
                      items: {}
                    - type: 'null'
                  description: The ideal output of the trace. Used in some evaluators.
                metadata:
                  type:
                    - object
                    - 'null'
                  additionalProperties: {}
                  description: Additional metadata to be associated with the trace.
                  example:
                    sessionId: '456'
                    userType: admin
                organization:
                  type:
                    - object
                    - 'null'
                  properties:
                    id:
                      type: string
                      description: A unique identifier for the organization
                    name:
                      type: string
                      description: The name of the organization
                  required:
                    - id
                    - name
                  description: >-
                    The organization related to the trace. Used to identify the
                    organization of the user that triggered the trace.
                  example:
                    id: '123'
                    name: ACME
                user:
                  type:
                    - object
                    - 'null'
                  properties:
                    id:
                      type: string
                      description: A unique identifier for the user
                    name:
                      type: string
                      description: The name of the user
                  required:
                    - id
                    - name
                  description: >-
                    The user related to the trace. Used to identify the user
                    that triggered the trace.
                  example:
                    id: '123'
                    name: John Doe
                startTime:
                  anyOf:
                    - type: string
                    - type: number
                      exclusiveMinimum: 0
                    - type: 'null'
                  description: The start time of the trace
                  example: '2021-01-01T00:00:00Z'
                endTime:
                  anyOf:
                    - type: string
                    - type: number
                      exclusiveMinimum: 0
                    - type: 'null'
                  description: The end time of the trace
                  example: '2021-01-01T00:00:00Z'
                experiment:
                  type:
                    - object
                    - 'null'
                  properties:
                    id:
                      type: string
                  required:
                    - id
                  description: >-
                    The experiment to append the trace to. You must create an
                    experiment before.
                  example:
                    id: '123'
                logs:
                  type:
                    - array
                    - 'null'
                  items:
                    anyOf:
                      - type: object
                        properties:
                          id:
                            type: string
                            description: A unique identifier for the log
                            example: log-123
                          type:
                            type: string
                            enum:
                              - span
                              - function
                              - tool
                              - retrieval
                              - event
                            description: The type of log
                            example: span
                          name:
                            type:
                              - string
                              - 'null'
                            description: The name of the log
                            example: retrieval
                          startTime:
                            anyOf:
                              - type: string
                              - type: number
                                exclusiveMinimum: 0
                              - type: 'null'
                            description: The start time of the log
                            example: '2021-01-01T00:00:00Z'
                          endTime:
                            anyOf:
                              - type: string
                              - type: number
                                exclusiveMinimum: 0
                              - type: 'null'
                            description: The end time of the log
                            example: '2021-01-01T00:00:00Z'
                          metadata:
                            type:
                              - object
                              - 'null'
                            additionalProperties: {}
                            description: The metadata of the log
                            example:
                              sessionId: '456'
                          parentId:
                            type:
                              - string
                              - 'null'
                            description: >-
                              The parent ID of the log. Used to nest logs in a
                              hierarchical structure.
                            example: parent-123
                          input:
                            anyOf:
                              - type: string
                              - type: object
                                additionalProperties: {}
                              - type: array
                                items: {}
                              - type: 'null'
                            description: The input of the log
                            example: What is the capital of France?
                          output:
                            anyOf:
                              - type: string
                              - type: object
                                additionalProperties: {}
                              - type: array
                                items: {}
                              - type: 'null'
                            description: The output of the log
                            example: Paris
                          idealOutput:
                            anyOf:
                              - type: string
                              - type: object
                                additionalProperties: {}
                              - type: array
                                items: {}
                              - type: 'null'
                            description: >-
                              The ideal output of the log. Used in some
                              evaluators.
                          evaluators:
                            type:
                              - array
                              - 'null'
                            items:
                              type: object
                              properties:
                                slug:
                                  type: string
                                  description: The slug of the evaluator in Basalt.
                                  example: hallucination
                              required:
                                - slug
                            example:
                              - slug: hallucination
                        required:
                          - id
                          - type
                      - type: object
                        properties:
                          id:
                            type: string
                            description: A unique identifier for the log
                            example: log-123
                          type:
                            type: string
                            enum:
                              - generation
                            description: The type of log
                            example: generation
                          name:
                            type:
                              - string
                              - 'null'
                            description: The name of the log
                            example: retrieval
                          startTime:
                            anyOf:
                              - type: string
                              - type: number
                                exclusiveMinimum: 0
                              - type: 'null'
                            description: The start time of the log
                            example: '2021-01-01T00:00:00Z'
                          endTime:
                            anyOf:
                              - type: string
                              - type: number
                                exclusiveMinimum: 0
                              - type: 'null'
                            description: The end time of the log
                            example: '2021-01-01T00:00:00Z'
                          metadata:
                            type:
                              - object
                              - 'null'
                            additionalProperties: {}
                            description: The metadata of the log
                            example:
                              sessionId: '456'
                          parentId:
                            type:
                              - string
                              - 'null'
                            description: >-
                              The parent ID of the log. Used to nest logs in a
                              hierarchical structure.
                            example: parent-123
                          input:
                            anyOf:
                              - type: string
                              - type: object
                                additionalProperties: {}
                              - type: array
                                items: {}
                              - type: 'null'
                            description: The input of the log
                            example: What is the capital of France?
                          output:
                            anyOf:
                              - type: string
                              - type: object
                                additionalProperties: {}
                              - type: array
                                items: {}
                              - type: 'null'
                            description: The output of the log
                            example: Paris
                          idealOutput:
                            anyOf:
                              - type: string
                              - type: object
                                additionalProperties: {}
                              - type: array
                                items: {}
                              - type: 'null'
                            description: >-
                              The ideal output of the log. Used in some
                              evaluators.
                          inputTokens:
                            type:
                              - number
                              - 'null'
                            description: >-
                              The number of input tokens. If not provided, it
                              will be computed based on the input
                            example: 100
                          outputTokens:
                            type:
                              - number
                              - 'null'
                            description: >-
                              The number of output tokens. If not provided, it
                              will be computed based on the output
                            example: 100
                          cost:
                            type:
                              - number
                              - 'null'
                            example: 100
                          variables:
                            type:
                              - array
                              - 'null'
                            items:
                              type: object
                              properties:
                                label:
                                  type: string
                                value:
                                  type:
                                    - string
                                    - 'null'
                              required:
                                - label
                            example:
                              - label: question
                                value: What is the capital of France?
                          prompt:
                            type:
                              - object
                              - 'null'
                            properties:
                              slug:
                                type: string
                              version:
                                type:
                                  - string
                                  - 'null'
                              tag:
                                type:
                                  - string
                                  - 'null'
                            required:
                              - slug
                            example:
                              slug: qa-prompt
                              version: 1.0.0
                              tag: production
                          evaluators:
                            type:
                              - array
                              - 'null'
                            items:
                              type: object
                              properties:
                                slug:
                                  type: string
                                  description: The slug of the evaluator in Basalt.
                                  example: hallucination
                              required:
                                - slug
                            example:
                              - slug: hallucination
                        required:
                          - id
                          - type
                  description: The logs to append to the trace.
                  example:
                    - id: '123'
                      type: generation
                      name: qa-chatbot
                      startTime: '2021-01-01T00:00:00Z'
                      endTime: '2021-01-01T00:00:00Z'
                      metadata:
                        sessionId: '456'
                        userType: admin
                evaluators:
                  type:
                    - array
                    - 'null'
                  items:
                    type: object
                    properties:
                      slug:
                        type: string
                        description: The slug of the evaluator in Basalt.
                        example: hallucination
                    required:
                      - slug
                  description: The evaluators used to generate the trace.
                  example:
                    - slug: hallucination
                evaluationConfig:
                  type:
                    - object
                    - 'null'
                  properties:
                    sampleRate:
                      type:
                        - number
                        - 'null'
                      minimum: 0
                      maximum: 1
                      description: >-
                        The sample rate of the trace. If not provided, it will
                        be computed based on the evaluators.
                      example: 0.5
                  description: The evaluation configuration of the trace.
                  example:
                    sampleRate: 0.5
      responses:
        '200':
          description: The trace created
          content:
            application/json:
              schema:
                type: object
                properties:
                  trace:
                    type: object
                    properties:
                      id:
                        type: string
                    required:
                      - id
                    description: The trace created
                    example:
                      id: '123'
                  warning:
                    type:
                      - string
                      - 'null'
                    description: The warning message
                    example: >-
                      No prompt found with the given slug or no production
                      version found or no prompt found with the given version or
                      tag (production version also missing)
                required:
                  - trace
        '400':
          description: Bad Request - Invalid query parameters
        '404':
          description: Not found - No feature found for the given slug
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````