{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Enrich — structure any dataset with your own LLM key",
    "description": "Structure and enrich any dataset with YOUR OWN LLM key (OpenAI, Anthropic or OpenRouter). Define a target JSON schema and an instruction; every item is transformed to match, with JSON repair, retries and per-item error isolation. You control model choice and token cost.",
    "version": "0.1",
    "x-build-id": "lpXTM9JCLeMfIl9kW"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/multiplex~dataset-enrich/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-multiplex-dataset-enrich",
        "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/multiplex~dataset-enrich/runs": {
      "post": {
        "operationId": "runs-sync-multiplex-dataset-enrich",
        "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/multiplex~dataset-enrich/run-sync": {
      "post": {
        "operationId": "run-sync-multiplex-dataset-enrich",
        "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": [
          "instruction",
          "outputSchema",
          "provider",
          "apiKey",
          "model"
        ],
        "properties": {
          "datasetId": {
            "title": "Source dataset ID",
            "type": "string",
            "description": "The Apify dataset to read, e.g. the default dataset of another actor's run. Leave empty and paste rows into `items` instead. Give one or the other, not both."
          },
          "items": {
            "title": "Items (JSON array)",
            "type": "array",
            "description": "Rows to enrich, as a JSON array of objects. Used only when `datasetId` is empty. Handy for a trial run before you point this at a full dataset."
          },
          "instruction": {
            "title": "Instruction",
            "type": "string",
            "description": "What the model should do with each row, in plain English. Be specific about how to derive each field and what to do when a value is missing."
          },
          "outputSchema": {
            "title": "Target output schema (JSON Schema)",
            "type": "object",
            "description": "A JSON Schema describing ONE output row. Every enriched row is produced against it, and its properties become the dataset's columns. Keep it flat and typed for the cleanest CSV/Excel export."
          },
          "provider": {
            "title": "LLM provider",
            "enum": [
              "openai",
              "anthropic",
              "openrouter"
            ],
            "type": "string",
            "description": "Whose API to call. The key you supply below is sent only to this provider, over HTTPS, and is never written to the dataset, the logs or the key-value store.",
            "default": "openai"
          },
          "apiKey": {
            "title": "API key",
            "type": "string",
            "description": "Your own API key for the provider above. Stored encrypted by Apify, held in memory only during the run, and never logged or pushed to any storage. Use a key scoped to this job and rotate it as you would any other."
          },
          "model": {
            "title": "Model",
            "type": "string",
            "description": "The model id exactly as your provider spells it — e.g. `gpt-4o-mini` (OpenAI), `claude-3-5-haiku-latest` (Anthropic), `openai/gpt-4o-mini` (OpenRouter). Model ids change; check your provider's own model list. A small, cheap model is usually plenty for structuring."
          },
          "batchSize": {
            "title": "Items per request",
            "minimum": 1,
            "maximum": 25,
            "type": "integer",
            "description": "How many rows to send in one model call. Larger batches cost fewer tokens overall but risk hitting the model's output limit, which shows up as repaired or failed rows. 1-5 is the safe range.",
            "default": 1
          },
          "concurrency": {
            "title": "Concurrent requests",
            "minimum": 1,
            "maximum": 5,
            "type": "integer",
            "description": "How many model calls to run at once. Capped at 5. Lower it if your provider returns 429s (the actor already backs off and honours Retry-After).",
            "default": 2
          },
          "maxItems": {
            "title": "Max items",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many source rows. 0 = every row. Set it to 10 for a cheap trial run before committing your key to a full dataset.",
            "default": 0
          },
          "includeSourceItem": {
            "title": "Include the original item",
            "type": "boolean",
            "description": "Keep the untouched source row under `_source` on every output row. Off by default so the dataset stays narrow and exports cleanly.",
            "default": false
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}