Skip to main content

Official Python SDK for the FlaxFlow Engine API — AI document processing.

Project description

flaxflow — Python SDK

Official Python SDK for the FlaxFlow Engine API — AI-powered document processing (extraction, classification, webhooks).

pip install flaxflow

Authentication

The SDK authenticates with an API key (sk_...). Create one in the FlaxFlow app under Settings → API keys, then pass it to the client or set FLAXFLOW_API_KEY.

from flaxflow import FlaxFlow

fx = FlaxFlow(api_key="sk_...")  # or FlaxFlow() reading FLAXFLOW_API_KEY

Quickstart

from flaxflow import FlaxFlow

fx = FlaxFlow(api_key="sk_...")

# 1. Create a document class from a sample — the AI infers the fields to extract
doc = fx.documents.create_from_sample("invoice-sample.pdf")

# 2. Process a real document against that class
job = fx.processing.process_document("invoice-001.pdf", document_id=str(doc.document_id))
print(job.result)        # -> {"invoice_number": "123", "total_amount": "99.90", ...}

# 3. Or extract with a free-form prompt, no document class needed
job = fx.processing.process_with_prompt(
    "invoice-001.pdf",
    prompt="Extract invoice number, issue date and total amount",
)
print(job.result)

The file argument accepts a path, raw bytes, or any file-like object. For paths the documentType is inferred from the extension; otherwise pass document_type=.

Resources

Resource Highlights
fx.documents create_from_sample, create_manual, update, list, delete
fx.processing process_document, process_with_prompt, process_many
fx.jobs list, get, get_batch, analytics, download_document
fx.classifiers create, list, get, update, set_models, delete
fx.webhooks create, list, update, delete, delivery_logs
fx.api_keys create, list, delete

Batch processing

batch = fx.processing.process_many(
    ["a.pdf", "b.pdf", "c.pdf"],
    classifier_id="<classifier_id>",   # let the classifier pick the right class
)
print(batch.batch_id, len(batch.jobs))

Webhooks

hook = fx.webhooks.create("https://example.com/hooks/flaxflow",
                          event_types=["job.completed", "job.failed"])
print(hook.secret)   # HMAC-SHA256 signing secret — shown only once

Error handling

Every failure raises a subclass of FlaxFlowError:

from flaxflow import FlaxFlow, AuthenticationError, NotFoundError, RateLimitError

try:
    fx.jobs.get("does-not-exist")
except NotFoundError:
    ...
except RateLimitError as e:
    print("slow down", e.status_code)
except AuthenticationError:
    print("check your API key")

Configuration

Option Default Env var
api_key – (required) FLAXFLOW_API_KEY
base_url https://api.flaxia.com.br FLAXFLOW_BASE_URL
timeout 60 seconds

FlaxFlow is a context manager — use with FlaxFlow(...) as fx: to close the HTTP client automatically.

Types

Response objects are pydantic models generated from the API's OpenAPI spec, so you get full editor autocompletion and validation. Field names are snake_case in Python (the wire format stays camelCase).

Development

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
bash scripts/generate.sh   # regenerate models from ../openapi.json
pytest

Publishing (maintainers)

Configure o token PyPI no GitHub (uma vez):

bash scripts/configure-pypi.sh   # cole o token pypi-...

Push em main com mudanças nesta pasta publica automaticamente a versão em pyproject.toml. Antes de cada release, aumente version (ex.: 1.0.1).

The generated models live in src/flaxflow/_generated/ and are produced from sdks/openapi.json (exported from the backend via cargo run --bin export_openapi).

Async support (AsyncFlaxFlow) is planned. The sync client is fully featured today.

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

flaxflow-1.0.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

flaxflow-1.0.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file flaxflow-1.0.0.tar.gz.

File metadata

  • Download URL: flaxflow-1.0.0.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for flaxflow-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0def1862a8c38d50ac1591900d22994ac86e1b45c91120556f4065116ada0b15
MD5 1fd9405a31143c5481d76969c1f28042
BLAKE2b-256 2315a0bd90a2400b3ca80686a40d3780b8fecd86d9af1e971bcfa4a3ccff5c28

See more details on using hashes here.

File details

Details for the file flaxflow-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: flaxflow-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for flaxflow-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d931753e525bd3cd6ceeccbe94c35820bbcee52be2249820d5fc3dd383152f1
MD5 276d3ba659088e2ba19e487e7c545ec5
BLAKE2b-256 cdc8039486e26fe39a53f04821b65a43c1479845c78cd5e44c7aa414f3410ef9

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