Xplo8E/piai
Python port of pi-ai with moreeeeee crazy ideas
Platform-specific configuration:
{
"mcpServers": {
"piai": {
"command": "npx",
"args": [
"-y",
"piai"
]
}
}
}Add the config above to .claude/settings.json under the mcpServers key.
Python port of @mariozechner/pi-ai.
Use your ChatGPT Plus/Pro subscription to access GPT models from Python — no API key, no per-token billing. Authenticates via OAuth using your existing ChatGPT account and streams completions directly from ChatGPT's backend.
---
---
uv add pi-ai-py
# or
pip install pi-ai-pyFrom source:
git clone https://github.com/Xplo8E/piai
cd piai
uv sync---
Run once to authenticate. Opens a browser for you to log in with your ChatGPT account.
piai loginCredentials are saved to auth.json in the current directory. Keep it private — add to .gitignore. If you've already logged in with the JS CLI (npx @mariozechner/pi-ai login openai-codex), the same auth.json works without re-logging in.
---
piai run "Explain async/await in Python"
piai run "What is 2+2?" --model gpt-5.1
piai run "Summarize this" --system "You are a concise assistant"
piai status # check login state
piai logout---
Streams the model response as typed events.
import asyncio
from piai import stream
from piai.types import Context, UserMessage, TextDeltaEvent, DoneEvent
async def main():
ctx = Context(
system_prompt="You are a helpful assistant.",
messages=[UserMessage(content="What is the capital of France?")]
)
async for event in stream("gpt-5.1-codex-mini", ctx):
if isinstance(event, TextDeltaEvent):
print(event.text, end="", flush=True)
elif isinstance(event, DoneEvent):
print()
print(f"Tokens: {event.message.usage['input']} in, {event.message.usage['output']} out")
asyncio.run(main())Returns the full AssistantMessage after the response finishes.
Loading reviews...