python3 -m pip install re_copilot --upgrade
- python 3.9+
- A Microsoft Account with access to https://bing.com/chat (Optional, depending on your region)
- Required in a supported country or region with New Bing (Chinese mainland VPN required)
- a) (Easy) Install the latest version of Microsoft Edge
- b) (Advanced) Alternatively, you can use any browser and set the user-agent to look like you're using Edge (e.g.,
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51
). You can do this easily with an extension like "User-Agent Switcher and Manager" for Chrome and Firefox.
- Get a browser that looks like Microsoft Edge.
- Open bing.com/chat
- If you see a chat feature, you are good to continue...
- Install the cookie editor extension for Chrome or Firefox
- Go to bing.com/chat
- Open the extension
- Click "Export" on the bottom right, then "Export as JSON" (This saves your cookies to clipboard)
- Paste your cookies into a file
bing_cookies.json
.- NOTE: The cookies file name MUST follow the regex pattern
bing_cookies.json
, so that they could be recognized by internal cookie processing mechanisms
- NOTE: The cookies file name MUST follow the regex pattern
- Open Edge (make sure you already enable developer tools)
- Go to [bing.com/chat](https://copilot.microsoft.com/chats
- Press F12 to open developer tools
- Switch to network tab
- Press Ctrl + F on developer tool window to search
- Search authorization and find request header that include authorization
- Copy all JWT token string after Bearer
import asyncio
import json
from pathlib import Path
from re_copilot import chat
async def main(jwt_token: str, cookies: list[dict], chat_text: str, reset_conversation: bool):
bot_response = await chat(jwt_token=jwt_token, cookies=cookies, chat_text=chat_text,
reset_conversation=reset_conversation)
print(bot_response)
if __name__ == "__main__":
your_jwt_token = ""
jwt_token = f"{your_jwt_token}"
cookies: list[dict] = json.loads(open(
str(Path(str(Path.cwd()) + "/bing_cookies.json")), encoding="utf-8").read())
try:
loop = asyncio.get_running_loop()
except RuntimeError:
loop = asyncio.get_event_loop()
loop.run_until_complete(
main(jwt_token=jwt_token, cookies=cookies, chat_text="Introduction yourself", reset_conversation=True))