Skip to main content

forgefile-python

Python client for the ForgeFile REST API — translate, transcribe, convert, OCR, summarize and rewrite files.

Requires Python 3.11+.

Install

pip install forgefile

Quick start

from forgefile import ForgeFile

with ForgeFile("your-token") as api:
    job = api.jobs.translate("contract.pdf", target_language="es")
    api.files.wait(job.uuid)
    api.files.download(job.uuid, "contract.es.pdf")

The token is read from FORGEFILE_API_KEY when the first argument is omitted. Public endpoints need no token at all:

with ForgeFile() as api:
    for language in api.public.languages():
        print(language.code, language.name)

Processing a file

Every job endpoint uploads the file and starts the work in one call, returning a FileJob whose uuid identifies it from then on.

api.jobs.translate("contract.pdf", target_language="de")  # source_language is optional
api.jobs.transcribe("interview.mp3")
api.jobs.convert("report.docx", to_format="pdf")
api.jobs.ocr("receipt.jpg")
api.jobs.summarize("paper.pdf")
api.jobs.rewrite("draft.docx")
api.jobs.compress("scan.pdf")

Uploads are capped at 10 MB by the API.

Waiting for the result

wait() blocks until the job reaches a terminal state and raises JobTimeoutError if it does not. The job keeps running server-side, so calling again resumes waiting.

finished = api.files.wait(job.uuid, timeout=900, interval=5)

if finished.succeeded:
    transcript = api.files.result(job.uuid)  # structured output
    api.files.download(job.uuid, "interview.srt")

track() yields every observed state instead, for progress reporting:

for state in api.files.track(job.uuid, interval=5):
    print(state.status)

Branch on job.is_finished and job.succeeded rather than comparing status strings — a status this client does not recognise is never treated as finished, so a wait loop cannot end early on a state it has not seen.

Errors

Every failure raises a subclass of ForgeFileError carrying the API's stable error_code, so you can branch on the code rather than on message text.

from forgefile import RateLimitError, ValidationError

try:
    api.jobs.translate("contract.pdf", target_language="es")
except ValidationError as exc:
    print(exc.context)  # field errors
except RateLimitError as exc:
    print(f"retry in {exc.retry_after}s")
Exception Raised when
AuthenticationError 401 — no token, or rejected
ForbiddenError 403 — token lacks the right
NotFoundError 404
ValidationError 422 — field errors in context
RateLimitError 429 — retry_after in seconds
ServerError 5xx — safe to retry with backoff
TransportError no response at all: DNS, TLS, timeout
JobTimeoutError wait() gave up; the job still runs

The API allows 60 requests per minute.

Configuration

Argument Environment variable Default
api_key FORGEFILE_API_KEY none — public endpoints only
base_url FORGEFILE_BASE_URL https://forgefile.com/api/v1
timeout 60 seconds

Examples

Runnable scripts in examples/:

File Shows
01_public_data.py reference data without a token
02_translate_document.py submit, wait, download
03_transcribe_with_progress.py streaming progress with track()
04_convert_a_folder.py batching — submit all, then collect
05_handling_errors.py every failure mode and its remedy
06_custom_transport.py replacing the HTTP layer

Architecture

Module Responsibility
config where to connect and with what headers
envelope the API's {success, message, data} wrapper — the only place that knows it
errors turning a failed response into the right exception
transport HTTP, as a Protocol plus an httpx implementation
resources/ one class per endpoint group: system, public, account, files, jobs

Resources depend on the HTTPTransport protocol, never on httpx, so the HTTP layer can be replaced with a recorded fixture, a proxy or a different library — see examples/06_custom_transport.py.

Response models accept unknown fields, which stay reachable through model_extra. Only fields observed against the live API are typed explicitly; authenticated endpoints could not be inspected without a token while this client was written, so their payloads are permissive rather than guessed.

The package ships a py.typed marker, so your type checker sees these signatures.

Development

git clone https://github.com/ForgeFile/forgefile-python
cd forgefile-python
uv sync

uv run ruff check .
uv run ruff format --check .
uv run mypy
uv run pytest

Tests make no network calls: the resource layer runs against a fake transport, the httpx layer against respx. CI runs these commands on Python 3.11, 3.12 and 3.13.

Links

MIT licensed. See LICENSE.

Release files for forgefile 0.1.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 forgefile 0.1.0
File Size Uploaded
forgefile-0.1.0.tar.gz 74.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for forgefile 0.1.0
File Interpreter ABI Platform
forgefile-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size:91.3 kB

Release files / forgefile-0.1.0.tar.gz

Download URL forgefile-0.1.0.tar.gz
Size 74.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d22876ff0caa824fb4ef2ce0c14876319ebdb50c48ed232ce17c2793d658d894
BLAKE2b-256 checksum
How to use checksums
3cf806304954e38eac732621265919121da584042013d3ad21e5ead75a4bcbaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release files / forgefile-0.1.0-py3-none-any.whl

Download URL forgefile-0.1.0-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d263a874cc43a3b865795392b1eac0480c7d481d503111916ea2c6cbe3c34610
BLAKE2b-256 checksum
How to use checksums
6721f2af2fddc9b65a559272a5b4c2b57c9a744a7150996da7a71801cb7e76c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 4, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.0 This release

2 release files

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