Get started
Test mode
Test keys run the real engine on a fixed set of published sample files, at no cost, so you can build an integration before adding a payment method.
What a test key does
A key starting smol_test_ calls the same endpoints as a live key and runs the same engine. Nothing is mocked: the file you get back is a real result, produced with the options you sent. The response headers, the result object and the errors are the ones you will see in live mode.
There are three differences:
- A test key only accepts the published sample files. Any other file is refused.
- Test requests are free.
Smol-Billedis alwaysfalse, and a test job always hasbilled: false. - Test keys work as soon as the account exists. No payment method is needed.
Sample files
A sample file is recognised by the SHA-256 of its bytes. The name of the file does not matter. The bytes do: if you open a sample and save it again, or let a tool re-encode it, the hash changes and the file is no longer a sample. Download the files and send them unchanged.
There are 16 samples, one or more for each kind of file the API handles. The same list, with every hash, is at /api-samples/manifest.json.
| File | Size | What it is for |
|---|---|---|
animated.gif | 295 kB | A short animation. |
artwork.pdf | 20 kB | One page of flat artwork. |
artwork.png | 48 kB | Flat colour and shapes, where palette reduction matters. |
clip.mp4 | 6.9 MB | Four seconds of 1080p test video with sound. Video needs to be enabled on the account. |
orders.csv | 101 bytes | A small table with quoting, a line break and an accent. |
orders.json | 118 bytes | The same kind of table as JSON. |
photo.heic | 838 kB | An iPhone-style HEIC input. Photo from Pexels. |
photo.jpg | 498 kB | A photograph as a camera would save it. Photo by Mikael Blomkvist on Pexels. |
photo.png | 2.1 MB | The same kind of photograph as a PNG, where conversion pays off most. Photo from Pexels. |
photo.webp | 297 kB | A WebP input. Photo from Pexels. |
report.docx | 4 kB | A short Word document, for conversion to PDF as a job. |
sample.ttf | 118 kB | A TrueType font: Press Start 2P. The Press Start 2P Project Authors, SIL Open Font License 1.1. |
scans.pdf | 2.5 MB | Three pages of photographs, like a scanned document. Photos from Pexels. |
tone.mp3 | 803 kB | The same audio as a 320 kbit/s MP3. |
tone.wav | 3.5 MB | Twenty seconds of uncompressed stereo audio. |
with-metadata.jpg | 796 kB | A photo with made-up GPS, camera and author tags, for strip-metadata. Photo from Pexels. |
curl -O https://smolmac.com/api-samples/photo.jpg
shasum -a 256 photo.jpg
# dc57e874fed9ea671f5bcb57e68d7148e2ac09c0f6d3bf5cb647b33d6af8970aA file that is not on the list is refused with 402:
{
"error": {
"type": "billing_error",
"code": "test_mode_sample_required",
"message": "Test keys only work with the published sample files. Use a live key for your own files.",
"param": null,
"request_id": "req_Q2mY8sLx0aVn4TfB7kRd",
"doc_url": "https://smolmac.com/docs/reference/errors#test_mode_sample_required"
}
}Try it
Send a sample file exactly as you would send your own. Options work as usual, so you can test every format and setting that applies to the sample.
export SMOL_API_KEY="smol_test_..."
curl -X POST "https://api.smolmac.com/v1/compress?image.format=avif&image.quality=60" \
-H "Authorization: Bearer $SMOL_API_KEY" \
--data-binary @photo.jpg \
-o photo.avif -D -HTTP/1.1 200 OK
Content-Type: image/avif
Smol-Output-Format: avif
Smol-Kept-Original: false
Smol-Billed: false
RateLimit-Limit: 4
RateLimit-Remaining: 3
RateLimit-Reset: 1Some samples need a little more than the file:
| Sample | What to know |
|---|---|
orders.csv, orders.json | Text formats are recognised by their name. Add ?filename=orders.csv to a raw-body request, or send a multipart form. |
report.docx | Office documents run as jobs. Upload it and create a job with "operation": "convert". |
photo.heic | With image.format left at original the output would be HEIC, which is in limited preview. Unless HEIC output is enabled for the account, choose another format, such as image.format=avif. Strip metadata works on it as it is. |
clip.mp4 | Video runs as a job and is in limited preview. Unless video is enabled for the account, the job fails with feature_not_enabled. |
Limits in test mode
| Limit | Value |
|---|---|
| Request rate | 2 direct requests per second, with a burst of 4. The same on every plan. Above it you get 429 rate_limited with a Retry-After header. |
| File size, direct requests | 10 MB |
| Job input | An upload made with POST /v1/uploads, of up to 25 MB. A test key cannot use input.url, because the file has to be checked against the sample list before the job is accepted. It cannot start an upload in parts either: no sample is that large. |
| Everything else | The limits of the plan on the account. See Limits. |
The test rate limit is separate from the live one. Test traffic does not use up the rate allowance of your live keys.
Jobs and webhooks
Jobs work in test mode. Upload a sample file, create a job, and poll it or receive a webhook, exactly as in Large files and jobs. A job created with a test key carries livemode: false:
{
"id": "job_4tGZq0WnB8sYh2LdX6pC",
"object": "job",
"livemode": false,
"operation": "compress",
"status": "succeeded",
"billed": false
}The two modes are kept apart:
- A test key cannot read, download, delete or get a receipt for a live job. The API answers
404 not_found, as if the job did not exist. A live key cannot see test jobs either. GET /v1/jobslists only the jobs of the mode of the key that asks.- Webhook endpoints belong to the account, not to a mode. They receive events for test jobs and live jobs. Each event has a
livemodefield, so check it before you act on an event.
Going live
- Add a payment method or choose a plan in the dashboard.
- Create a live key.
- Replace the test key with the live key in your configuration. No other change is needed: the endpoints, the options and the responses are the same.
Keep a test key in your automated tests. The sample files do not change, so a test that sends a sample has a stable input and costs nothing to run. Usage made with a test key is reported separately: GET /v1/usage with a test key returns test usage only.