One API to rule them all - Unified OpenAI and Gemini interface with automatic provider switching and structured data extraction from anywhere.
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, [email protected], (555) 123-4567")pip install aiwand
export OPENAI_API_KEY="your-key" # Set either key (or both for fallback)
export GEMINI_API_KEY="your-key" 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 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, [email protected], (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 accessimport 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")# Quick chat
aiwand "Explain quantum computing simply"
# Extract from anything
aiwand extract "Dr. Sarah Johnson, [email protected]" --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!"| π 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 |
- API Reference - Complete function docs
- CLI Guide - Command line usage
- Installation - Setup details
- Development - Contributing guide
We welcome contributions! See CONTRIBUTING.md for guidelines.
MIT License - see LICENSE file for details.
β Star this repo if AIWand makes your AI development easier!
Made with β€οΈ by Aman Kumar