Quickstart

Your first generation with a test key, in three steps.

The quality of your photo strongly affects the result. Read the photo guide.

Test keys never use credits: they run the whole flow and return a sample image. Run the code on your server or your own machine, not in a browser.

Get a test key

Your test key comes with your dashboard invitation. To ask for access, email hello@foodshot.ai.

Store the key as an environment variable:

Terminal
export FOODSHOT_API_KEY="fs_test_..."

Create a generation

Send a photo and a style. This code sends our sample dish photo: replace it with your photo's https URL. The Idempotency-Key is one new UUID per photo.

In Node or Python, save the code as quickstart.mjs or quickstart.py; step 3 adds to the same file.

curl https://api.foodshot.ai/v1/generations \
  -H "Authorization: Bearer $FOODSHOT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "image_url": "https://docs.foodshot.ai/samples/dish.jpg",
    "style_id": "pure-shot"
  }'

The answer is 202 Accepted with the new generation (shortened here):

JSON
{
  "id": "gen_4Kq9xT2mVb7Zp1Ls8Hc3Rw",
  "object": "generation",
  "status": "queued",
  "style_id": "pure-shot",
  "resolution": "4k",
  "output": null
}

Get the result

Check the generation until its status is succeeded or failed, then download the file. In production, a webhook tells you when a job is done, so you don't have to poll.

# GENERATION_ID is the id from step 2. Repeat until "status" is "succeeded" or "failed".
curl https://api.foodshot.ai/v1/generations/$GENERATION_ID \
  -H "Authorization: Bearer $FOODSHOT_API_KEY"

# OUTPUT_URL is "output.url" from the answer. No key is needed.
curl -o result.jpg "$OUTPUT_URL"

A finished generation has an output (shortened here):

JSON
{
  "id": "gen_4Kq9xT2mVb7Zp1Ls8Hc3Rw",
  "object": "generation",
  "environment": "test",
  "status": "succeeded",
  "resolution": "4k",
  "output": {
    "url": "https://api.foodshot.ai/v1/files/gen_4Kq9xT2mVb7Zp1Ls8Hc3Rw/image.jpg?exp=1792406595&sig=VT5DMYyFzJsUzoKdU9fob--vTZ1Nx5PFShO290vXCjc",
    "content_type": "image/jpeg",
    "width": 2048,
    "height": 2048
  }
}

The link works for 24 hours, and the file is deleted after 30 days, so keep your own copy.

With a test key, the result is a 2K sample image marked SAMPLE. With a live key, the same code returns your real result and uses 1 credit.

On this page