import requests
base = "https://api.fildraai.com/api/v1"
headers = {"X-Api-Key": "YOUR_USER_API_KEY"}
img_path = "/absolute/path/to/maize_leaf.jpg"
presign = requests.post(
f"{base}/image_diagnosis/uploads/presign",
headers=headers,
json={"content_type": "image/jpeg", "size_bytes": 204800},
timeout=30,
).json()
put_url, raw_key = presign["put_url"], presign["raw_key"]
with open(img_path, "rb") as fh:
requests.put(put_url, data=fh, headers={"Content-Type": "image/jpeg"}, timeout=60).raise_for_status()
response = requests.post(
f"{base}/image_diagnosis/infer/basic",
headers=headers,
json={"plant": "maize", "raw_key": raw_key, "top_k": 3, "locale": "en-us"},
timeout=60,
)
response.raise_for_status()
print(response.json())
const base = 'https://api.fildraai.com/api/v1';
const headers = { 'X-Api-Key': 'YOUR_USER_API_KEY' };
async function diagnoseImage(file) {
const presign = await (await fetch(`${base}/image_diagnosis/uploads/presign`, {
method: 'POST',
headers: { ...headers, 'Content-Type': 'application/json' },
body: JSON.stringify({ content_type: file.type || 'image/jpeg', size_bytes: file.size }),
})).json();
await fetch(presign.put_url, { method: 'PUT', headers: { 'Content-Type': file.type || 'image/jpeg' }, body: file });
const response = await fetch(`${base}/image_diagnosis/infer/basic`, {
method: 'POST',
headers: { ...headers, 'Content-Type': 'application/json' },
body: JSON.stringify({ plant: 'maize', raw_key: presign.raw_key, top_k: 3, locale: 'en-us' }),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json();
}
Postman is the fastest way to verify your API key and image work before wiring up code. The steps below mirror what the Python and JavaScript snippets do above: presign, PUT the bytes, then infer with the raw_key. Posting the image straight to the infer endpoint as form-data is not supported and returns 400.
Screenshot 1
Presign request (POST .../uploads/presign)
Show Postman with POST selected, the presign URL pasted in, and the raw JSON body. Filename:
postman_diagnosis_01_url.png
Screenshot 2
Adding the X-Api-Key header
Headers tab with one row visible: X-Api-Key + your masked key value. Filename:
postman_diagnosis_02_header.png
Screenshot 3
Infer request: raw JSON body with plant + raw_key
Body tab, raw + JSON selected, showing plant and the raw_key from the presign step. Filename:
postman_diagnosis_03_formdata.png
Screenshot 4
200 response with predictions
Response pane showing 200 status + pretty-printed JSON with a predictions array. Filename:
postman_diagnosis_04_response.png