Skip to main content

Python SDK for the Infratex document intelligence API

Project description

Infratex Python SDK

Official Python client for the Infratex document intelligence API. Parse PDFs, build search indexes, and generate AI-powered answers grounded in your documents.

Installation

pip install infratex

Quick start

from infratex import Infratex

client = Infratex(api_key="infratex_sk_...")

# Upload and parse a PDF
doc = client.documents.upload("report.pdf")
print(doc.id, doc.status, doc.page_count)

# Index for search
index = client.documents.index(doc.id, method="vector")

# Search
results = client.searches.create(query="revenue growth", document_ids=[doc.id])
for r in results:
    print(r.score, r.content[:100])

# AI response (streamed)
for event in client.responses.create(message="Summarize the key findings", document_ids=[doc.id]):
    if event.type == "text":
        print(event.content, end="")
    elif event.type == "sources":
        print("Sources:", event.content)

Authentication

Pass your API key directly or set the INFRATEX_API_KEY environment variable:

# Explicit
client = Infratex(api_key="infratex_sk_...")

# From environment
import os
os.environ["INFRATEX_API_KEY"] = "infratex_sk_..."
client = Infratex()

Resources

Documents

# Upload
doc = client.documents.upload("report.pdf")
doc = client.documents.upload("report.pdf", method="standard", collection_id="col-id")

# List
docs = client.documents.list(limit=50, offset=0, collection_id="col-id")
print(docs.total)
for d in docs:
    print(d.filename)

# Get
doc = client.documents.get("doc-id")

# Download markdown
md = client.documents.markdown("doc-id")

# Delete
client.documents.delete("doc-id")

# Index
index = client.documents.index("doc-id", method="hybrid")

Searches

results = client.searches.create(
    query="What is the EBITDA?",
    method="vector",
    limit=5,
    document_ids=["doc-id"],
    collection_id="col-id",
)
for r in results:
    print(r.score, r.content[:200])

Responses (streaming)

for event in client.responses.create(
    message="Summarize the report",
    method="hybrid",
    limit=5,
    document_ids=["doc-id"],
    conversation_id="conv-id",
):
    if event.type == "text":
        print(event.content, end="")
    elif event.type == "sources":
        print("Sources:", event.content)
    elif event.type == "done":
        print("\n--- Done ---")

Collections

col = client.collections.create(name="Q3 Reports")
cols = client.collections.list()
col = client.collections.get("col-id")
client.collections.update("col-id", name="Q4 Reports")
client.collections.delete("col-id")

Conversations

conv = client.conversations.create(title="Analysis")
convs = client.conversations.list()
conv = client.conversations.get("conv-id")  # includes messages
client.conversations.delete("conv-id")

Account & Billing

account = client.account.get()
print(account.tenant["email"])

billing = client.billing.get()
print(billing.balance_micros)

Error handling

from infratex import Infratex, InfratexError

client = Infratex(api_key="infratex_sk_...")

try:
    doc = client.documents.get("nonexistent-id")
except InfratexError as e:
    print(e.status_code)  # 404
    print(e.code)         # error code from the API
    print(str(e))         # human-readable message

Configuration

client = Infratex(
    api_key="infratex_sk_...",
    base_url="https://api.infratex.io",  # custom base URL
    timeout=60.0,                         # request timeout in seconds
)

# Use as a context manager
with Infratex(api_key="infratex_sk_...") as client:
    doc = client.documents.upload("report.pdf")

License

MIT

Project details


Download files

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

Source Distribution

infratex-0.2.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

infratex-0.2.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file infratex-0.2.0.tar.gz.

File metadata

  • Download URL: infratex-0.2.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for infratex-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e780150ca8f26af808629ad7c22e295d1d0f7a831756b1ac20dd80664b9a8e61
MD5 405e01f09c63fe89f9f31e219b80a9e4
BLAKE2b-256 de91ed61b982228dcd8999876cd1666cc208a3ae31e10d04bab42d2afc72d113

See more details on using hashes here.

File details

Details for the file infratex-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: infratex-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for infratex-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d66bc5697ef24594814dc52adaf07d369d0ca23b85a196f44025cd6cf314a00
MD5 2b02ab025fdb37bd7429a2405ab2cc41
BLAKE2b-256 1abefa74518be58658330a705c5c3fd04a0a0c5c1b332ca547c3ad46820f5849

See more details on using hashes here.

Supported by

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