Skip to main content

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

Project description

askai-python 🚀

AI Made Stupid Simple. One unified Python client for OpenAI, Claude, Gemini, Groq, and Azure.

PyPI version License: MIT GitHub


⚡ What is askai-python?

askai-python is a lightweight, zero-dependency-logic wrapper that provides a single API for all major AI providers. Stop learning multiple SDKs; just call .ask() and get your answer.

  • Unified Interface: One syntax for OpenAI, Anthropic, Google, and more.
  • Zero-Config: Seamlessly uses environment variables for API keys.
  • Smart Media: Easy handling of images and audio (Provider permitting).
  • Production Grade: Built-in robust error handling and type hints.

📦 Installation

pip install askai-python

🚀 Examples & Tutorials

1. Basic Usage (The 3-Line Magic)

from ask_ai import OpenAI

ai = OpenAI() # Auto-loads OPENAI_API_KEY from env
print(ai.ask("What is the capital of France?").text)

2. Multi-Provider Mastery

Switching between top-tier models has never been easier:

from ask_ai import OpenAI, Anthropic, Google

prompt = "Explain quantum computing to a 5-year-old."

# OpenAI (GPT-4o)
print(OpenAI().ask(prompt).text)

# Anthropic (Claude 3.5 Sonnet)
print(Anthropic().ask(prompt).text)

# Google (Gemini 1.5 Pro)
print(Google().ask(prompt).text)

3. Advanced Configuration (System Personas)

You can set a system prompt and temperature globally for an instance or per-request.

from ask_ai import OpenAI

ai = OpenAI()

# Global config
ai.advanced(
    prompt="You are a sarcastic robot from the year 3000.",
    temperature=0.9
)

print(ai.ask("What is love?").text)

# Per-request override
print(ai.ask("What is 1+1?", temperature=0.1).text)

4. Handling Structured Exceptions

Build reliable apps by catching specific AI errors:

from ask_ai import OpenAI
from ask_ai.exceptions import AskAIError, APIKeyError

try:
    ai = OpenAI(api_key="invalid-key")
    ai.ask("Hello")
except APIKeyError:
    print("Check your API keys!")
except AskAIError as e:
    print(f"An AI error occurred: {e}")

🔌 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

🔗 Important Links


Built with ❤️ by Hossein Ghorbani.

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.1.3.tar.gz (15.0 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.1.3-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: askai_python-0.1.3.tar.gz
  • Upload date:
  • Size: 15.0 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.1.3.tar.gz
Algorithm Hash digest
SHA256 8d1bca81426dee23a245a88327616f1eb7462c99e97f7d3abbe4c2f24b91e69c
MD5 24a6a9f4cb98922cbd9c245387f440bf
BLAKE2b-256 8b13d7b5f4cb1c514a1fc69b403d1c0fac12b479c117034460fa83b17312ea1b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: askai_python-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 17.5 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.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 111e4f0c4efe26b889093a7a758f5890fad48fb532623452b14c3896dc489aa7
MD5 3632af2f1b58f93694b917d9ab366add
BLAKE2b-256 332d6c35059c7ce3890a5997417b652e5e2f969adf74660c044ae960f9682abe

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