Skip to main content

A reverse engineered API wrapper for Quora's Poe

Project description

Python Poe API

PyPi Version

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 Antropic's Claude.

Features:

  • Log in with token
  • Download bot list
  • Send messages
  • Stream bot responses

Installation:

You can install this library by running the following command:

pip3 install poe-api

Documentation:

An example can be be found in /examples/example.py.

Using the Client:

To use this library, simply import poe and create a poe.Client instance, passing in your token as the only argument. You can find your token in the p-b field in your browser's cookies.

import poe
client = poe.Poe("TOKEN_HERE")

Note that the following examples assume client is the name of your poe.Client instance.

Downloading the Available Bots:

The client downloads all of the available bots upon initialization and stores them within poe.Client.bots. A dictionary that maps bot codenames to their display names can be found at poe.Client.bot_names. If you want to refresh these values, you can call poe.Client.get_bots.

print(client.bot_names)
#{'capybara': 'Sage', 'beaver': 'GPT-4', 'a2_2': 'Claude+', 'a2': 'Claude', 'chinchilla': 'ChatGPT', 'nutria': 'Dragonfly'}

Sending Messages:

You can use the poe.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.

The function is a generator which returns the most recent version of the generated message whenever it is updated.

Streamed Example:

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"])

Misc:

Changing the Logging Level:

If you want to show debug messages, simply call poe.logger.setLevel.

import poe
poe.logger.setLevel(logging.INFO)

Setting a Custom User-Agent:

If you want to change the user-agent that is being spoofed, set poe.user_agent.

import poe
poe.user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"

Copyright:

This program is licensed under the GNU GPL v3. All code, with the exception of the GraphQL queries, has been written by me, ading2210.

Most of the GraphQL queries are taken from muharamdani/poe, which is licenced under the ISC License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poe-api-0.0.1.tar.gz (20.4 kB view details)

Uploaded Source

File details

Details for the file poe-api-0.0.1.tar.gz.

File metadata

  • Download URL: poe-api-0.0.1.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for poe-api-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5ecc2f40886a1ad0671cf4f7de9ffb95e9f0aa8f43272bdef8df5043de424385
MD5 4cd5b767d98a31ebcd4382851924c187
BLAKE2b-256 97bea70f94cdd098348294d4bdc072229b36595bfa49c2597cb8cb959d4bb7d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page