{
  "openapi": "3.0.1",
  "info": {
    "title": "LLM Dataset Processor — AI Enrich Any Dataset (BYOK)",
    "description": "Run one LLM prompt on every row of an Apify dataset — classify, extract structured JSON, score, translate or rewrite scraped data. Bring your own OpenAI, Anthropic, Groq or Gemini API key; pay only a small per-row processing fee.",
    "version": "0.1",
    "x-build-id": "EG0OimsDtHUPxNxwH"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/glueworks~llm-dataset-processor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-glueworks-llm-dataset-processor",
        "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/glueworks~llm-dataset-processor/runs": {
      "post": {
        "operationId": "runs-sync-glueworks-llm-dataset-processor",
        "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/glueworks~llm-dataset-processor/run-sync": {
      "post": {
        "operationId": "run-sync-glueworks-llm-dataset-processor",
        "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",
        "properties": {
          "datasetId": {
            "title": "Dataset ID",
            "type": "string",
            "description": "ID or name of the Apify dataset to process (the output of any scraper run). Leave EMPTY (together with inlineItems) to run a demo on built-in sample data with a mock model — no API key needed."
          },
          "inlineItems": {
            "title": "Inline items (alternative to datasetId)",
            "type": "array",
            "description": "Array of JSON objects to process instead of a dataset — handy for testing or small ad-hoc jobs. If both inlineItems and datasetId are set, inlineItems wins.",
            "default": []
          },
          "prompt": {
            "title": "Prompt template",
            "type": "string",
            "description": "The prompt run for EVERY row. Insert row values with {{field}} placeholders (dot-notation for nested fields, e.g. {{seller.name}}; {{_json}} inserts the whole row as JSON). Example: \"Classify the sentiment of this review: {{review_text}}\""
          },
          "mode": {
            "title": "Mode",
            "enum": [
              "classify",
              "extract",
              "score",
              "rewrite",
              "custom"
            ],
            "type": "string",
            "description": "Shapes the output contract and parsing. classify → single label string; extract → parsed JSON object (uses outputSchema); score → number; rewrite → plain text; custom → raw model reply, no added instructions.",
            "default": "custom"
          },
          "outputSchema": {
            "title": "Output JSON schema (extract mode)",
            "type": "object",
            "description": "Optional JSON schema the extracted object must conform to (embedded into the system prompt; JSON mode is also enabled on providers that support it)."
          },
          "provider": {
            "title": "LLM provider",
            "enum": [
              "openai",
              "anthropic",
              "groq",
              "gemini"
            ],
            "type": "string",
            "description": "Which API your key belongs to. All calls go directly from this Actor to the provider — your key is never sent anywhere else.",
            "default": "openai"
          },
          "apiKey": {
            "title": "API key",
            "type": "string",
            "description": "YOUR API key for the selected provider (stored encrypted). Token costs are billed by your provider directly to you. Leave empty to run the free demo with a mock model."
          },
          "model": {
            "title": "Model",
            "type": "string",
            "description": "Model name as the provider expects it (free text — new models work without an Actor update). Empty = provider default: gpt-4o-mini / claude-3-5-haiku-latest / llama-3.1-8b-instant / gemini-2.0-flash.",
            "default": ""
          },
          "systemPrompt": {
            "title": "System prompt",
            "type": "string",
            "description": "Optional extra system instructions prepended before the mode's output contract (e.g. \"You are an expert e-commerce analyst. Answer in German.\").",
            "default": ""
          },
          "temperature": {
            "title": "Temperature",
            "minimum": 0,
            "maximum": 2,
            "type": "integer",
            "description": "Sampling temperature 0–2 (integer; use 0 for deterministic classification/extraction — the default).",
            "default": 0
          },
          "concurrency": {
            "title": "Concurrency",
            "minimum": 1,
            "maximum": 25,
            "type": "integer",
            "description": "Parallel LLM requests. Keep low (default 4) to stay inside your provider's rate limits — 429s are retried with backoff, but lower concurrency finishes faster than a retry storm.",
            "default": 4
          },
          "maxItems": {
            "title": "Max items",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Hard cap on rows processed per run (default 1000) — protects your API bill if you point this at a huge dataset by accident. Raise it deliberately for big jobs.",
            "default": 1000
          },
          "maxInputTokensPerItem": {
            "title": "Max input tokens per row",
            "minimum": 100,
            "maximum": 200000,
            "type": "integer",
            "description": "Rendered prompts longer than this (rough estimate, ~4 chars/token) are truncated with an '...[input truncated]' marker instead of failing or burning tokens. Default 4000.",
            "default": 4000
          },
          "maxOutputTokens": {
            "title": "Max output tokens per row",
            "minimum": 1,
            "maximum": 32000,
            "type": "integer",
            "description": "Response length limit passed to the provider. Default 512 — plenty for labels/JSON, raise for long rewrites.",
            "default": 512
          },
          "skipOnError": {
            "title": "Skip failed rows",
            "type": "boolean",
            "description": "ON (default): a failing row gets an 'error' field and the run continues — one bad row never kills the job. OFF: abort the run on the first failed row.",
            "default": true
          },
          "injectionDefense": {
            "title": "Prompt-injection defense",
            "type": "boolean",
            "description": "ON (default): each row's field values (untrusted, usually scraped) are fenced in per-run delimiters and the model is told to treat them as DATA, not instructions — so a review saying 'ignore previous instructions' can't hijack your task. In extract mode the output is also pruned to your outputSchema. Turn OFF only if your rows are fully trusted and you need the raw prompt verbatim.",
            "default": true
          },
          "datamarking": {
            "title": "Datamarking (spotlighting)",
            "type": "boolean",
            "description": "Optional extra defense: interleave a marker character through untrusted data so injected instructions are harder for the model to parse as commands. OFF by default — it can slightly reduce extraction/rewrite fidelity. Only takes effect when injectionDefense is ON.",
            "default": false
          },
          "outputField": {
            "title": "Output field name",
            "type": "string",
            "description": "Field on each output record that holds the parsed model output. Default: llm_output.",
            "default": "llm_output"
          },
          "outputDatasetName": {
            "title": "Output dataset name",
            "type": "string",
            "description": "Optional name for the output (named) dataset. If empty, results go to the run's default dataset. Pushing to an existing named dataset appends to it.",
            "default": ""
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}