Skip to main content

content-sdk

Install

pip install content-sdk        # https://pypi.org/project/content-sdk/

Python 3.11+. Requires only httpx and pydantic. The wheel is also attached to each GitHub release; from a clone: pip install ./packages/python-sdk.

The official Python SDK for the Content engine — the one API client. It fully encapsulates the REST API (/api/v1); the CLI, the MCP server and applications all speak through it, so the engine's rules are never duplicated.

Install

pip install content-sdk        # or: uv pip install -e packages/python-sdk

Synchronous

from content_sdk import ContentClient, outputs

with ContentClient("http://localhost:8010") as client:
    analysis = client.analyze(outputs.url_source("https://www.youtube.com/watch?v=…"))
    caps = client.get_capabilities(analysis.id)  # analysis_id is addressable
    job = client.generate(analysis.id, [outputs.audio_output()])
    job.wait()  # polls until terminal
    for artifact in job.artifacts:
        print(artifact.filename, artifact.media_type)

analyze, get_capabilities and generate accept either an analysis_id / Analysis or inline sources (ADR 0014):

client.get_capabilities([outputs.url_source("https://…")])  # stateless, by sources

Asynchronous

import asyncio
from content_sdk import AsyncContentClient, outputs


async def main():
    async with AsyncContentClient("http://localhost:8010") as client:
        analysis = await client.analyze(outputs.url_source("https://…"))
        job = await analysis.generate([outputs.audio_output()])
        await job.wait()
        print([a.filename for a in await job.artifacts()])


asyncio.run(main())

Errors

Every non-2xx maps to a typed exception carrying the stable error codes:

from content_sdk import NotFound, Gone, ValidationError

try:
    client.get_analysis("ana_stale")
except Gone as exc:  # 410 — the analysis or its facts expired
    print(exc.codes)  # ["analysis_expired"]
except NotFound:  # 404
    ...
except ValidationError as exc:  # 422 / 409 idempotency
    print(exc.codes)

Design

  • models.py — pure pydantic contract models (data only, no client).
  • resources.py — behavioural objects (Analysis, Job) bound to a client.
  • _transport.py — httpx sync/async layer; conservative retries (transport errors + 5xx on safe GETs only; creations retried only with an idempotency key).

The SDK never imports the engine and never depends on the CLI or MCP.

Sending a local file

A file source names a path the engine can read. For a file on your own machine — a laptop talking to a homelab engine — upload it first:

source = client.upload_file("~/report.pdf")  # returns a ready-to-use source
analysis = client.analyze(source)
job = client.generate(analysis.id, [{"id": "s", "type": "summary"}])

upload_file streams from disk and hands back {"type": "upload", …} — the upload id never has to be handled by hand. upload_bytes(name, data, type) does the same for bytes that were never a file, which is what a browser upload is. upload() returns the record itself (size, sha256) for callers who want it, and get_upload / delete_upload complete the endpoint.

The async client mirrors all of it, with one deliberate difference: it buffers rather than streams, because handing httpx a blocking file handle inside an async send only relocates the stall. For a large upload, prefer the sync client.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

content_sdk-0.6.2.tar.gz (34.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

content_sdk-0.6.2-py3-none-any.whl (42.0 kB view details)

Uploaded Python 3

File details

Details for the file content_sdk-0.6.2.tar.gz.

File metadata

  • Download URL: content_sdk-0.6.2.tar.gz
  • Upload date:
  • Size: 34.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for content_sdk-0.6.2.tar.gz
Algorithm Hash digest
SHA256 eda1e1b0445d06aa0b9872da26dece17095e4d187aae87dc877cc75c0ead0d49
MD5 f64df129bbed7eca81b48e3d1cc30e15
BLAKE2b-256 5c8862369cde645701f96e04d0e9889ac4c3463e7bf7b326f2ccdcb42acaf192

See more details on using hashes here.

Provenance

The following attestation bundles were made for content_sdk-0.6.2.tar.gz:

Publisher: publish-pypi.yml on LatentNoise/content

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file content_sdk-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: content_sdk-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 42.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for content_sdk-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c75011881efb8f104abc9bf01d7ccf6bc04f88f8a566acf9333b8d14e98476e6
MD5 b96dc6c9eaf449cfd247fe05e7cf6d63
BLAKE2b-256 aac968052066c528b1039662aebca4d062693063cd66b3e00144464aca864323

See more details on using hashes here.

Provenance

The following attestation bundles were made for content_sdk-0.6.2-py3-none-any.whl:

Publisher: publish-pypi.yml on LatentNoise/content

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.6.7

2 files

0.6.6

2 files

0.6.5

2 files

0.6.4

2 files

0.6.3

2 files

This release

0.6.2 This release

2 files

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.3

2 files

0.3.0

2 files

0.2.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page