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

# Create Trace

> Use this endpoint to create a trace.



## OpenAPI

````yaml POST /api/v1/traces
openapi: 3.1.0
info:
  version: 0.0.1
  title: Prem Studio API
  description: Studio autofinetuning agent API
servers:
  - url: http://studio.premai.io
    description: Current environment
  - url: https://studio.premai.io
    description: Production server
security:
  - bearerAuth: []
paths:
  /api/v1/traces:
    post:
      tags:
        - Traces
      description: Create traces with feedback
      operationId: traces.create
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/TraceCreateRequest'
      responses:
        '200':
          description: success response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraceCreateResponse'
        '400':
          description: bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: unauthenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    TraceCreateRequest:
      type: object
      properties:
        modelId:
          type: string
          minLength: 1
          description: Identifier (or alias) for the model that produced the trace.
        projectId:
          type: string
          format: uuid
          description: >-
            Project identifier that groups this trace. Leave empty to keep it
            unassigned.
        input:
          type: string
          minLength: 1
          description: Prompt or message provided to the model.
        output:
          type: string
          minLength: 1
          description: Model response captured for the trace.
        score:
          type: number
          minimum: 0
          maximum: 1
          description: Evaluator score used to determine if the trace is positive.
        feedback:
          type: string
          nullable: true
          maxLength: 2048
          description: Optional feedback explaining the score or providing guidance.
      required:
        - modelId
        - input
        - output
        - score
    TraceCreateResponse:
      type: object
      properties:
        results:
          type: array
          items:
            $ref: '#/components/schemas/TraceCreateResult'
          description: One entry per trace provided in the request.
      required:
        - results
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
      required:
        - error
    TraceCreateResult:
      type: object
      properties:
        traceId:
          type: string
          format: uuid
          description: Identifier of the newly created trace.
        success:
          type: boolean
          description: Whether the trace was persisted successfully.
      required:
        - traceId
        - success
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````