-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.sh
executable file
·43 lines (33 loc) · 1.17 KB
/
sample.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Use 'demo' mode just to try api4ai for free. Free demo is rate limited.
# For more details visit:
# https://api4.ai
#
# Use 'rapidapi' if you want to try api4ai via RapidAPI marketplace.
# For more details visit:
# https://rapidapi.com/api4ai-api4ai-default/api/alcohol-label-recognition/details
MODE="demo"
# Your RapidAPI key. Fill this variable with the proper value if you want
# to try api4ai via RapidAPI marketplace.
RAPIDAPI_KEY=""
# Define URL and headers.
if [[ "${MODE}" == "demo" ]]; then
URL="https://demo.api4ai.cloud/alco-rec/v1/results"
HEADERS="A4A-CLIENT-APP-ID: sample" # optional header
elif [[ "${MODE}" == "rapidapi" ]]; then
URL="https://alcohol-label-recognition.p.rapidapi.com/v1/results"
HEADERS="X-RapidAPI-Key: ${RAPIDAPI_KEY}"
else
echo "Unsupported sample mode"
exit 1
fi
# Path or URL to image.
IMAGE=${1:-"https://storage.googleapis.com/api4ai-static/samples/alco-rec-1.jpg"}
# POST.
if [[ "${IMAGE}" =~ "://" ]]; then
# POST image via URL.
curl -s -X POST -H "${HEADERS}" "${URL}" -F "url=${IMAGE}"
else
# POST image as file.
curl -s -X POST -H "${HEADERS}" "${URL}" -F "image=@${IMAGE}"
fi