From a6246fbaac216b1bf144af3b9cbd4ef0a4b9de78 Mon Sep 17 00:00:00 2001 From: xytraaaa <143930236+Xytra-zn@users.noreply.github.com> Date: Sat, 13 Sep 2025 21:04:06 +0530 Subject: [PATCH] Fix KeyError in python example code KeyError was coming when code tries to access `image` field from `data` returned from api. Fixed by changing data['image'] to data['result']['image'] --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3d09cb9..4eded2e 100644 --- a/README.md +++ b/README.md @@ -412,7 +412,7 @@ def simple_example(): print(f"Error: {data['error']}") return - img = base64.b64decode(data['image']) + img = base64.b64decode(data['result']['image']) with open('simple-quote.png', 'wb') as f: f.write(img) print("Saved simple-quote.png") @@ -457,7 +457,7 @@ def complete_example(): # Option 1: Using the regular endpoint (returns base64) r = requests.post('https://bot.lyo.su/quote/generate', json=payload) data = r.json() - img = base64.b64decode(data['image']) + img = base64.b64decode(data['result']['image']) with open('quote.png', 'wb') as f: f.write(img) print("Saved quote.png")