[UNMAINTAINED] A reverse engineered Python API wrapper for Quora's Poe, which provides free access to ChatGPT, GPT-4, and Claude.
[UNMAINTAINED] A reverse engineered Python API wrapper for Quora's Poe, which provides free access to ChatGPT, GPT-4, and Claude.
This is a reverse engineered API wrapper for Quora's Poe, which allows you free access to OpenAI's ChatGPT and GPT-4, as well as Anthropic's Claude.
Table of contents generated with markdown-toc.
You can install this library by running the following command:
pip3 install poe-apiThis library depends on quickjs, which does not have prebuilt binaries available for Python 3.11. Pip will attempt to compile it, but will fail if python-dev is not installed.
On Linux, you can install it via the instructions listed here: https://stackoverflow.com/questions/21530577/fatal-error-python-h-no-such-file-or-directory
On Windows and MacOS, python-dev should be included with your existing Python installation.
Examples can be found in the /examples directory. To run these examples, pass in your token as a command-line argument.
python3 examples/temporary_message.py "TOKEN_HERE"Log into Poe on any desktop web browser, then open your browser's developer tools (also known as "inspect") and look for the value of the p-b cookie in the following menus:
Note that excessive usage of this library may lead to your account getting banned. It is recommended that you set your own rate limits, and that you use an alt account that you don't value. See issue #118 for more details. If your requests are infrequent, the risk for a ban is very low.
To use this library, simply import poe and create a poe.Client instance. The Client class accepts the following arguments:
token - The token to use. proxy = None - The proxy to use, in the format protocol://host:port. The socks5h protocol is recommended, as it also proxies the DNS queries.device_id = None - The device ID to use. If this is not specified, it will be randomly generated and stored on the disk. headers = headers - The headers to use. This defaults to the headers specified in poe.headers.client_identifier = client_identifier - The client identifier that will be passed into the TLS client library. This defaults to the one specified in poe.client_identifier.formkey = None - The formkey to use. Only supply this option if initializing the client without it fails. You can find this value by going into your browser's devtools, looking in the network tab for a gql_POST request, and taking the value of the poe-formkey request header. The formkey that you use must come from a browser that matches the headers that you've set in poe.headers. Keep in mind that the default browser is Chromium 112.Regular Example:
import poe
client = poe.Client("TOKEN_HERE")Proxied Example:
import poe
client = poe.Client("TOKEN_HERE", proxy="socks5h://178.62.100.151:59166")Note that the following examples assume client is the name of your poe.Client instance. If the token is invalid, a RuntimeError will be raised.
The client downloads all of the available bots upon initialization and stores them within client.bots. A dictionary that maps bot codenames to their display names can be found at client.bot_names. If you want to refresh these values, you can call client.get_bots. This function takes the following arguments:
download_next_data = True - Whether or not to re-download the __NEXT_DATA__, which is required if the bot list has changed.print(json.dumps(client.bot_names, indent=2))
"""
{
"chinchilla": "ChatGPT",
"a2": "Claude-instant",
"capybara": "Assistant",
"a2_100k": "Claude-instant-100k",
"llama_2_7b_chat": "Llama-2-7b",
"llama_2_13b_chat": "Llama-2-13b",
"a2_2": "Claude-2-100k",
"llama_2_70b_chat": "Llama-2-70b",
"agouti": "ChatGPT-16k",
"beaver": "GPT-4",
"vizcacha": "GPT-4-32k",
"acouchy": "Google-PaLM"
}
"""Note that, on free accounts, Claude+ (a2_2) has a limit of 3 messages per day and GPT-4 (beaver) has a limit of 1 message per day. Claude-instant-100k (c2_100k) is completely inaccessible for free accounts. For all the other chatbots, there seems to be a rate limit of 10 messages per minute.
To get a list of 3rd party bots, use client.explore_bots, which accepts the following arguments:
end_cursor = None - The cursor to use when fetching the list. count = 25 - The number of bots that is returned.The function will return a dict containing a list of bots and the cursor for the next page:
…To get a specific third party bot, you can use client.get_bot_by_codename, which accept's the bot's codename as its only argument.
client.get_bot_by_codename("JapaneseTutor")Since display names are the same as the codenames for custom bots, you can simply pass the bot's display name into client.send_message to send it a message.
You can create a new bot using the client.create_bot function, which accepts the following arguments:
handle - The handle of the new bot.prompt = "" - The prompt for the new bot.display_name = None - The display name for the new bot.base_model = "chinchilla" - The model that the new bot uses. This must be either "chinchilla" (ChatGPT) or "a2" (Claude). If you've subscribed, you can use "beaver" (ChatGPT4) or "a2_2"` (Claude-2-100k).description = "" - The description for the new bot.intro_message = "" - The intro message for the new bot. If this is an empty string then the bot will not have an intro message.prompt_public = True - Whether or not the prompt should be publicly visible. pfp_url = None - The URL for the bot's profile picture. Currently, there is no way to actually upload a custom image using this library.linkification = False - Whether or not the bot should turn some text in the response into clickable links.markdown_rendering = True - Whether or not to enable markdown rendering for the bot's responses.suggested_replies = False - Whether or not the bot should suggest possible replies after each response.private = False - Whether or not the bot should be private.temperature = None: - The temperature for the new bot.Use these arguments if you want the new bot to use your own API (as detailed here):
api_key = None - The API key for the new bot. api_bot = False - Whether or not the bot has API functionally enabled.api_url = None - The API URL for the new bot.A full example of how to create and edit bots is located at examples/create_bot.py.
new_bot = client.create_bot(bot_name, "prompt goes here", base_model="a2")You can edit a custom bot using the client.edit_bot function, which accepts the following arguments:
bot_id - The botId of the bot to edit. This can also be set to None.handle - The handle for the bot you're editing.prompt - The new prompt for the bot.new_handle = None - The new handle for the bot. By default the handle will not change.display_name = None - The new display name for the bot.base_model = "chinchilla" - The new model that the bot uses. This must be either "chinchilla" (ChatGPT) or "a2" (Claude). If you've subscribed, you can use "beaver" (ChatGPT4) or "a2_2"` (Claude-2-100k).description = "" - The new description for the bot.intro_message = "" - The new intro message for the bot. If this is an empty string then the bot will not have an intro message.prompt_public = True - Whether or not the prompt should be publicly visible. pfp_url = None - The URL for the bot's profile picture. Currently, there is no way to actually upload a custom image using this library.linkification = False - Whether or not the bot should turn some text in the response into clickable links.markdown_rendering = True - Whether or not to enable markdown rendering for the bot's responses.suggested_replies = False - Whether or not the bot should suggest possible replies after each response.private = False - Whether or not the bot should be private.temperature = None: - The new temperature for the this bot.Bot API related arguments:
api_key = None - The new API key for the bot. api_url = None - The new API URL for the bot.A full example of how to create and edit bots is located at examples/create_bot.py.
edit_result = client.edit_bot(1086981, "bot_handle_here", base_model="a2")You can use the client.send_message function to send a message to a chatbot, which accepts the following arguments:
chatbot - The codename of the chatbot. (example: capybara)message - The message to send to the chatbot.with_chat_break = False - Whether the conversation context should be cleared.timeout = 20 - The max number of seconds in between received chunks until a RuntimeError is raised. async_recv = True - Whether or not to make the receive_POST request async. If this is disabled, then there will be an extra wait of about 3 seconds after the message is complete.suggest_callback = None - Callback for suggested replies. See examples/send_message.py for an example on how to use this.The function is a generator which returns the most recent version of the generated message whenever it is updated.
Streamed Example:
message = "Summarize the GNU GPL v3"
for chunk in client.send_message("capybara", message):
print(chunk["text_new"], end="", flush=True)Non-Streamed Example:
message = "Summarize the GNU GPL v3"
for chunk in client.send_message("capybara", message):
pass
print(chunk["text"])You can also send multiple messages in parallel using threading and receive their responses separately, as demonstrated in /examples/parallel_messages.py. Note that if you send messages too fast, the server will give an error, but the request will eventually succeed.
The client.is_busy function can be used to check if ther
No open issues yet, or sync has not completed.