Documentation menu

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-Billed is always false, and a test job always has billed: 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.

FileSizeWhat it is for
animated.gif295 kBA short animation.
artwork.pdf20 kBOne page of flat artwork.
artwork.png48 kBFlat colour and shapes, where palette reduction matters.
clip.mp46.9 MBFour seconds of 1080p test video with sound. Video needs to be enabled on the account.
orders.csv101 bytesA small table with quoting, a line break and an accent.
orders.json118 bytesThe same kind of table as JSON.
photo.heic838 kBAn iPhone-style HEIC input. Photo from Pexels.
photo.jpg498 kBA photograph as a camera would save it. Photo by Mikael Blomkvist on Pexels.
photo.png2.1 MBThe same kind of photograph as a PNG, where conversion pays off most. Photo from Pexels.
photo.webp297 kBA WebP input. Photo from Pexels.
report.docx4 kBA short Word document, for conversion to PDF as a job.
sample.ttf118 kBA TrueType font: Press Start 2P. The Press Start 2P Project Authors, SIL Open Font License 1.1.
scans.pdf2.5 MBThree pages of photographs, like a scanned document. Photos from Pexels.
tone.mp3803 kBThe same audio as a 320 kbit/s MP3.
tone.wav3.5 MBTwenty seconds of uncompressed stereo audio.
with-metadata.jpg796 kBA photo with made-up GPS, camera and author tags, for strip-metadata. Photo from Pexels.
download one and check it
curl -O https://smolmac.com/api-samples/photo.jpg
shasum -a 256 photo.jpg
# dc57e874fed9ea671f5bcb57e68d7148e2ac09c0f6d3bf5cb647b33d6af8970a

A file that is not on the list is refused with 402:

402 response
{
  "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.

bash
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 -
response headers (shortened)
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: 1

Some samples need a little more than the file:

SampleWhat to know
orders.csv, orders.jsonText formats are recognised by their name. Add ?filename=orders.csv to a raw-body request, or send a multipart form.
report.docxOffice documents run as jobs. Upload it and create a job with "operation": "convert".
photo.heicWith 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.mp4Video 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

LimitValue
Request rate2 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 requests10 MB
Job inputAn 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 elseThe 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:

job object (shortened)
{
  "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/jobs lists 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 livemode field, so check it before you act on an event.

Going live

  1. Add a payment method or choose a plan in the dashboard.
  2. Create a live key.
  3. 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.