Skip to main content

factorial-compute

One API for AI compute that returns typed answers — text, images, masks, detections, depth, documents, transcripts, speech, video, 3D models, tracks — in the same shape whichever model or supplier produced it.

pip install factorial-compute
factorial login inv_...        # once: saves your key for every script and agent here
from factorial_compute import Client

f = Client()  # the key `factorial login` saved, or FACTORIAL_API_KEY if set

# Text, and JSON on request.
print(f.run(model="gpt-oss-120b", input="Name three uses for a forklift.").text)

# An image from a prompt.
result = f.run(model="flux-schnell", input={"prompt": "a red forklift in a warehouse"})
result.images[0].save("forklift.jpg")

# Masks: one per object, each with a box measured from the mask.
result = f.run(model="sam2-segment", input={
    "image": "warehouse.jpg",                      # a local path: uploaded for you
    "objects": [{"id": "pallet", "box": [40, 60, 300, 280]},
                {"id": "cone", "point": [512, 240]}],
})
for mask in result.masks:
    print(mask.id, mask.box)
    mask.save(f"{mask.id}.png")

# A transcript, with timestamps.
result = f.run(model="whisper", input={"audio": "meeting.mp3"})
print(result.transcript.text)
for segment in result.transcript.segments:
    print(f"{segment.start:6.1f}s  {segment.text}")

That is the whole surface for most work: run() with a model id and an input, then read the typed answer.

Rules worth knowing

  • Files go in by path, URL or bytes under the keys image, images, audio and video - for vision chat models too. The client uploads them and sends a reference.
  • Answers are typed. .text, .images, .masks, .detections, .depth, .document, .transcript, .audio, .video, .mesh, .tracks. Asking a result for the wrong kind raises, rather than returning something empty.
  • Boxes are [x0, y0, x1, y1] in pixels everywhere, so a box from a vision model or a detector can be sent straight to a segmenter.
  • Files come back as handles. .save(path) writes one; .read() returns the bytes. They stay on the server until you ask.
  • Retries are safe. Every run() carries an idempotency key and is retried on connection failures and on 429/502/503/504, so a retry never runs — or bills — the work twice.
  • Errors say what to change. A refused input raises InvalidInput whose message names the field and a value that works.
  • Reasoning models think before they answer, and the thinking counts against max_tokens. Too low a cap is spent thinking: .text then raises IncompleteAnswer rather than returning "". Give reasoning models a few thousand tokens, or send reasoning_effort="low" to think less.
  • Every result says what it cost: result.cost.usd, alongside result.timing.duration_ms. f.quote(model=..., input=...) says it before anything runs; max_cost_usd= on run() or submit() refuses a call that would cost more, raising CostCapExceeded.
  • Answers chain. Pass an earlier answer's file as an input - {"image": result.images[0]} - and it goes by reference, never downloaded and uploaded again.
  • Several models as one workload: with f.workflow() as w: - each w.run(...) returns at once, an input can name an earlier step's answer (photo.image, seen.text), and the server runs steps as their inputs become ready, in parallel, with one status, one cost and the whole graph.
  • Submitted work can call back: submit(..., webhook_url=...) posts the id and status when it finishes; fetch the execution for the answer.
  • Masks and boxes draw onto the photo: result.masks.draw(photo, "out.png") tints and numbers every mask, mask.layer(photo, colour) gives one see-through layer for stacking in HTML, result.detections.draw(...) boxes.
  • Usage is in the model's own unit: tokens, images, audio_seconds, characters, video_seconds_generated, object_seconds, meshes. result.usage.units has it.

Which models exist

for model in f.models.catalog():
    print(model["id"], model.get("output"), model["unit"])
    print("  ", model["example"])

The catalogue lists the models you can call right now (catalog(all=True) for everything, with availability saying which are offline). Each entry says what kind of answer it returns (output), what every input field means (input), and gives an example input that works as written.

Longer work

handle = f.submit(model="flux-schnell", input={"prompt": "..."})
result = handle.wait()

submit returns before the work runs and survives your process exiting.

Metadata

Release files for factorial-compute 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for factorial-compute 0.0.7
File Size Uploaded
factorial_compute-0.0.7.tar.gz 34.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for factorial-compute 0.0.7
File Interpreter ABI Platform
factorial_compute-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 71.4 kB

Release files / factorial_compute-0.0.7.tar.gz

Download URL factorial_compute-0.0.7.tar.gz
Size 34.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d156cae07a1244d0a793b78e7ce2b65b99ad72338efc7c5db4431115a37e9c78
BLAKE2b-256 checksum
How to use checksums
154a9b46b3cb44337ff8c700793910a2592e698afe3f27ee937b287f5430e9d3
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 Oct 1, 2026.

Transparency log

Release files / factorial_compute-0.0.7-py3-none-any.whl

Download URL factorial_compute-0.0.7-py3-none-any.whl
Size 37.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
300ae99855ebe4340888afed5bbaec42f24fd776468ec197f8150490f3b7db87
BLAKE2b-256 checksum
How to use checksums
631fc0bdd5217c38f4f008e75521c9f75544076960682522c524855148aa7169
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 Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.0

2 release files

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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