Skip to main content

AI Made Stupid Simple. Unified API for OpenAI, Groq, Google, Anthropic, and more.

Project description

askai-python 🚀

A minimal Python SDK to switch between LLM providers in one line.
No frameworks. No servers. No overengineering.

PyPI version License: MIT GitHub


⚡ Quick Start (5 seconds)

pip install askai-python
from ask_ai import OpenAI, Groq

# Auto-detects OPENAI_API_KEY from environment
print(OpenAI().ask("Explain black holes like I'm 5").text)

# Switch provider instantly
print(Groq().ask("Explain black holes like I'm 5").text)

🧐 Why askai-python?

  • One function: Just call .ask()
  • Multiple providers: OpenAI, Anthropic, Google Gemini, Groq, Azure, OpenRouter
  • Zero config: Keys are pulled from the environment automatically
  • SDK-first, not a framework: It stays out of your way.

🚫 What this project is NOT

❌ Not an AI framework
❌ Not an API gateway
❌ Not an agent memory system

It does one thing perfectly: Simplifying the API call to LLMs.


🛠️ Advanced Usage

🧰 Developer QoL Utilities (Auto-Parsing)

askai-python features parsing banner

Stop writing Regex to clean up model outputs! `askai-python` comes with built-in text processing flags:
from ask_ai import OpenAI
ai = OpenAI()

# 1. Clean Markdown (Removes ```json and ``` tags)
# Perfect for extracting raw data from models that wrap everything in markdown
clean_text = ai.ask("Write JSON", clean=True).text

# 2. Extract Code (Returns ONLY the code block, ignores conversational filler)
# Great for automation pipelines
code = ai.ask("Write a python ping script", code=True).text

# 3. Strip Tags (Removes <think> blocks and HTML)
# Essential for reasoning models like DeepSeek-R1
answer_only = ai.ask("What is 1+1?", strip=True).text

# 4. Enforce & Parse JSON (Directly returns a Parsed Python Dictionary)
# Adds JSON instructions to the prompt and safely runs json.loads()
data_dict = ai.ask("Extract user info", json=True).json
print(data_dict['name'])

🚀 Built-in Resiliency (Retries & Timeouts)

askai-python resiliency banner

Build reliable apps without writing your own loops. askai-python handles rate limits (429) and network drops via an internal exponential backoff.

from ask_ai import OpenAI

ai = OpenAI()

# Automatically retries up to 3 times on transient errors, with a 15-second timeout
response = ai.ask(
    "Write a complex python script", 
    retry=3, 
    timeout=15 
)

🔌 Supported Providers

Provider Class Capabilities
OpenAI OpenAI Text, Images (DALL-E), Vision
Anthropic Anthropic Text, Vision (Claude 3.5)
Google Google Text, Images, Video, Audio
Groq Groq Ultra-fast Llama 3 & Mixtral
Azure Azure Enterprise-grade OpenAI
OpenRouter OpenRouter 100+ community models

🗺️ Roadmap

  • Baseline multiple providers
  • Automated Retry & Timeout controls
  • Async API (await ask_async)
  • Provider Fallback (fallback=[Groq()])
  • Structured Outputs (Pydantic Support)

🔗 Important Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

askai_python-0.4.0.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

askai_python-0.4.0-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file askai_python-0.4.0.tar.gz.

File metadata

  • Download URL: askai_python-0.4.0.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for askai_python-0.4.0.tar.gz
Algorithm Hash digest
SHA256 59e56073e0d99251fadc98813c416d331a54513a624b23150d1bfd51d3601efe
MD5 a02d00d70f655320a971bda6c2cc874b
BLAKE2b-256 ecb9eabff5890495ab82292d7ca987f345f682fe6d1001404518a84d54b3338d

See more details on using hashes here.

File details

Details for the file askai_python-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: askai_python-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for askai_python-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7afa600008b1d665d1ae2e12c1e6551545abe94ff5002fff3571c296a4cab1c5
MD5 d5217d823738caa3b6b0e80070100d59
BLAKE2b-256 48f48800e216f1b2951a1ca35a04c972917c12cfa0df8a0f0c58e8beb8173681

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page