-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use CAI's mobile version endpoints #104
Comments
I never thought of that, but that actually sounds like a good idea |
How would you find those endpoints though? |
Use an android emulator and a reverse proxy like Fiddler or WireShark |
Yeah that's what I was thinking. An emulator like https://appetize.io and inspect HTTP requests |
For free users a session doesn't last long so you'd need to install the app quick and sign in |
Nevermind, you can't install apps on there for whatever reason |
Character AI without Puppeteer How to get WebSocket token and chat id?
|
@catvinyl you're joking, right??? How the heck did you actually make an API without cloudflare catching you? |
its only a matter of time till the staff catches up.. |
@realcoloride lol, true... I've got to test out this script |
Alright, keep me updated! |
Ok. It seems to work but I'm getting an error because I didn't provide the right chat_id. I inspected the /ws/ request in the Network tab of Firefox, but it's empty. There's no response data from the websocket in the console. Is there any other way to get the chat id? |
@Parking-Master you need send message to AI, then check out for GET request with status 101. You can also choose filter for WS requests. Check that you're using https://beta.character.ai/chat2?char=... but not https://beta.character.ai/chat?char=... |
My implementation is simple, but it can be broken with async requests, so you need to use await, and it skips to the fully generated answer. You can get a streamed answer (but it needs to be implemented).
It is possible that the WS API has more commands. https://beta.character.ai/chat2?char=... https://beta.character.ai/chat?char=... |
Oh, I got it. That's why. I was only using the first chat |
Yep, I'm still getting an empty response |
@Parking-Master I upgraded the script. Now it can create chat. Try only putting in a token. You can also try "debug = true" to see what's wrong. |
Nice! I'll try it when I get a chance. I was able to get the token pretty easily |
@catvinyl it works awesome, and responds really fast! One thing you should add though is like what we currently have, |
@Parking-Master you can continue chat. You need to replace const chat = await characterAI.createChat(character_id);
const chat_id = getChatId(chat); with const chat_id = 'xxxxyyyy-bbbb-cccc-dddd-eeeeffff1111'; |
Yep, but the problem is, I don't know the chat id lol. Besides, even if I did, I want to continue the "original" chat (like "/chat?char=...") and I don't think that one has an id. I've tried inspecting multiple socket requests on the page on Chrome and Firefox and they both say it's empty. I don't know what else I can do. |
I even asked the AI himself and he gave me a valid-looking chat_id but it's still invalid |
I don't think AI have information about chat_id. When you run script it says
Then you need put that to chat_id. "?char=YntB_ZeqRq2l_aVf2gWDCZl4oBttQzDvhj9cXafWcF8" This is not chat_id. |
@catvinyl ok, so I did in fact find the chat ID on the page. It worked, but the stream stops every time the AI stutters, so I found a way to return the response soon as the AI is done talking. It works great, less resources, no puppeteer, and lightning fast! Thank you so much for making this small script. I've adapted it to my own needs. |
do you mind uploading the package, because rn with puppeteer it takes too long to get a response and mostly failed response |
@Mr-TIME-c I don't mind uploading a package for this, but I don't want to take credit for realcoloride's work. I will upload a package soon but I will also try it help with this package to make it without puppeteer and make it faster. |
Hello again, this looks good and could help a lot in the process. However, I would like to probably make a way to use the old puppeteer method and this new one. But judging by how it looks like it works, this would require much more effort to convert and find all new endpoints |
Could you just list them all from the current code base? (see chat and message and client) |
I've published my own package! @parking-master/node_characterai |
Worth the look but looks very messy in my opinion. |
@realcoloride okay, just a recommendation haha :) I hope there's an easy way to get the mobile version endpoints though... have you experimented yet? |
I wish I could talk in-depth about my searches (mainly reverse engineering) of the mobile app but I fear of if it complies legally or with their ToS. |
Yep, I always do a deep search in the company's ToS before making unofficial APIs like this, because I don't want to get in trouble. I'll do some research too. |
If you got the mobile version endpoints make sure to get the new group chat endpoints as well as it uses a different and improved chat model that's not available through the browser. |
The mobile endpoints use new the endpoints. See #180 |
Hello,
As you may have noticed, characterAI released their mobile app and I would like to know if it would be interesting to perhaps try to see if using their endpoints or if they have useragents or endpoints that could be used for easier automation.
The text was updated successfully, but these errors were encountered: