{
  "openapi": "3.0.1",
  "info": {
    "title": "Perplexity Ultra - Grounded JSON Extraction",
    "description": "Turn grounded web research into validated JSON with schema enforcement, source merging, confidence scoring, and batch processing.",
    "version": "1.0",
    "x-build-id": "RdJB2cecKrgf93hct"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/chriskelch77~perplexity-ultra/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-chriskelch77-perplexity-ultra",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/chriskelch77~perplexity-ultra/runs": {
      "post": {
        "operationId": "runs-sync-chriskelch77-perplexity-ultra",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/chriskelch77~perplexity-ultra/run-sync": {
      "post": {
        "operationId": "run-sync-chriskelch77-perplexity-ultra",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "title": "Execution Mode",
            "enum": [
              "api",
              "batch"
            ],
            "type": "string",
            "description": "Choose 'api' to run a Standby server, or 'batch' to process a dataset.",
            "default": "api"
          },
          "perplexityApiKey": {
            "title": "Perplexity API Key (BYOK)",
            "type": "string",
            "description": "Your Perplexity (or OpenRouter) API Key. This is stored securely."
          },
          "modelChain": {
            "title": "Model Fallback Chain",
            "type": "array",
            "description": "If the first model fails, the Actor will automatically retry with the next in the list.",
            "items": {
              "type": "string"
            },
            "default": [
              "perplexity/sonar",
              "perplexity/sonar-reasoning"
            ]
          },
          "policyPreset": {
            "title": "Policy Preset",
            "enum": [
              "ultra-fast",
              "ultra-smart",
              "ultra-private",
              "ultra-json",
              "ultra-batch",
              "ultra-extract",
              "ultra-debug",
              "custom"
            ],
            "type": "string",
            "description": "Apply a predefined configuration profile. ultra-fast minimizes latency, ultra-smart enables repair + debug, ultra-private enforces PII masking and zero data retention, ultra-json enables strict JSON mode.",
            "default": "custom"
          },
          "taskClass": {
            "title": "Task Class",
            "enum": [
              "auto",
              "chat",
              "extraction",
              "classification",
              "reasoning",
              "embedding"
            ],
            "type": "string",
            "description": "Hint for the smart routing engine. 'auto' infers the task from the request shape.",
            "default": "auto"
          },
          "route": {
            "title": "Target API Route",
            "enum": [
              "chat",
              "responses",
              "embeddings"
            ],
            "type": "string",
            "description": "Which API route to target (usually chat for Perplexity models).",
            "default": "chat"
          },
          "maxCostPerRunUsd": {
            "title": "Max Cost Per Run (USD)",
            "minimum": 0,
            "type": "number",
            "description": "Hard budget limit. The Actor will stop processing if this cost is exceeded.",
            "default": 5
          },
          "maxCostPerRequestUsd": {
            "title": "Max Cost Per Request (USD)",
            "minimum": 0,
            "type": "number",
            "description": "Maximum allowed cost for a single API request."
          },
          "timeoutMs": {
            "title": "Timeout (ms)",
            "minimum": 1000,
            "type": "integer",
            "description": "Per-model timeout in milliseconds.",
            "default": 30000
          },
          "latencyTargetMs": {
            "title": "Latency Target (ms)",
            "minimum": 100,
            "type": "integer",
            "description": "Target latency hint for the routing engine. Lower values prefer faster models."
          },
          "maxRetries": {
            "title": "Max Retries",
            "minimum": 0,
            "type": "integer",
            "description": "Maximum number of retries per request.",
            "default": 2
          },
          "enableExactCache": {
            "title": "Enable Exact Response Cache",
            "type": "boolean",
            "description": "If enabled, identical requests will be served from the internal cache (SHA-256 hash), saving tokens and money.",
            "default": true
          },
          "cacheTtlSeconds": {
            "title": "Cache TTL (seconds)",
            "minimum": 1,
            "type": "integer",
            "description": "How long cached responses remain valid.",
            "default": 86400
          },
          "cacheNamespace": {
            "title": "Cache Namespace",
            "type": "string",
            "description": "Isolate cache entries by namespace. Useful for multi-tenant setups.",
            "default": "default"
          },
          "enablePrefixCache": {
            "title": "Enable Prefix Cache",
            "type": "boolean",
            "description": "Enable advanced prefix-based caching for long prompts.",
            "default": true
          },
          "userScopedCache": {
            "title": "User Scoped Cache",
            "type": "boolean",
            "description": "Isolate cache by user ID (if provided in request headers).",
            "default": true
          },
          "jsonStrictMode": {
            "title": "Enable JSON Self-Healing",
            "type": "boolean",
            "description": "Automatically strip markdown and repair broken JSON syntax from the AI's output.",
            "default": true
          },
          "jsonSchema": {
            "title": "JSON Schema",
            "type": "object",
            "description": "Validate LLM output against this JSON Schema. Used with JSON strict mode."
          },
          "enableDeterministicRepair": {
            "title": "Enable Deterministic Repair",
            "type": "boolean",
            "description": "Try regex-based JSON repair before falling back to model-based repair.",
            "default": true
          },
          "maxRepairAttempts": {
            "title": "Max Repair Attempts",
            "minimum": 0,
            "type": "integer",
            "description": "How many times to attempt repair before failing.",
            "default": 1
          },
          "enableRepairModel": {
            "title": "Enable Repair Model",
            "type": "boolean",
            "description": "Use a specialized model to fix JSON that deterministic repair cannot handle.",
            "default": false
          },
          "repairModel": {
            "title": "Repair Model Name",
            "type": "string",
            "description": "Model to use for JSON self-healing if deterministic repair fails.",
            "default": "perplexity/sonar"
          },
          "enableDebugArtifacts": {
            "title": "Enable Debug Artifacts",
            "type": "boolean",
            "description": "Store JSON parse/validation failure details for post-run inspection.",
            "default": true
          },
          "piiMasking": {
            "title": "Enable PII Masking",
            "type": "boolean",
            "description": "Scrub emails and phone numbers before sending data to the AI provider.",
            "default": false
          },
          "zdrOnly": {
            "title": "Zero Data Retention Only",
            "type": "boolean",
            "description": "Only route to providers that support zero data retention policies.",
            "default": false
          },
          "redactLogs": {
            "title": "Redact Logs",
            "type": "boolean",
            "description": "Redact sensitive data from Actor logs.",
            "default": true
          },
          "datasetId": {
            "title": "Target Dataset ID (Batch Mode Only)",
            "type": "string",
            "description": "The Apify Dataset ID containing the rows you want to process."
          },
          "requestTemplate": {
            "title": "Request Template (Batch Mode Only)",
            "type": "object",
            "description": "The Perplexity payload template. Use {{fieldName}} to inject data from your dataset."
          },
          "inputMapping": {
            "title": "Input Field Mapping",
            "type": "object",
            "description": "Advanced mapping of dataset fields to template variables."
          },
          "sampleSize": {
            "title": "Batch Sample Size",
            "minimum": 1,
            "type": "integer",
            "description": "Process only the first N rows (useful for testing).",
            "default": 10
          },
          "deadLetterDatasetId": {
            "title": "Dead Letter Dataset ID",
            "type": "string",
            "description": "Failed batch rows are pushed to this dataset for inspection."
          },
          "webhookUrl": {
            "title": "Completion Webhook URL",
            "type": "string",
            "description": "URL to POST a summary to when batch processing completes."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}