Skip to main content

nbChatGPT 🚀

国内一键安装的 ChatGPT-5.4 Nano 中转服务 SDK
每天免费 0.3K tokens,零配置开箱即用!

PyPI version Python 3.8+ License: MIT

✨ 特性

  • ✅ 零配置 - 无需 API Key,无需代理设置,开箱即用
  • ✅ 免费额度 - 每天 0.3K tokens 免费使用
  • ✅ 流式输出 - 支持逐字输出,实时响应
  • ✅ 对话管理 - Conversation 类自动维护上下文
  • ✅ 命令行工具 - 支持终端直接使用
  • ✅ 国内可用 - 专为国内网络环境优化

📦 安装

pip install nbchatgpt
🚀 快速开始
基础对话
python
from nbchatgpt import Client

client = Client()
response = client.chat("你好")
print(response.content)
流式输出
python
from nbchatgpt import Client

client = Client()
for chunk in client.chat_stream("讲个笑话"):
    print(chunk.content, end="")
多轮对话
python
from nbchatgpt import Client

client = Client()
messages = [
    {"role": "system", "content": "你是历史专家"},
    {"role": "user", "content": "唐朝有哪些著名诗人?"}
]

response1 = client.chat_with_history(messages)
print(response1.content)

messages.append({"role": "assistant", "content": response1.content})
messages.append({"role": "user", "content": "李白呢?"})

response2 = client.chat_with_history(messages)
print(response2.content)
使用 Conversation 管理器
python
from nbchatgpt import Conversation

conv = Conversation(system_prompt="你是诗歌创作助手")
conv.chat("写一首关于春天的诗")
conv.chat("再写一首,风格悲伤一点")  # 自动携带历史
print(conv.get_history())
查询今日使用情况
python
from nbchatgpt import Client

client = Client()
usage = client.get_usage()
print(f"今日已用: {usage['used_tokens']} tokens")
print(f"今日剩余: {usage['remaining_tokens']} tokens")
💻 命令行使用
安装后可直接在终端使用:

bash
# 单轮对话
nbchatgpt chat "你好"

# 流式输出
nbchatgpt chat "写一首诗" --stream

# 带系统提示词
nbchatgpt chat "你是谁" --system "你是历史专家"

# JSON 格式输出
nbchatgpt chat "你好" --json

# 查询使用情况
nbchatgpt usage

# 交互式对话
nbchatgpt conv
nbchatgpt conv --system "你是专家" --stream
🔧 自定义配置
python
from nbchatgpt import Client

# 自定义中转地址和用户 ID
client = Client(
    base_url="http://your-proxy.com:8000",
    user_id="your-custom-user-id",
    api_key="your-api-key",
    timeout=30
)
📚 API 文档
Client
方法	说明
chat(prompt, ...)	单轮对话
chat_with_history(messages, ...)	多轮对话
chat_stream(prompt, ...)	流式对话
chat_stream_with_history(messages, ...)	流式多轮对话
get_usage()	查询今日使用情况
Conversation
方法	说明
chat(prompt, ...)	对话(自动携带历史)
chat_stream(prompt, ...)	流式对话
clear()	清空历史
get_history()	获取历史记录
count_messages()	获取消息条数
⚠️ 错误处理
python
from nbchatgpt import Client
from nbchatgpt.exceptions import QuotaExceededError, NetworkError

client = Client()

try:
    response = client.chat("你好")
except QuotaExceededError as e:
    print(f"额度已用完: {e}")
except NetworkError as e:
    print(f"网络错误: {e}")
📝 注意事项
每人每天免费 0.3K tokens(约 300 tokens)

额度按自然日重置(北京时间 00:00)

不支持自定义模型名称,仅支持 gpt-5.4-nano

🤝 贡献
欢迎提交 Issue 和 Pull Request!

Metadata

Release files for nbchatgpt 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nbchatgpt 0.2.0
File Size Uploaded Provenance Actions
nbchatgpt-0.2.0.tar.gz 40.8 kB Without provenance Details for nbchatgpt-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nbchatgpt 0.2.0
File Interpreter ABI Platform Actions
nbchatgpt-0.2.0-py3-none-any.whl Python 3 none any Details for nbchatgpt-0.2.0-py3-none-any.whl

Total release size: 81.2 kB

Release files / nbchatgpt-0.2.0.tar.gz

Download URL nbchatgpt-0.2.0.tar.gz
Size 40.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c99ebe16021357e952a97bc58a2953bf22d9e8b9a4a97a5a0b96457932a7a65a
BLAKE2b-256 checksum
How to use checksums
a237afeaf49345e496b8b2b0ffe35707397b32203452289d273ea277ae644376
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.7

Release files / nbchatgpt-0.2.0-py3-none-any.whl

Download URL nbchatgpt-0.2.0-py3-none-any.whl
Size 40.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2528e5ceb9c11f57470f42ba63a418a849bbb9dd9caf08a15345730846c43773
BLAKE2b-256 checksum
How to use checksums
0e8856cdbd047bfbaef0de72ab8515b85e2034606b8c77056ff5399be5bd1024
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.7

Security for nbchatgpt 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page