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

> ## Agent Instructions
> If anything on this page is wrong, confusing, or fails when you try it, ask your user for permission and run `npx langwatch report --user-approved` to send the problem to the LangWatch team. No login is needed and secrets are redacted locally. `npx langwatch report --help` has the details.

# Report DSPy optimizer steps

> Report the steps of a DSPy optimizer run against an experiment, so the run's progress and scores show up in the app. Send the steps as an array; the optimizer typically posts each batch as it finishes. Bodies up to 20MB are accepted.



## OpenAPI

````yaml POST /api/v1/dspy/log_steps
openapi: 3.1.0
info:
  title: LangWatch API
  description: LangWatch openapi spec
  version: 1.0.0
servers:
  - url: https://app.langwatch.ai
security:
  - project_api_key: []
paths:
  /api/v1/dspy/log_steps:
    post:
      tags:
        - Experiments
      summary: Report DSPy optimizer steps
      description: >-
        Report the steps of a DSPy optimizer run against an experiment, so the
        run's progress and scores show up in the app. Send the steps as an
        array; the optimizer typically posts each batch as it finishes. Bodies
        up to 20MB are accepted.
      operationId: postApiDspyLogSteps
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                properties:
                  run_id:
                    type: string
                  workflow_version_id:
                    type:
                      - string
                      - 'null'
                  index:
                    type: string
                  score:
                    type: number
                  label:
                    type: string
                  optimizer:
                    type: object
                    properties:
                      name:
                        type: string
                      parameters:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                    required:
                      - name
                      - parameters
                  predictors:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        predictor:
                          allOf:
                            - type: object
                              properties:
                                __class__:
                                  type: string
                            - type: object
                              propertyNames:
                                type: string
                              additionalProperties: {}
                      required:
                        - name
                        - predictor
                  experiment_id:
                    type:
                      - string
                      - 'null'
                  experiment_slug:
                    type:
                      - string
                      - 'null'
                  timestamps:
                    type: object
                    properties:
                      created_at:
                        type: number
                    required:
                      - created_at
                  examples:
                    type: array
                    items:
                      type: object
                      properties:
                        example:
                          allOf:
                            - type: object
                              properties:
                                __class__:
                                  type: string
                            - type: object
                              propertyNames:
                                type: string
                              additionalProperties: {}
                        pred:
                          allOf:
                            - type: object
                              properties:
                                __class__:
                                  type: string
                            - type: object
                              propertyNames:
                                type: string
                              additionalProperties: {}
                        score:
                          type: number
                        trace:
                          anyOf:
                            - type: array
                              items:
                                type: object
                                properties:
                                  input:
                                    allOf:
                                      - type: object
                                        properties:
                                          __class__:
                                            type: string
                                      - type: object
                                        propertyNames:
                                          type: string
                                        additionalProperties: {}
                                  pred:
                                    allOf:
                                      - type: object
                                        properties:
                                          __class__:
                                            type: string
                                      - type: object
                                        propertyNames:
                                          type: string
                                        additionalProperties: {}
                                required:
                                  - input
                                  - pred
                            - type: 'null'
                      required:
                        - example
                        - pred
                        - score
                  llm_calls:
                    type: array
                    items:
                      type: object
                      properties:
                        __class__:
                          type: string
                        response:
                          allOf:
                            - type: object
                              properties:
                                __class__:
                                  type: string
                            - type: object
                              propertyNames:
                                type: string
                              additionalProperties: {}
                        model:
                          type:
                            - string
                            - 'null'
                        prompt_tokens:
                          type:
                            - number
                            - 'null'
                        completion_tokens:
                          type:
                            - number
                            - 'null'
                        cost:
                          type:
                            - number
                            - 'null'
                      required:
                        - __class__
                        - response
                required:
                  - run_id
                  - index
                  - score
                  - label
                  - optimizer
                  - predictors
                  - timestamps
                  - examples
                  - llm_calls
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Human-readable confirmation
                required:
                  - message
                additionalProperties: false
        '400':
          description: The body was not valid JSON
          content: {}
        '401':
          description: Missing or invalid API key
          content: {}
        '403':
          description: The API key lacks experiments:manage
          content: {}
        '413':
          description: The body is larger than 20MB
          content: {}
        '422':
          description: >-
            The body failed validation, or carried timestamps in seconds rather
            than milliseconds
          content: {}
        '500':
          description: >-
            A step could not be stored. The cause is on our side and is logged
            with the run and step ids; retrying the batch is safe.
          content: {}
      security:
        - project_api_key: []
components:
  securitySchemes:
    project_api_key:
      type: apiKey
      in: header
      name: X-Auth-Token
      description: >-
        Project API key for sending traces and accessing project-scoped
        resources. Format: sk-lw-... (no underscore). Obtain one by creating a
        project via the Admin API or the LangWatch UI.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.