---
title: "Bulk Create Dataset Logs"
method: POST
path: "/api/datasets/{dataset_id}/logs/bulk/"
tags: ["datasets"]
---

# Bulk Create Dataset Logs

`POST /api/datasets/{dataset_id}/logs/bulk/`

Bulk create dataset logs from array of unified format data

Endpoint:
    POST /api/datasets/{dataset_id}/logs/bulk/

Args (POST body):
    - logs (array, required): List of log objects in unified format
      Each log object contains:
        - input (any): The input data (required) - can be any type (dict, list, string, etc.)
        - output (any, optional): The output data - can be any type
        - metadata (object, optional): Additional metadata fields (model, log_type, etc.)
        - metrics (object, optional): Metric fields (tokens, cost, latency, etc.)

Example Request (Recommended - Top-level expected_output):
    ```json
    {
      "logs": [
        {
          "input": "What is your return policy?",
          "expected_output": "You can return within 30 days",
          "metadata": {"category": "support"}
        },
        {
          "input": "How do I reset my password?",
          "expected_output": "Click Forgot Password on login page",
          "metadata": {"category": "support"}
        }
      ]
    }
    ```

Example Request (Legacy - Nested expected_output, auto-extracted):
    Frontend parses CSV where expected_output is nested in input:
    ```json
    {
      "logs": [
        {
          "input": {
            "user_query": "What is your return policy?",
            "expected_output": "You can return within 30 days",
            "category": "support"
          }
        }
      ]
    }
    ```
    Note: Nested expected_output is automatically extracted to top-level field.

Example Request (Direct API usage with expected_output):
    ```json
    {
      "logs": [
        {
          "input": "What is AI?",
          "expected_output": "AI is artificial intelligence",
          "output": "",
          "metadata": {"category": "qa", "model": "gpt-4"}
        },
        {
          "input": [{"role": "user", "content": "Hello"}],
          "expected_output": "A friendly greeting",
          "output": {"role": "assistant", "content": "Hi there!"},
          "metrics": {"tokens": 10, "cost": 0.0001}
        }
      ]
    }
    ```

Field Descriptions:
    - input: The input to be processed (can be string, dict, or array)
    - expected_output: Expected/ground truth output for evaluation (optional)
    - output: Actual output from LLM or system (populated during experiments)
    - metadata: Additional context fields
    - metrics: Performance metrics (tokens, cost, latency)

Returns (POST 201):
    ```json
    {
      "success_count": 95,
      "error_count": 5,
      "errors": [
        {"index": 3, "error": "Invalid input format"},
        {"index": 7, "error": "Missing required field"}
      ]
    }
    ```

Notes:
    - For UI users: Frontend parses CSV and sends array in unified format
    - For API users: Send JSON array directly, no CSV conversion needed
    - Each row of CSV becomes an "input" object in the dataset log
    - Plan limits are enforced (current dataset log count + new logs <= limit)
    - Errors are returned for individual logs that fail, successful ones are still created

## Path parameters

- `dataset_id` string, required

## Headers

- `Authorization` string, required

## Request body

- DatasetLogsBulkCreateRequestRequest
  - `logs` unknown[], required
    - unknown

## Response `201`

- DatasetLogsBulkCreateResponse
  - `success_count` integer, required
  - `error_count` integer, required
  - `errors` unknown[], required
    - unknown

## Other responses

- `400` — Empty/invalid `logs`, plan limit exceeded, request body too large (>500 items), or all items failed.
- `404` — Dataset not found.

---

[API](https://skmtc.net/keywordsai/apis/api-reference.md) · [All operations](https://skmtc.net/keywordsai/apis/api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/keywordsai/api-reference/versions/c26d550029f8/schema)
