## Estimate credit cost for document preprocessing

`datasets.get_preprocessing_credits(strdataset_id, DatasetGetPreprocessingCreditsParams**kwargs)  -> DatasetGetPreprocessingCreditsResponse`

**get** `/api/v1/datasets/{dataset_id}/preprocessing-credits`

Quotes the credits that extracting a document dataset (pdf, docx, pptx, xlsx, html, or a zip of them) will reserve, from the page count of each document. Pass the same `pages_to_process` or `documents_to_process` you intend to launch with. Page counting runs in the background after upload, so `isFinal: false` means the quote is still partial — poll until it is true. Start extraction with POST /datasets/{dataset_id}/launch-preprocessing.

### Parameters

- `dataset_id: str`

- `pages_to_process: Optional[float]`

  Maximum number of pages to process. Documents are included until this budget is reached. If omitted, all pages are processed.

- `documents_to_process: Optional[float]`

  Maximum number of documents to process. If omitted, all documents are processed.

### Returns

- `class DatasetGetPreprocessingCreditsResponse: …`

  - `available_credits: float`

    User's total available credits (team balance)

  - `extraction_cost: float`

    Estimated or actual credit cost for document extraction

  - `total_pages: float`

    Total pages across all documents (sum of page counts)

  - `total_documents: float`

    Total documents in the dataset

  - `completed_documents: float`

    Number of documents with completed extraction (page counts known)

  - `is_final: bool`

    Whether the cost is final or still an estimate. Before launch it is final once every document has a page count; after launch, once every extraction has finished.

  - `insufficient_credits: Optional[InsufficientCredits]`

    Present when available credits are insufficient for the extraction cost

    - `credits_required: float`

      Credits the extraction would reserve

    - `credits_available: float`

      Credits available to the team

### Example

```python
import os
from adaption import Adaption

client = Adaption(
    api_key=os.environ.get("ADAPTION_API_KEY"),  # This is the default and can be omitted
)
response = client.datasets.get_preprocessing_credits(
    dataset_id="dataset_id",
)
print(response.available_credits)
```

#### Response

```json
{
  "availableCredits": 0,
  "extractionCost": 0,
  "totalPages": 0,
  "totalDocuments": 0,
  "completedDocuments": 0,
  "isFinal": true,
  "insufficientCredits": {
    "creditsRequired": 0,
    "creditsAvailable": 0
  }
}
```
