{
  "openapi": "3.0.1",
  "info": {
    "title": "Dataset Cost Estimator — LLM Embedding Budget",
    "description": "Estimate USD token costs for an Apify dataset before RAG upsert. Compare chat & embedding models; optional fail-if-over-budget. No LLM API keys.",
    "version": "0.1",
    "x-build-id": "zzx9FjV23xacXwinH"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/fg-ei~dataset-llm-cost-estimator/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-fg-ei-dataset-llm-cost-estimator",
        "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/fg-ei~dataset-llm-cost-estimator/runs": {
      "post": {
        "operationId": "runs-sync-fg-ei-dataset-llm-cost-estimator",
        "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/fg-ei~dataset-llm-cost-estimator/run-sync": {
      "post": {
        "operationId": "run-sync-fg-ei-dataset-llm-cost-estimator",
        "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": {
          "reportName": {
            "title": "Report name",
            "type": "string",
            "description": "Friendly label shown in the Markdown REPORT and in the summary row (reportName).",
            "default": "Dataset LLM cost estimate"
          },
          "items": {
            "title": "Inline JSON items",
            "type": "array",
            "description": "Paste rows here for quick tests (max 5,000 rows). Each object should contain text fields such as text or markdown. Mutually exclusive with Apify Dataset ID: clear this field before using a dataset."
          },
          "datasetId": {
            "title": "Apify Dataset ID",
            "type": "string",
            "description": "ID (or name) of an existing Apify dataset you own, for example the default dataset of a Website Content Crawler run (open the run and copy its dataset ID). Read-only access is requested for this dataset only. Clear Inline JSON items when using this field."
          },
          "allowRemoteFetch": {
            "title": "Allow remote dataset fetch",
            "type": "boolean",
            "description": "Must be enabled to read a dataset via Apify Dataset ID. Ignored for Inline JSON items.",
            "default": true
          },
          "textFields": {
            "title": "Billable text fields",
            "type": "array",
            "description": "Field names whose values are concatenated as billable text for each row. Defaults cover common crawler outputs: text, markdown, content, body, pageContent, description.",
            "default": [
              "text",
              "markdown",
              "content",
              "body",
              "pageContent",
              "description"
            ],
            "items": {
              "type": "string"
            }
          },
          "chatModels": {
            "title": "Chat / completion models",
            "type": "array",
            "description": "Model IDs to price. Empty = defaults (gpt-4o-mini, gpt-4o, claude-haiku-4.5, gemini-2.0-flash). Supported: gpt-4o-mini, gpt-4o, gpt-4.1-mini, claude-haiku-4.5, claude-sonnet-4.6, gemini-2.0-flash, llama-3.3-70b. Unknown IDs fail validation.",
            "items": {
              "type": "string"
            }
          },
          "embeddingModels": {
            "title": "Embedding models",
            "type": "array",
            "description": "Embedding model IDs to price. Empty = defaults (text-embedding-3-small, text-embedding-3-large). Supported: text-embedding-3-small, text-embedding-3-large, voyage-3-lite, voyage-3. Unknown IDs fail validation.",
            "items": {
              "type": "string"
            }
          },
          "maxItems": {
            "title": "Max items (safety cap)",
            "minimum": 1,
            "maximum": 50000,
            "type": "integer",
            "description": "Hard cap on rows analyzed. Rows beyond the cap are ignored. The rows-analyzed event is charged per analyzed row, so this also caps that charge (1,000 rows = $0.05).",
            "default": 1000
          },
          "assumedOutputTokensPerItem": {
            "title": "Assumed chat output tokens per item",
            "minimum": 0,
            "maximum": 100000,
            "type": "integer",
            "description": "Assumed completion tokens per non-empty row when estimating chat cost. Use 0 to price input tokens only.",
            "default": 0
          },
          "budgetUsd": {
            "title": "Budget (USD)",
            "minimum": 0,
            "type": "number",
            "description": "Optional USD ceiling compared to the estimate selected in 'Budget comparison basis'. Leave empty for a report without gate."
          },
          "budgetBasis": {
            "title": "Budget comparison basis",
            "enum": [
              "cheapest_embedding",
              "most_expensive_embedding",
              "cheapest_chat_input",
              "most_expensive_chat_input"
            ],
            "type": "string",
            "description": "Which estimate is compared to Budget (USD).",
            "default": "cheapest_embedding"
          },
          "failIfOverBudgetUsd": {
            "title": "Fail Actor run if over budget",
            "type": "boolean",
            "description": "When enabled (requires Budget), the Actor writes OUTPUT and REPORT, then fails the run with BUDGET_GATE_FAIL if the estimate exceeds the budget. Use as a CI / agent gate.",
            "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}