FireHead90544 / craiyon.py

Unofficial API Wrapper for craiyon.com (DAL-E-MINI). Generate awesome images from text tokens.
Apache License 2.0
69 stars 22 forks source link

v3 image generation throws a 403 error #15

Closed gillemic closed 1 year ago

gillemic commented 1 year ago

When trying to create images using the standard Craiyon client, it throws a 403 error from axios. Curious if this is caused by not having an API key with a paid subscription, or if they are down. Has been happening for at least 3 days now. Screenshot 2023-08-02 121148

gillemic commented 1 year ago

Sorry my mistake, this screenshot is for a similar library written in Node. But the python one you've created no longer works as well.

FireHead90544 commented 1 year ago

Sorry my mistake, this screenshot is for a similar library written in Node. But the python one you've created no longer works as well.

I just had a look at it myself and it seems like you say so. I'll be trying to get a workaround this and push the updates as soon as possible. Until then, please wait and make sure to update the library once the changes are pushed.

FireHead90544 commented 1 year ago

Since I am not near my workspace for a few days you might need to wait for around 2-3 days. Until then maybe @mdm9300404 can help if he's free, otherwise I'll just do that once I get back to it.

gillemic commented 1 year ago

Since I am not near my workspace for a few days you might need to wait for around 2-3 days. Until then maybe @mdm9300404 can help if he's free, otherwise I'll just do that once I get back to it.

No worries. I use this library for fun in my friend and I's discord server, and I've got a workaround in place to use v1 image generations as well. Just wanted to get the information out there!

mdm9300404 commented 1 year ago

Since I am not near my workspace for a few days you might need to wait for around 2-3 days. Until then maybe @mdm9300404 can help if he's free, otherwise I'll just do that once I get back to it.

It seems they have Cloudflare detecting Craiyon.py as a script and they're sending blocked/403 forbidden responses now. I'm trying to emulate a web browser to get around the block, but I haven't had any success yet.

It might also be related to cookies but I haven't tested whether or not that's the case yet.

MysticalVictini commented 1 year ago

Yeah, it appears using a simple request on their api isn't working anymore. I am trying to figure out how to bypass it still.

FireHead90544 commented 1 year ago

The library was breaking due to Craiyon implementing Cloudflare's anti-bot protection page. Bypassed it in the v1.1.0 by using CloudScraper. Please update the wrapper to the latest version by running pip install -U craiyon.py before using it.

gillemic commented 1 year ago

The library was breaking due to Craiyon implementing Cloudflare's anti-bot protection page. Bypassed it in the v1.1.0 by using CloudScraper. Please update the wrapper to the latest version by running pip install -U craiyon.py before using it.

I am still getting an error with this. Now it is throwing a 'Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8' error. Passing content_type='text/html' to the .json() method in the library does not help either.

guisua commented 1 year ago

Also not working either with 1.1.0 but with slightly different error:

raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

happening in the generate:L43 function for v3.

Edit: Additional info: the above error as described by @gillemic happens when using the async_generate.