Usage

Installation

Install the sapling-py package from PyPI with pip:

python -m pip install sapling-py

Or add it to a uv project:

uv add sapling-py

Quickstart

  • Register for an account at Sapling.ai.

  • After registering and signing in, generate a development API key in your dashboard.

  • Install the Python client by following the installation steps above.

from sapling import SaplingClient

API_KEY = '<YOUR_API_KEY>'
client = SaplingClient(api_key=API_KEY)
edits = client.edits('Lets get started!', session_id='test_session')
  • The result should be an array of edits of this form:

[{
  "id": "aa5ee291-a073-5146-8ebc-c9c899d01278",
  "sentence": "Lets get started!",
  "sentence_start": 0,
  "start": 0
  "end": 4,
  "replacement": "Let's",
  "error_type": "R:OTHER",
  "general_error_type": "Other",
}]

Batch requests

The analysis endpoints — classify, extract, safety, langdetect, translate, summarize, quality and aidetect — also accept a list of 1-10 texts in place of a single string. The batch is sent as one request (the same options apply to every item) and returns {'results': [...]} with one single-response-shaped dict per input, in order:

scores = client.quality(['First draft.', 'Second draft.'], sentence_scores=True)
langs = client.langdetect(['Bonjour le monde', 'Hello world'])