Files on WriftAI are now stable. You can send files to models and get files back without setting up storage or hosting of your own.
A model that takes a file as input, or returns one as output, uses one of two forms: an HTTP URL or a base64 data URL. Until now, input meant passing a URL to a file you hosted yourself, and output came back as a base64 data URL. A base64 data URL embeds the file's contents in the URL itself. It is about a third larger than the file and has to be held in memory in full, so it only suits small files.
WriftAI now hosts the file for you. Upload a file and you get an HTTP download URL back that you can pass to a model. Large files are uploaded in parallel parts to keep big transfers fast, and downloads are served through a CDN.
This guide uploads and uses a file end to end. You will transcribe a recording with systran/faster-whisper-large-v3.
What you need
- A WriftAI account and an Access Token
- An audio or video file. The examples use
interview.mp3
Transcribe a recording
The official clients automatically detect and upload files for you when creating a prediction. This model takes its audio in an input field called audio, so the file goes there. If your recording already has a URL, you can skip the upload and pass it directly, as the cURL tab shows.
1from pathlib import Path2from wriftai import Client, File34# Instantiate the WriftAI client5wriftai = Client()67# The file is uploaded automatically before the prediction is created8prediction = wriftai.predictions.create(9 model="systran/faster-whisper-large-v3",10 input={"audio": File(Path("interview.mp3"))},11)
Remember that predictions are asynchronous by default, so creating one returns before the model finishes. To get the transcript, pass the wait option when you create it, which waits for the result or up to the time you give it, or set up webhooks to be notified when it is ready.
Upload a file on its own
Sometimes you want the file on WriftAI before you create any prediction, for example to run the same recording through more than one model. Upload it and you get a download URL back:
1from pathlib import Path2from wriftai import Client, File34# Instantiate the WriftAI client5wriftai = Client()67# Upload a file, large files are split into parts and uploaded concurrently automatically8result = wriftai.files.upload(File(Path("interview.mp3")))910print(result["download_url"])
The upload guide explains each step of the upload.
A few things worth knowing
- The download URL is the only way to refer to a file. Save it. If you lose it, upload the file again.
- Files are deleted 90 minutes after the upload completes. Within that window you can reuse the same URL. After it, upload the file again.
- An upload you have not completed expires after 20 minutes. Create a new one.
- The maximum file size is 1 GB. We are working on increasing this limit.
Right now files are temporary. We are working on persistent files that you can view, manage, and request new download URLs for, with configurable expiration or no expiry at all.
Download a file
The download URL is signed, so downloading needs no authentication. Files are served through a CDN, and range requests are supported, so you can download a file in parallel parts. Every request counts toward the URL's rate limit, so keep the number of parallel requests within it.
Use files in the playground
File inputs also work in the playground UI. When a model takes a file, its playground lets you select a file to upload and run, or pass an existing URL, with no code required.
Further reading
- Files overview: What WriftAI handles for you
- Upload files: How uploads work under the hood
- Use files with models: URL and base64 forms, and more input options
- Rate limits: How rate limits apply to files