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

# Diff Prompt Versions

> Compares the templates of two prompt versions side-by-side and returns a unified diff. Requires read access to the prompt.



## OpenAPI

````yaml /openapi.yaml get /v1/prompts/{id}/versions/diff
openapi: 3.1.0
info:
  title: px0 API
  description: >
    px[0] is an open-source prompt infrastructure toolkit for managing prompts
    in production. It replaces hardcoded prompt strings with versioned
    templates, in-process caching, and OpenTelemetry observability, so teams can
    iterate on prompts without touching application code. This is the OpenAPI
    specification for all the public APIs of px0.
  version: 1.0.0
servers:
  - url: http://localhost:3000
    description: Local development server
security: []
paths:
  /v1/prompts/{id}/versions/diff:
    get:
      tags:
        - Prompt Versions
      summary: Diff Prompt Versions
      description: >-
        Compares the templates of two prompt versions side-by-side and returns a
        unified diff. Requires read access to the prompt.
      operationId: diffVersions
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: from
          in: query
          required: true
          schema:
            type: integer
          description: The source version number to compare from.
        - name: to
          in: query
          required: true
          schema:
            type: integer
          description: The target version number to compare to.
      responses:
        '200':
          description: Versions compared successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  from_version:
                    type: integer
                    example: 1
                  to_version:
                    type: integer
                    example: 2
                  from_template:
                    type: string
                    example: Hello {{ .name }}
                  to_template:
                    type: string
                    example: |-
                      Hello {{ .name }}!
                      Welcome to px0.
                  diff:
                    type: string
                    example: |
                      --- v1
                      +++ v2
                      @@ -1 +1,2 @@
                      -Hello {{ .name }}
                      +Hello {{ .name }}!
                      +Welcome to px0.
                required:
                  - from_version
                  - to_version
                  - from_template
                  - to_template
                  - diff
        '400':
          description: Missing or invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
        '404':
          description: Prompt or version not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
      security:
        - BearerAuth: []
components:
  schemas:
    APIError:
      type: object
      properties:
        error:
          type: string
          example: invalid credentials
      required:
        - error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Use an access token retrieved from login (Bearer sess_...) or a
        programmatic API key (Bearer ak_...).

````