Skip to content

Releases: AlexAnys/ai-sub-auth

v0.2.0 — AI Facade, Bug Fixes & Subscription Reality Docs

28 Feb 13:40
56279a3

Choose a tag to compare

What's New

AI Facade — The Simplest Integration API

New AI class that auto-detects your subscription and provides the simplest possible API:

from ai_sub_auth import AI

ai = AI()        # auto-detects ChatGPT Plus OAuth token or API key env vars
ai.connect()     # OAuth login or API key verification
result = ai.chat_sync("Hello!")   # sync, safe in any context
result = await ai.chat("Hello!")  # async
  • Auto-detection: Codex OAuth token → ANTHROPIC_API_KEYOPENAI_API_KEY → Gemini → DeepSeek → OpenRouter
  • Sync/Async dual API: chat_sync() handles nested event loops (FastAPI, Jupyter) via threading
  • Multi-turn conversations: messages parameter supported across all 4 provider APIs
  • Subscription status: ai.status returns connection state, provider, token expiry, reauth needs

Bug Fixes

  • Gemini system prompt — Now uses native system_instruction field (was faking with user/model conversation)
  • OAuth token exchange — Validates error field before accessing tokens in both exchange and refresh
  • skills.py diversityseen_skills set properly synced when replacing suggestions
  • API key validationLLMClient raises AuthError immediately if key is missing

Code Quality

  • Narrowed broad except Exception: pass to specific exceptions with warnings.warn()
  • Type hints added to all internal _chat_* methods
  • Removed hardcoded fallback model names (explicit model required)
  • File lock failures now warn instead of silently passing

Documentation

  • Subscription Reality (2026) — Honest table showing which subscriptions can actually be bridged (only OpenAI Codex OAuth = zero extra cost; Claude/Gemini = API key only)
  • Anti-patterns — Don't bridge Claude Pro/Max or Gemini subscriptions via OAuth
  • AGENT.md — New TRANSFORM and EXTRACT implementation examples, Provider Selection Guide, Principle #7 (Subscription-first)
  • README — AI Facade as recommended entry point, updated quick start examples

Files Changed

File Change
ai_sub_auth/facade.py NEW (264 lines)
ai_sub_auth/api_client.py Gemini fix, messages param, type hints
ai_sub_auth/oauth_flow.py Error field validation
ai_sub_auth/token_store.py Narrow exceptions, lock warnings
ai_sub_auth/skills.py Diversity bug fix
ai_sub_auth/models.py Import cleanup
ai_sub_auth/__init__.py New exports
AGENT.md Subscription reality, examples
README.md / README_CN.md Full docs update

Full Changelog: f389deb...v0.2.0