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) andAsyncArgus(asyncio) with the same methods.- Typed responses (Pydantic v2), typed errors, retries with backoff.
- Python 3.10+. Depends only on
httpxandpydantic.
Install
pip install gushwork-argus
# or
uv add gushwork-argus
Pin a version in services (gushwork-argus==0.12.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 permissions 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 (namespace.create). 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 (namespace.upload). 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"])
page = argus.pages.add(namespace.id, Path("manual.pdf"), page_url="https://acme.com/manual.pdf")
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) # 900 s; a large scanned PDF: timeout=1800
print(status.status, status.images.searchable, "of", status.images.total, "searchable")
# 4. Search (namespace.search)
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"]},
)
# Anything but logos and icons, in any shape but portrait
response = argus.images.search(
namespace.id,
"kitchen remodel",
filters={"exclude_kind": ["logo", "icon"], "exclude_orientation": ["portrait"]},
)
# 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)contentis aPath(type read from.md/.html/.pdf), or the page itself asstrorbyteswithtype="md",type="html"ortype="pdf". Astris always page text, never a file name, so a PDF is aPathorbytes. For a PDF, every picture in it is extracted and named from its page;page_urlis the PDF's own URL. Sendpage_urlwhenever 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 withduplicate=True, and any newpage_url,page_titleormarkdownis ignored. Newtagsare still added.images.add(namespace_id, *, file=None, url=None, alt=None, caption=None, page_url=None, tags=None)Exactly one offile(aPath,bytesor a file opened"rb") orurl. APath's or open file's name is sent as the image'sfilename; 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 filterstags(any of) andexclude_tags(none of) filter on them; results and images returntags. - An ingestion is
completewhen the page is parsed (or failed) and every image on it is searchable or failed. Complete is not success: checkstatus,errorandimages.failed. - Signed image links (
url,thumbnail_url) expire after an hour. Storemedia_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
secretcan 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 raisesValueError: 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 permission, 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 permissions
Each call needs one permission on the key:
| Permission | Calls |
|---|---|
namespace.view |
namespaces.get, list, list_all, find_by_slug, images.list, ingestions.get, ingestions.wait |
namespace.upload |
pages.add, images.add |
namespace.search |
images.search |
namespace.delete |
images.delete, images.restore |
namespace.create |
namespaces.create (on a key not bound to a namespace) |
A key bound to a namespace sees only that namespace. A missing permission raises
PermissionDeniedError whose message names it.
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.12.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gushwork_argus-0.12.0.tar.gz | 23.2 kB | Without provenance | Details for gushwork_argus-0.12.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gushwork_argus-0.12.0-py3-none-any.whl | Python 3 | none | any | Details for gushwork_argus-0.12.0-py3-none-any.whl |
Total release size: 51.0 kB
Release files / gushwork_argus-0.12.0.tar.gz
| Download URL | gushwork_argus-0.12.0.tar.gz |
|---|---|
| Size | 23.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72c01f65ae037356eb8e0f10e5c89d75ac7ce9d1a4cbb14348d722f985bdd446
|
|
BLAKE2b-256 checksum How to use checksums |
5610087b94057e33751717ee96d8af9bf668216a9ce8a3d4afcd76c0486e79ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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.12.0-py3-none-any.whl
| Download URL | gushwork_argus-0.12.0-py3-none-any.whl |
|---|---|
| Size | 27.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
60743c9185fe84163fd4559d82009a997741d18f23efd32700a63607b2fb2d62
|
|
BLAKE2b-256 checksum How to use checksums |
ea16542ea3038f8deb86096f3c9f7ac2f61ae71f0397ffbd5b3c984a3a61e0a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","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.12.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.