Skip to main content

nace-sdk (Python)

The official Python client for the Drex API: calibrated answers to typed questions (POST /v1/systemone), document jobs — parse, split, classify, extract and ground — and workspaces with search over their files. Docs: https://console.nace.ai/docs

The client is built on the TypeSafe AI Python SDK (MIT; see THIRD_PARTY_NOTICES.md): system_one, Noul, Choice, Score, SystemOneResponse with .nouls, .choices and .scores, RetryPolicy and the error classes match typesafe-sdk, so TypeSafeClient code runs on NaceClient after renaming the imports. It depends only on httpx, pydantic and typing-extensions.

pip install nace-sdk
export NACE_API_KEY=nace_sk_...

Python 3.10 or later. Create a key on the API keys page.

Decisions

from nace_sdk import Choice, NaceClient, Noul, Score

with NaceClient() as client:  # reads NACE_API_KEY, NACE_BASE_URL, NACE_DEFAULT_DECISION_MODEL
    result = client.system_one(
        state="I was charged twice for my March invoice.",
        questions={
            "wants_refund": Noul(instructions="Is the customer asking for a refund?"),
            "topic": Choice(instructions="Which topic is it?", criteria={"billing": None, "shipping": None, "other": None}),
            "urgency": Score(instructions="How urgent is it?", criteria=["low", "medium", "high"]),
        },
    )

print(result.nouls["wants_refund"].noul)
print(result.choices["topic"].choice, result.request_id)

AsyncNaceClient has the same methods, awaited.

Documents

from nace_sdk import NaceClient, UrlSource

with NaceClient() as client:
    # An https:// URL whose last path segment names the file: its extension picks the parser.
    created = client.documents.parse("https://example.com/invoice.pdf", output={"formats": ["markdown"]})
    job = client.jobs.wait(created.job_id)
    print(job.result["document"]["markdown"])

    # A URL whose last segment isn't the file's name needs a file_name.
    client.documents.parse(UrlSource(url="https://arxiv.org/pdf/1706.03762", file_name="attention.pdf"))

    # on_conflict="new_version" replaces the file at that path instead of failing with path_conflict.
    file = client.documents.upload("invoice.pdf", path="invoices/invoice.pdf", on_conflict="new_version")
    extracted = client.documents.extract(
        file.as_source(),
        schema={"type": "object", "properties": {"total": {"type": "number"}}},
        wait_seconds=60,
    )

    # Or save the schema once and name it.
    saved = client.extraction_schemas.create("Invoice", {"type": "object", "properties": {"total": {"type": "number"}}})
    client.documents.extract(file.as_source(), schema_id=saved.schema_id)

Uploads go straight to the document service with a one-use token, never with your API key; files of 32 MiB and more go up in parts. To run a resumable upload yourself, use create_upload_session, upload_part, complete_upload_session, get_upload_session (which parts landed) and abort_upload_session; create_upload_grant mints a token for another client to upload with. Every document job and upload session create carries an Idempotency-Key, so retries never start a second job or session. The /v1 routes send no Access-Control-Allow-Origin header, so keep Drex calls on your server: a browser uploads with a grant your server mints, and opens job files through jobs.file_link links.

