KoushikNavuluri / Claude-API

This project provides an unofficial API for Claude AI, allowing users to access and interact with Claude AI .
https://pypi.org/project/claude-api/
MIT License
747 stars 122 forks source link

send_message stopped working, is any changes on Claude? #94

Open gregmichels opened 9 months ago

gregmichels commented 9 months ago

I checked the model, but it seems they using another payload? Have anybody experienced the same issues with send_message?

gregmichels commented 9 months ago

@KoushikNavuluri @jhchenchong guys, sorry for putting up, something with https://claude.ai/api/append_message, am I right? Endpoint disabled

Lxb921006 commented 9 months ago

yes,the same problem: {"error":{"type":"permission_error","message":"Endpoint disabled"}}。It's completely unusable

gregmichels commented 9 months ago

yes,the same problem: {"error":{"type":"permission_error","message":"Endpoint disabled"}}。It's completely unusable

I'm on half way - they changed the payload structure - so for quick fix is to change URL and payload structure as below:

url = f"https://claude.ai/api/organizations/{self.organization_id}/chat_conversations/{conversation_id}/completion" 

payload = json.dumps({
    "prompt": prompt,
    "timezone": "Asia/Singapore",
    "model": f"claude-{self.model_version}",
    "attachments": [],
    "files": []
})
Lxb921006 commented 9 months ago

Yes, I also noticed that it has been modified 11

gregmichels commented 9 months ago

Now I see cookies started to change from chat opening - can't repeat my success path yet. Investigation in progress, lemme know if you also find smth please

Lxb921006 commented 9 months ago

Yes, but this does not affect the use of this Claude API. I have called this Claude API several times for testing and have not found any problems

gregmichels commented 9 months ago

OK, now what we have:

1) different URL for send_message and payload as above 2) cookie now should be retrieved (once during login) from the chat window and request with a model name like claude-2.1 or instant - doesn't matter. This cookie can change from time to time - but it doesn't matter 3) Important - response from Claude now should be retrieved in separate GET - they are providing whole dialogue in response.

So it is like POST -> GET + filter/associate with your POST as uuid and generated chronologically.

I would not share my code, as this is not optimal but an emergency. But the general thing is above. Files work as before through attachments.

johnd0e commented 9 months ago

See fix is here https://github.com/st1vms/unofficial-claude2-api/commit/e2d1b57bcf0dad8bfc545a53f250ec670e5d01f3

inconnu26 commented 9 months ago

See fix is here st1vms/unofficial-claude2-api@e2d1b57

Great ! How long before the fix is available through "pip install claude-api" command ? Also, I keep getting "{"type":"permission_error","message":"Endpoint disabled"}}" error. Is it my cookie ? I tried many times but I keep getting this issue. Thank you for your help !

gregmichels commented 9 months ago

Hi Team, have you ever met an error with {"success":false,"error":"BrotliDecompress failed"}

I don't understand why sometimes there BrotliDecompress issue when retrieving the response Its random and I can't repeat properly

AshwinPathi commented 8 months ago

I just put up a fix here on my version: https://github.com/AshwinPathi/claude-api-py. Give it a try and let me know if it works.