Skip to main content

gushwork-argus

Python client for Argus, Gushwork's image ingestion and search API. You give Argus pages and images; it finds every image, describes it, and makes it searchable by meaning.

  • One client, two settings: an API key and the API host.
  • Argus (blocking) and AsyncArgus (asyncio) with the same methods.
  • Typed responses (Pydantic v2), typed errors, retries with backoff.
  • Python 3.10+. Depends only on httpx and pydantic.

Install

pip install gushwork-argus
# or
uv add gushwork-argus

Pin a version in services (gushwork-argus==0.10.0); see CHANGELOG.md.

Configure

from gushwork_argus import Argus

argus = Argus(api_key="...", base_url="https://<argus host>")

Or set ARGUS_API_KEY and ARGUS_BASE_URL and call Argus(). The Argus team gives you both: a key with the scopes your service needs, and the host for each environment.

Optional: timeout=30.0 (seconds per request), max_retries=2. Create one client per process and reuse it; it keeps a connection pool. Close it with argus.close() or use with Argus(...) as argus:.

Use

from pathlib import Path
from gushwork_argus import Argus, ConflictError

argus = Argus()

# 1. Create a namespace (admin key). Safe to retry with the same fields.
namespace = argus.namespaces.create(
    slug="acme-dental", name="Acme Dental", site_name="Acme Dental", domain="acme.com"
)

# 2. Get it back, by id or slug
namespace = argus.namespaces.get(namespace.id)
namespace = argus.namespaces.find_by_slug("acme-dental")  # None when there is none
namespace.profile  # what deep search knows about the library; None until built

# 3. Add a page or an image (ingest scope). Files go to S3 through a presigned upload.
page = argus.pages.add(namespace.id, Path("about.md"), page_url="https://acme.com/about")
page = argus.pages.add(namespace.id, html_text, type="html", page_url="https://acme.com/")
image = argus.images.add(namespace.id, file=Path("crown.jpg"), alt="Dentist fitting a crown")
image = argus.images.add(namespace.id, url="https://cdn.acme.com/crown.jpg")  # no upload
# Tags go on every image of the page (or on the one image) and act as filters later
page = argus.pages.add(namespace.id, html_text, type="html", tags=["google_business_profile"])
image = argus.images.add(namespace.id, file=Path("kitchen.jpg"), tags=["customer_uploaded"])

# 7. Check an ingestion, or wait until it is complete
status = argus.ingestions.get(page.ingestion_id)
status = argus.ingestions.wait(page.ingestion_id, timeout=600)
print(status.status, status.images.searchable, "of", status.images.total, "searchable")

# 4. Search (retrieve scope)
response = argus.images.search(
    namespace.id, "dentist fitting a crown", top_k=5, filters={"orientation": "landscape"}
)
for result in response.results:
    print(result.rank, result.match, result.image.url, result.description, result.tags)
# Only images carrying any of `tags`, and none of `exclude_tags`
response = argus.images.search(
    namespace.id,
    "kitchen remodel",
    filters={"tags": ["customer_uploaded"], "exclude_tags": ["stock"]},
)
# Everything known about each result: pages it appears on, text in it, keywords
response = argus.images.search(namespace.id, "ceo headshot", include_context=True)
# mode="fast" skips the judge; mode="deep" plans rewrites from the library's profile and
# reranks more candidates, at about three times the cost and twice the time of "accurate";
# deep requests use a 120 s timeout unless the client's own timeout is longer
response = argus.images.search(namespace.id, "team photo at the clinic", mode="deep")
for appearance in response.results[0].context.appearances:
    print(appearance.page_url, appearance.alt, appearance.heading_path, appearance.count)

# 5. List namespaces: one page, or all of them
page_of_namespaces = argus.namespaces.list(limit=50)  # CursorPage: .items, .next_cursor
for ns in argus.namespaces.list_all():
    print(ns.slug)

# 6. List images, newest first
for img in argus.images.list_all(namespace.id, status="RETRIEVAL_READY"):
    print(img.media_id, img.description, img.file.url if img.file else None)
for img in argus.images.list_all(namespace.id, tags=["google_business_profile"]):
    print(img.media_id, img.tags)

Async

from gushwork_argus import AsyncArgus

async with AsyncArgus() as argus:
    namespace = await argus.namespaces.get(namespace_id)
    page = await argus.pages.add(namespace.id, Path("about.md"))
    async for img in argus.images.list_all(namespace.id):
        ...

Pages and images, in detail

  • pages.add(namespace_id, content, *, type=None, page_url=None, page_title=None, markdown=None, tags=None) content is a Path (type read from .md/.html), or the page itself as str or bytes with type="md" or type="html". A str is always page text, never a file name. Send page_url whenever you have it: it resolves relative image links and tells the describer where each image appears. For HTML, markdown (the same page converted to markdown, if your scraper has it) improves captions. A page is identified by its bytes: sending the same bytes again returns the first ingestion with duplicate=True, and any new page_url, page_title or markdown is ignored. New tags are still added.
  • images.add(namespace_id, *, file=None, url=None, alt=None, caption=None, page_url=None, tags=None) Exactly one of file (a Path, bytes or a file opened "rb") or url. A Path's or open file's name is sent as the image's filename; raw bytes have none.
  • Tags: up to 20 per call, each 1-64 of a-z 0-9 _ . : -, lowercased by Argus. They only grow: an image carries the tags of every page and upload it came from, near duplicates included, so a tag filter returns the image's group by its representative. images.list(..., tags=, exclude_tags=) and the search filters tags (any of) and exclude_tags (none of) filter on them; results and images return tags.
  • An ingestion is complete when the page is parsed (or failed) and every image on it is searchable or failed. Complete is not success: check status, error and images.failed.
  • Signed image links (url, thumbnail_url) expire after an hour. Store media_id, not the link.

