---
title: "Extend trajectories with a next user turn (or estimate cost)"
method: POST
path: "/api/v1/datasets/{dataset_id}/extend-trajectories"
tags: ["Dataset"]
---

# Extend trajectories with a next user turn (or estimate cost)

`POST /api/v1/datasets/{dataset_id}/extend-trajectories`

## Request

- The document declares no server URL.
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/adaptionlabs/apis/adaption-api/docs/api/v1/datasets/:dataset_id/extend-trajectories/post.ts> (a function with typed inputs; its response is checked against the schema)

For each row's conversation, generates the user's next message: a single question or request that can only be answered correctly by remembering details from earlier in the conversation, written in the conversation's language. No completion is generated for it. Each request creates a new dataset for the result, returned as `dataset_id`; the dataset in the path is left unchanged. Poll GET /datasets/{dataset_id}/status and download from GET /datasets/{dataset_id}/download with the new id. If the dataset has been adapted (POST /datasets/{dataset_id}/adapt finished), the extension builds on its adapted download: `column_mapping` names columns of that download, so `column_mapping.completion` can be `enhanced_completion`, and the result keeps the adapted columns next to `extended_prompt`. Only `prompt` + `completion` applies there, since adapt splits a chat column into `original_prompt` and `original_completion`. Otherwise the extension reads the uploaded file, with one of two mappings. `column_mapping.chat`: a column of `{"role", "content"}` turns (or a JSON string of that list), ending on the assistant's reply. Or `column_mapping.prompt` with `column_mapping.completion`: the conversation up to the user's last turn (a turn list, or a plain string), plus the final reply as plain text. Each row of the result carries the conversation (split as for /adapt) plus an `extended_prompt` column. `context`, `universal_prompt` and `image` mappings are not currently supported. Credits and status polling behave as for /adapt; an `idempotency_key` replays the extension it first created, returning its `dataset_id` and `run_id` with zero estimates, since the replay starts and charges nothing (as for /translate). Set estimate=true to validate and get a cost quote without starting a run.

## Path parameters

- `dataset_id` string, required

## Request body

- PublicExtendTrajectoriesDto
  - `column_mapping` PublicExtendTrajectoriesColumnMappingDto
    - `chat` string: Column holding each row's conversation as a list of `{"role", "content"}` turns (or a JSON string encoding that list), ending on the assistant's reply. The full conversation is the trajectory the next user message is generated from. Send `chat` alone, or `prompt` with `completion` instead. Not available on an adapted dataset: adapt splits the chat column into `original_prompt` and `original_completion`, so map those with `prompt` and `completion`.
    - `prompt` string: Column holding the conversation up to and including the user's last turn: a list of `{"role", "content"}` turns (or a JSON string encoding that list), or a plain string read as a single user turn. Requires `completion`; not allowed with `chat`. On an adapted dataset, a column of its download: `original_prompt` if it was adapted from a chat column, otherwise the dataset's own prompt column.
    - `completion` string: Column holding the assistant's final reply to `prompt`, as plain text. It becomes the last turn of the trajectory. Requires `prompt`; not allowed with `chat`. On an adapted dataset, a column of its download: `enhanced_completion` extends the adapted reply, the original completion column extends the reply as uploaded.
  - `job_specification` PublicJobSpecDto
    - `max_rows` number: Maximum number of rows to process in this run
    - `idempotency_key` string: Client-generated idempotency key for safe retries. If a launch with the same key already exists, the original response is returned.
  - `estimate` boolean: When true, validates the request and returns the estimated credit cost without starting a run.

## Response `200`

- PublicExtendTrajectoriesResponseDto
  - `run_id` string, nullable: Unique identifier for this pipeline run. Null for estimate-only requests.
  - `estimatedMinutes` number, required: Estimated processing time in minutes
  - `estimatedCreditsConsumed` number, required: Estimated number of credits that will be consumed by this run
  - `estimate` boolean, required: Whether this was an estimate-only request (no run started)
  - `multimodalPricingApplied` boolean, required: True when an image column is mapped and also listed in context_columns; each output row is billed at a higher rate.
  - `creditMultiplier` number: 10 credits per 100 output rows when multimodalPricingApplied is true. Omitted for text-only pricing.
  - `dataset_id` string, uuid, nullable, required: The new dataset holding the extended trajectories. Poll GET /datasets/{dataset_id}/status and download from GET /datasets/{dataset_id}/download with this id, not the source dataset's. Null for estimate-only requests.

## Other responses

- `400`: Validation failed: `column_mapping` must be `chat` alone, or `prompt` with `completion`, naming columns the input has (an adapted dataset takes `prompt` + `completion` only). Any other `column_mapping` field (such as `context`, `universal_prompt` or `image`) is not currently supported. Also returned for datasets this endpoint cannot read: another extension, a combined, invented, augmented, translated or localized dataset, or one adapted into preference pairs, from a universal prompt, or with images.
- `402`: Insufficient credits
- `409`: Conflict — dataset is launching or still importing, row_count is not yet available, or another request holds this idempotency_key. Poll GET /datasets/{dataset_id}/status until row_count is populated.
- `422`: Estimate without `column_mapping` on a dataset that has not been adapted and whose saved mapping is neither a chat column nor a prompt + completion pair.

## Changes

- **2026-10-20** `7398ff1eeeba`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/adaptionlabs/apis/adaption-api/changes/api/v1/datasets/:dataset_id/extend-trajectories/post.md)

---

[API](https://skmtc.dev/adaptionlabs/apis/adaption-api.md) - [All operations](https://skmtc.dev/adaptionlabs/apis/adaption-api/llms.txt) - [OpenAPI document](https://skmtc.dev/adaptionlabs/apis/adaption-api/revisions/d4cf908c19a0?raw)
