Skip to main content

A simple AI toolkit for text processing using OpenAI and Gemini APIs

Project description

AIWand 🪄

One API to rule them all - Unified OpenAI and Gemini interface with automatic provider switching and structured data extraction from anywhere.

PyPI version Python versions License Coverage Status Downloads Downloads Downloads

🚀 Stop Wrestling with AI APIs

Before: Different APIs, manual JSON parsing, provider-specific code 😫
After: One API, automatic everything ✨

import aiwand
# Works with any model - provider auto-detected
response = aiwand.call_ai(model="gpt-4o", user_prompt="Explain quantum computing?")

# returns structured json data directly
data = aiwand.extract(content="John Doe, john@example.com, (555) 123-4567")

🔧 Installation & Setup

pip install aiwand
export OPENAI_API_KEY="your-key"     # Set either key (or both for fallback)
export GEMINI_API_KEY="your-key"     

💡 Core Features

call_ai - Universal AI Interface

Same code works with OpenAI and Gemini - automatic provider detection:

from pydantic import BaseModel

# Basic AI calls
response = aiwand.call_ai(model="gpt-4o", user_prompt="Explain quantum computing?")

# Structured output - get Pydantic objects directly
class BlogPost(BaseModel):
    title: str
    content: str
    tags: list[str]

blog = aiwand.call_ai(
    model="gemini-2.0-flash",
    user_prompt="Write a blog about AI",
    response_format=BlogPost    # Returns BlogPost object!
)
print(blog.title)  # Direct access, no JSON parsing

# Works with any model
for model in ["gpt-4o", "gemini-2.0-flash", "o3-mini"]:
    response = aiwand.call_ai(model=model, user_prompt=f"What makes {model} special?")

extract - Smart Data Extraction

Extract structured data from text, web links, documents, and images:

from pydantic import BaseModel

class CompanyInfo(BaseModel):
    name: str
    founded: int
    employees: int
    technologies: list[str]

# Extract from individual sources
contact = aiwand.extract(content="John Doe, john@example.com, (555) 123-4567")
webpage = aiwand.extract(links=["https://company.com/about"])
docs = aiwand.extract(document_links=["resume.pdf", "report.docx"])
images = aiwand.extract(images=["chart.png", "diagram.jpg"])

# Or mix all sources together with custom structure
company = aiwand.extract(
    content="Research notes about tech companies...", 
    links=["https://company.com/about"],           # Web pages
    document_links=["annual_report.pdf"],          # Documents  
    images=["company_chart.png"],                  # Images
    response_format=CompanyInfo                    # Get typed object back
)

print(f"{company.name} founded in {company.founded}")  # Direct access

⚡ Quick Examples

import aiwand

# Instant AI calls
summary = aiwand.summarize("Long article...", style="bullet-points")
response = aiwand.chat("What is machine learning?")
story = aiwand.generate_text("Write a haiku about coding")

# Smart classification  
grader = aiwand.create_binary_classifier(criteria="technical accuracy")
result = grader(question="What is 2+2?", answer="4", expected="4")
print(f"Accuracy: {result.score}/5")

🎨 CLI Magic

# Quick chat
aiwand "Explain quantum computing simply"

# Extract from anything
aiwand extract "Dr. Sarah Johnson, sarah@lab.com" --json
aiwand extract --links https://example.com --document-links resume.pdf --images chart.png

# Built-in functions
aiwand summarize "Long text..." --style concise
aiwand chat "Hello there!"

✨ Why Choose AIWand?

🔄 Provider Agnostic Same code, OpenAI or Gemini
🏗️ Structured Output Pydantic objects, no JSON parsing
🧠 Smart Detection Automatic provider selection
📄 Universal Extraction Text, web links, documents, images
Zero Setup Just add API keys
🎯 Drop-in Ready Minimal code changes

📚 Documentation

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

📝 License

MIT License - see LICENSE file for details.


Star this repo if AIWand makes your AI development easier!

Made with ❤️ by Aman Kumar

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

aiwand-0.4.32.tar.gz (75.2 kB view details)

Uploaded Source

Built Distribution

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

aiwand-0.4.32-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

Details for the file aiwand-0.4.32.tar.gz.

File metadata

  • Download URL: aiwand-0.4.32.tar.gz
  • Upload date:
  • Size: 75.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for aiwand-0.4.32.tar.gz
Algorithm Hash digest
SHA256 fd09e5e8a3205608bd2af5f5fe99d18989a9c3fcf6c53f80ea5374171ec1bbef
MD5 63853910be2b59a876e417d3b7877ed4
BLAKE2b-256 a0a895656b263a59f061bb58665646454b2b2677bb431a234c33a1785e63ab89

See more details on using hashes here.

File details

Details for the file aiwand-0.4.32-py3-none-any.whl.

File metadata

  • Download URL: aiwand-0.4.32-py3-none-any.whl
  • Upload date:
  • Size: 39.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for aiwand-0.4.32-py3-none-any.whl
Algorithm Hash digest
SHA256 fbbc630213c9426f17b02dc32ab7277da9ea57da7e6d8b014657c47aba937eb1
MD5 d3f79ccf4eba8df862876e1211f8f6de
BLAKE2b-256 0c33024ca568b1602b60c4b02d5e16afad8b3af64935f7e3dc0d5d61eae494fb

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