Verify a webhook

Argus signs every webhook it sends with Standard Webhooks headers (webhook-id, webhook-timestamp, webhook-signature). Check them before you act on the event; pass the raw request body, not parsed JSON.

from gushwork_argus import WebhookVerificationError, webhooks


def handle(request):
    try:
        event = webhooks.verify(request.headers, request.body, "whsec_...")
    except WebhookVerificationError:
        return 400  # not from Argus, tampered or replayed: ignore it
    if event["type"] == "namespace.settled":
        ...
    return 200
  • secret can be a list while you rotate secrets; a signature from any of them is accepted.
  • A delivery whose timestamp is more than tolerance_s (300 s) away from now is refused.
  • A malformed secret (not whsec_ plus base64) or an empty list raises ValueError: that is a bug in your config, not a bad delivery.
  • Deliveries are retried for up to 4 hours until you answer 2xx, so the same event can arrive twice: deduplicate on event["id"].

Errors

Every runtime error is an ArgusError. Bad arguments raise ValueError before any request is sent, and so does a malformed secret given to webhooks.verify().

Exception When
APIConnectionError / APITimeoutError No answer from Argus (after retries)
BadRequestError (400) Request refused, e.g. a search filter Argus can't apply
AuthenticationError (401) API key missing, wrong or revoked
PermissionDeniedError (403) Key lacks the scope, or the namespace is another tenant's
NotFoundError (404) No such namespace or ingestion
ConflictError (409) Slug taken with different fields (.namespace_id), or nothing searchable yet
UnprocessableEntityError (422) A field has the wrong shape
RateLimitError (429) / InternalServerError (5xx) After retries
UploadError S3 refused the file
APIResponseValidationError A 2xx body the SDK can't read (a proxy page, or a much newer server)
IngestionTimeoutError ingestions.wait() ran out of time (.ingestion has the last status)
WebhookVerificationError webhooks.verify() refused a delivery: not from Argus, tampered or replayed

Every APIStatusError has status_code, detail (the server's message, or a list of field errors) and body.

try:
    argus.namespaces.create(slug="acme-dental", name="Acme")
except ConflictError as exc:
    namespace = argus.namespaces.get(exc.namespace_id)

Retries

Writes are safe to repeat: namespaces are keyed by slug, pages by their content hash, images by their source and context. So every call except search is retried on connection errors, timeouts, 429, 502, 503 and 504, with exponential backoff and jitter (max_retries=2 by default; 0 turns retries off).

A search runs paid model calls each time, so it is retried only when it certainly never reached Argus (a refused connection, or 429). A search that times out raises APITimeoutError instead of running again; raise timeout if accurate or deep searches on large namespaces need longer. ingestions.wait() keeps polling through connection errors and 5xx until its own timeout.

Retries are logged at INFO on the gushwork_argus logger.

S3 uploads go through a separate HTTP client that never carries the API key. It does not use a custom http_client; like any httpx client it reads HTTPS_PROXY and SSL_CERT_FILE from the environment.

API keys and scopes

Scope Can
admin create and edit namespaces, read anything
ingest add pages and images, check ingestions
retrieve search

Any key can read namespaces and list images. A key bound to a namespace sees only that namespace.

Develop

See CLAUDE.md for the layout, conventions and the release process.

cd sdk/python
uv sync
uv run pytest
uv run ruff check . && uv run ruff format --check . && uv run pyright

Metadata

Release files for gushwork-argus 0.10.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 gushwork-argus 0.10.0
File Size Uploaded Provenance Actions
gushwork_argus-0.10.0.tar.gz 22.2 kB Without provenance Details for gushwork_argus-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gushwork-argus 0.10.0
File Interpreter ABI Platform Actions
gushwork_argus-0.10.0-py3-none-any.whl Python 3 none any Details for gushwork_argus-0.10.0-py3-none-any.whl

Total release size: 49.3 kB

Release files / gushwork_argus-0.10.0.tar.gz

Download URL gushwork_argus-0.10.0.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e3540957539ea53e95825bbd36b9e304ce01f1cd594ddd69e9956b8355f2482b
BLAKE2b-256 checksum
How to use checksums
0ab5338ec1a664b84d928df73b847649d1774b1e1be9162ef5995b529575f6a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gushwork_argus-0.10.0-py3-none-any.whl

Download URL gushwork_argus-0.10.0-py3-none-any.whl
Size 27.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6efdf1fbc958f428ee3314af9414c8d86e16adcb51edf8f9af4d42d70b7a3f5
BLAKE2b-256 checksum
How to use checksums
79efed30dfc202421d0e177d6448e2fa66b7203943cfcad2226f965f5da32fe9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for gushwork-argus 0.10.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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