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

# Compile Prompt

> Compiles a prompt by replacing variable placeholders ({VAR} or {{VAR}}) with the provided values. Returns the prompt with all variables substituted.



## OpenAPI

````yaml POST /v1/studio/prompts/{promptId}/compile
openapi: 3.0.3
info:
  title: Qualifire AI API
  description: API for Qualifire AI services, including evaluation and prompt management.
  version: 1.0.0
servers:
  - url: https://api.qualifire.ai/api
security:
  - ApiKeyAuth: []
paths:
  /v1/studio/prompts/{promptId}/compile:
    post:
      tags:
        - Studio
      summary: Compile a prompt
      description: >-
        Compiles a prompt by replacing variable placeholders ({VAR} or {{VAR}})
        with the provided values. Returns the prompt with all variables
        substituted.
      parameters:
        - name: promptId
          in: path
          description: Prompt ID (cuid) or textId (deprecated)
          required: true
          schema:
            type: string
        - name: revision
          in: query
          description: Revision ID (cuid) - preferred method
          schema:
            type: string
        - name: revisionNumber
          in: query
          description: Revision number (deprecated, use revision instead)
          deprecated: true
          schema:
            type: string
      requestBody:
        description: Variables to substitute in the prompt
        content:
          application/json:
            schema:
              type: object
              required:
                - variables
              properties:
                variables:
                  type: object
                  additionalProperties:
                    type: string
                  description: Key-value map of variable names to their values
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/models.CompiledPrompt'
        '400':
          description: Bad Request - missing required variables
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                  - missing_variables
                properties:
                  error:
                    type: string
                  missing_variables:
                    type: array
                    items:
                      type: string
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/models.Error'
        '404':
          description: Prompt not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/models.Error'
components:
  schemas:
    models.CompiledPrompt:
      type: object
      required:
        - id
        - name
        - revision
        - messages
        - tools
        - parameters
      properties:
        id:
          type: string
        name:
          type: string
          nullable: true
        revision:
          type: integer
        messages:
          type: array
          items:
            type: object
            required:
              - role
              - content
            properties:
              role:
                type: string
              content:
                type: string
                description: Fully compiled content with variables substituted
        tools:
          type: array
          items:
            $ref: '#/components/schemas/models.ToolResponse'
        parameters:
          type: object
          additionalProperties: true
    models.Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: A human-readable error message
          example: Invalid API key
    models.ToolResponse:
      type: object
      required:
        - type
        - function
      properties:
        type:
          type: string
        function:
          type: object
          required:
            - name
          properties:
            name:
              type: string
            description:
              type: string
            parameters:
              type: object
              additionalProperties: true
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Qualifire-API-Key

````