unofficial-claude-api: brotli.error and 403
I was using the API a couple of days ago and it was working fine.
Errors:
When using create_chat() I got Message limit hit, cannot create chat… (which I know is incorrect because I have messages left) so I changed the code and printed the response.status_code and got 403
When using send_message() I get brotli.error: BrotliDecompress failed
When using get_all_chat_ids() I get an empty array (which I know is incorrect because I have conversations) so I changed the code and printed the response.status_code and got 403
What I have tried:
Changing the __BASE_URL from “https://claude.ai” to “https://api.claude.ai” Host in headers from “claude.ai” to “api.claude.ai”. Using a US VPN connection.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (9 by maintainers)
Nice!
Auto closing this issue once the new branch is published.
All works fine for me on the new branch. Thank you 🎉
It means your account has multiple organizations…
At this point what I can do is to retrieve by default the last element in this array by indexing with
-1since the latest organization will always be the last. And also leave an integer parameter inget_session_datacalledorganization_indexto override it.I’ve also made a section in the README, all changes are already in the attached branch of this issue, they will be merged after feedback.
I found out the reason behind
get_session_data()not working for me. It’s because at https://claude.ai/api/organizations I get 2 objects in the array and the data is different in each as you can see here (changed json to markdown because idk how to pretty print json here):So I had to change the 0 in this line to a 1 https://github.com/st1vms/unofficial-claude-api/blob/422581d5766163e3b2477f7cf3acd3c4bcc0d0c7/claude_api/session.py#L85
Since I already received complaints about this error, I decided to drop the Brotli decoding. Changes are already live on the new branch, but I don’t know if I’ll merge into main any time soon without some feedback…