百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

Bard

> 编程语言
开源

Python SDK/API(用于反向工程 Google Bard)

1.4K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Python SDK/API(用于反向工程 Google Bard)

巴德

Google Bard 聊天机器人 API 的逆向工程

安装

bash
 $ pip3 install --upgrade GoogleBard

身份验证

转到 https://bard.google.com/

  • 控制台使用 F12
  • 复制值
  • 会话:前往「应用程序」→「Cookie」→「__Secure-1PSID」和「__Secure-1PSIDTS」。复制这些 Cookie 的值。

使用方法

bash
$ python3 -m Bard -h
usage: Bard.py [-h] --session <__Secure-1PSID> --session_ts <__Secure-1PSIDTS>

options:
  -h, --help         show this help message and exit
  --session --session_ts       pass two cookies

快速模式

$ export BARD_QUICK="true"
$ export BARD__Secure_1PSID="<__Secure-1PSID>"
$ export BARD__Secure_1PSIDTS="<__Secure-1PSIDTS>"
$ python3 -m Bard

环境变量可以放在 .zshrc 中。 bash 快捷方式示例:

bash
# USAGE1: bard QUESTION
# USAGE2: echo "QUESTION" | bard
bard () {
	export BARD_QUICK=true
	export BARD__Secure_1PSID=<__Secure-1PSID>
	export BARD__Secure_1PSIDTS=<__Secure-1PSIDTS>
	python3 -m Bard "${@:-$(</dev/stdin)}" | tail -n+7
}

实现:

python
from os import environ
from Bard import Chatbot

Secure_1PSID = environ.get("BARD__Secure_1PSID")
Secure_1PSIDTS = environ.get("BARD__Secure_1PSIDTS")
chatbot = Chatbot(Secure_1PSID, Secure_1PSIDTS)

answer = chatbot.ask("Hello, how are you?")

print(answer['content']

异步实现:

python
import asyncio
from os import environ
from Bard import AsyncChatbot

Secure_1PSID = environ.get("BARD__Secure_1PSID")
Secure_1PSIDTS = environ.get("BARD__Secure_1PSIDTS")

async def main():
    chatbot = await AsyncChatbot.create(Secure_1PSID, Secure_1PSIDTS)
    response = await chatbot.ask("Hello, how are you?")
    print(response['content'])

asyncio.run(main())

开发者文档

信用记录:

  • discordtehe - 他的原始逆向工程的衍生版

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Pythonchatbotgooglegoogle-bardgpt

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言