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

# Create trace

> Create a new trace for a tool/function call. See [Traces](https://docs.galtea.ai/sdk/api/trace/service).



## OpenAPI

````yaml https://api.galtea.ai/openapi.json post /traces
openapi: 3.0.0
info:
  version: 1.0.0
  title: Product Management Service API
  description: API documentation for Product Management Service
  contact:
    name: Galtea AI
servers:
  - url: https://api.galtea.ai
security:
  - bearerAuth: []
tags: []
externalDocs:
  description: Galtea Platform Documentation
  url: https://docs.galtea.ai
paths:
  /traces:
    post:
      tags:
        - traces
      summary: Create trace
      description: >-
        Create a new trace for a tool/function call. See
        [Traces](https://docs.galtea.ai/sdk/api/trace/service).
      operationId: createTrace
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - inferenceResultId
                - name
              properties:
                inferenceResultId:
                  type: string
                  example: ir_123
                name:
                  type: string
                  example: Example Name
                type:
                  type: string
                  enum:
                    - SPAN
                    - GENERATION
                    - EVENT
                    - AGENT
                    - TOOL
                    - CHAIN
                    - RETRIEVER
                    - EVALUATOR
                    - EMBEDDING
                    - GUARDRAIL
                inputData:
                  type: object
                outputData:
                  type: object
                error:
                  type: string
                  example: Error message
                latencyMs:
                  type: number
                metadata:
                  type: object
      responses:
        '200':
          description: Trace created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Trace'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearerAuth: []
components:
  schemas:
    Trace:
      type: object
      properties:
        id:
          type: string
          example: trace_123
        inferenceResultId:
          type: string
          example: ir_123
        name:
          type: string
          example: fetch_user_data
        type:
          type: string
          enum:
            - SPAN
            - GENERATION
            - EVENT
            - AGENT
            - TOOL
            - CHAIN
            - RETRIEVER
            - EVALUATOR
            - EMBEDDING
            - GUARDRAIL
          nullable: true
          example: TOOL
        description:
          type: string
          nullable: true
          example: Fetches user data from the database by ID
          description: Human-readable description of the operation. Maximum 1MB.
        inputData:
          type: object
          nullable: true
          example:
            user_id: '123'
          description: Input parameters passed to the operation
        outputData:
          type: object
          nullable: true
          example:
            name: John Doe
            email: john@example.com
          description: Result returned by the operation
        error:
          type: string
          nullable: true
          example: Connection timeout
          description: Error message if failed
        latencyMs:
          type: number
          nullable: true
          example: 45.5
          description: Execution time in milliseconds
        metadata:
          type: object
          nullable: true
          example:
            model: gpt-4
            temperature: 0.7
          description: Additional custom metadata
        parentTraceId:
          type: string
          nullable: true
          example: trace_parent_123
          description: ID of parent trace for hierarchical relationships
        startTime:
          type: string
          format: date-time
          nullable: true
        endTime:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
        deletedAt:
          type: string
          format: date-time
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: string
          example: Error type
        message:
          type: string
          example: Error message description
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authorization. Pass your API key in the Authorization header as
        a Bearer token. Both new (`gsk_*`) and legacy (`gsk-`) API keys are
        accepted, e.g. `Authorization: Bearer gsk_...` or `Authorization: Bearer
        gsk-...`.

````