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

Uploaded Python 3

File details

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

File metadata

  • Download URL: askai_python-0.1.5.tar.gz
  • Upload date:
  • Size: 15.1 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.5.tar.gz
Algorithm Hash digest
SHA256 9802fd5cf0dd53125d3b1a9ba80d959484aab30709c2e62de8901ce2957f4943
MD5 f62a5c96baff8ccca679478d32f62ad8
BLAKE2b-256 f493a3b24875fa3842711ba5a213d1e8aa08d5138eb7645133d642282cb1db54

See more details on using hashes here.

File details

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

File metadata

  • Download URL: askai_python-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0d520f64519993f1607715768d38bca7fae523b2b7cf6da6d476c9f271b8ac2e
MD5 e4b5f843484257975be2ee0e8279869b
BLAKE2b-256 d0ef1496b32dcea2a34e8be09f11f367ad1ccb8cc493bb02338942a46a2aa2b2

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