Instantiate the SDK client

Whenever you call the Textual SDK, you first instantiate the SDK client.

  • To work with Textual datasets, or to redact individual files, you instantiate TonicTextual.

  • To work with Textual pipelines, you instantiate TonicTextualParse.

Instantiating when the API key is already configured

If the API key is configured as the value of TONIC_TEXTUAL_API_KEY, then you do not need to provide the API key when you instantiate the SDK client.

For Textual pipelines:

from tonic_textual.parse_api import TonicTextualParse
# If you host Textual, use the appropriate URL
textual_url = "https://textual.tonic.ai"
textual = TonicTextualParse(textual_url)

For Textual datasets:

from tonic_textual.redact_api import TonicTextual
# If you host Textual, use the appropriate URL
textual_url = "https://textual.tonic.ai"
textual = TonicTextual(textual_url)

Instantiating when the API key is not configured

If the API key is not configured as the value of TONIC_TEXTUAL_API_KEY, then you must include the API key in the request.

For Textual pipelines:

from tonic_textual.parse_api import TonicTextualParse
api_key = "your-tonic-textual-api-key"
# If you host Textual, use the appropriate URL
textual_url = "https://textual.tonic.ai"
textual = TonicTextualParse(textual_url, api_key=api_key)

For Textual datasets:

from tonic_textual.redact_api import TonicTextual
api_key = "your-tonic-textual-api-key"
# If you host Textual, use the appropriate URL
textual_url = "https://textual.tonic.ai"
textual = TonicTextual(textual_url, api_key=api_key)

Last updated