client.jobs has get, list, iter, wait, delete, events, get_request (the request a job ran under), rows (a parsed sheet's rows, a page at a time), file_link (a signed link to a stored file) and download (any job file, including full Markdown that is still being prepared). client.extraction_schemas has list, iter, get, create, list_versions and iter_versions (oldest first), get_version, create_version and delete (every version); creates are not retried unless you pass retry, since a retry could save a second schema.

client.workspaces creates, lists, updates and deletes workspaces, and runs ingest over them; client.workspaces.files lists, reads, replaces and deletes their files, with their metadata, versions and outputs. client.domains manages the taxonomies a workspace classifies its files against (list, iter, get, create, update, publish, duplicate); pass a published domain's slug to workspaces.create(..., domain_slug=...). Upload into a workspace with client.documents.upload(..., workspace_id=...). client.search.automatic and client.search.qa answer questions over a workspace's ingested files, each as a job to jobs.wait for.

client.browser_runs gives a cloud browser agent a task on the sites you allow: run creates a run and waits for it, and create, get, list, iter_all, wait, cancel and artifacts handle each step. A run is billed once, when it ends, never more than its limits.max_cost_usd.

Errors and retries

Every failure raises a NaceError. HTTP failures are NaceAPIError subclasses (NaceBadRequestError, NaceAuthenticationError, NaceInsufficientCreditError, NacePermissionDeniedError, NaceNotFoundError, NaceConflictError, NaceUnprocessableEntityError, NaceRateLimitError, NaceInternalServerError, NaceOverloadedError) with status, body, request_id, type, code, issues, detail and server_retryable; a success whose body doesn't match is a NaceAPIResponseValidationError, and a failed connection a NaceAPIConnectionError (NaceAPITimeoutError on a timeout). jobs.wait raises NaceJobFailedError or NaceJobTimeoutError. The client retries 408, 429, 5xx, dropped connections and timeouts (up to 2 retries, 0.5 s doubling to 5 s, honoring retry-after-ms), except an error the server marks "retryable": false. Python honors server Retry-After delays without a maximum. There is no total retry budget by default, so slow failures can use all three attempts and may take several minutes to surface. Set RetryPolicy(timeout=...) to opt into a budget: elapsed time plus the next wait must be below it before another attempt starts. The budget does not interrupt an ongoing attempt. jobs.download retries opening each file the same way, but not a transfer cut off midway; jobs.events is not retried, and saved-schema creates aren't unless you pass retry.

from nace_sdk import NaceClient, RetryPolicy

# Allow 5 attempts; opt into a 500 s budget for starting retries.
client = NaceClient(timeout=90, retry=RetryPolicy(max_retries=4, timeout=500))

The SDK logs to the nace_sdk logger: NACE_LOG_LEVEL=debug sets its level, and a handler (for example logging.basicConfig()) shows the records. At debug it logs headers and bodies, with the API key, upload tokens and PDF passwords redacted.

The nace command line tool is pip install nace-cli; it reads the key nace login saves through nace_sdk.credentials. Full guide: https://console.nace.ai/docs/developer-tools/python

License

Apache-2.0

Credential destinations

The configured API root is trusted configuration. NACE_API_KEY and NACE_BASE_URL work together for Nace cloud, custom and on-prem deployments without passing constructor arguments. Legacy DREX_* variables still work when their NACE_* counterpart is absent. Explicit SDK arguments override the environment; CLI/MCP environment values override saved configuration. Keep the key and API root for the same deployment together. Login profiles are optional. URLs containing userinfo are refused.

The Python client keeps your HTTP client's follow_redirects setting. When enabled, authenticated API and upload-grant requests follow redirects only within the same scheme, host and effective port. Credential-free signed links may follow redirects to other origins without inheriting API authentication.

Metadata

Release files for nace-sdk 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nace-sdk 0.9.0
File Size Uploaded Provenance Actions
nace_sdk-0.9.0.tar.gz 100.8 kB With provenance Details for nace_sdk-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nace-sdk 0.9.0
File Interpreter ABI Platform Actions
nace_sdk-0.9.0-py3-none-any.whl Python 3 none any Details for nace_sdk-0.9.0-py3-none-any.whl

Total release size: 214.7 kB

Release files / nace_sdk-0.9.0.tar.gz

Download URL nace_sdk-0.9.0.tar.gz
Size 100.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7623af353cef2adc31194ba656b0e1d6da26c0cca1d7edd981355e12578dd2cb
BLAKE2b-256 checksum
How to use checksums
764a73d997eea0d2c9b2af8a3936a045a763416a6f34f4309d99a62fdbb46b12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / nace_sdk-0.9.0-py3-none-any.whl

Download URL nace_sdk-0.9.0-py3-none-any.whl
Size 113.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87e0e3bd50d62e15def280f7645739e50935800a0ec64a4a2aaa0b6c718793c4
BLAKE2b-256 checksum
How to use checksums
ae48e85aaebdbbaec5d059a0e61bab85d3e50266bff79a7dbb26fc3a2a38cec5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for nace-sdk 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nace_sdk-0.9.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page