A Python client library for the AI Search API that provides semantic search, contextual awareness, and intelligent AI-powered results.
This package makes it easy for developers to integrate the AI Search API into Python projects.
π To start, get your free API key from the AI Search API dashboard.
- π AI-Powered Semantic Search: Leverage advanced embeddings for natural language search
- π― Context Awareness: Add conversation history for smarter results
- β‘ Simple API Client: Clean and Pythonic interface with strong error handling
- π‘οΈ Type Safety: Full type hints for modern development
- π Flexible Output: Choose between plain text or markdown responses
- π° Usage Tracking: Monitor your API credit balance anytime
Install from PyPI:
pip install aisearchapi-client
Or install from source:
git clone https://github.com/aisearchapi/aisearchapi-python.git
cd aisearchapi-python
pip install -e .
- Sign up at aisearchapi.io.
- Log in to the dashboard.
- Copy your API key.
Use this key when creating a client:
from aisearchapi_client import AISearchAPIClient
client = AISearchAPIClient(api_key="your-api-key-here")
from aisearchapi_client import AISearchAPIClient
client = AISearchAPIClient(api_key="your-api-key-here")
result = client.search(
prompt="What is machine learning and how does it work?",
response_type="markdown"
)
print("Answer:", result.answer)
print("Sources:", result.sources)
print(f"Total time: {result.total_time}ms")
balance = client.balance()
print(f"Available credits: {balance.available_credits}")
client.close()
from aisearchapi_client import AISearchAPIClient, ChatMessage
with AISearchAPIClient(api_key="your-api-key-here") as client:
result = client.search(
prompt="What are the main advantages and disadvantages?",
context=[
ChatMessage(role="user", content="I am researching solar energy for my home"),
ChatMessage(role="user", content="I live in a sunny climate with high electricity costs")
],
response_type="text"
)
print("Contextual Answer:", result.answer)
client = AISearchAPIClient(
api_key="your-api-key-here",
base_url="https://api.aisearchapi.io",
timeout=60
)
Full API reference is available in the official documentation.
AISearchAPIClient(
api_key: str,
base_url: str = "https://api.aisearchapi.io",
timeout: int = 30
)
- api_key: Get yours from the dashboard
- base_url: Optional custom endpoint
- timeout: Timeout in seconds
- search(prompt, context=None, response_type=None) β Perform an AI-powered semantic search
- balance() β Check current credit usage
For more, see API docs.
from aisearchapi_client import AISearchAPIClient, AISearchAPIError
try:
with AISearchAPIClient(api_key="your-api-key") as client:
result = client.search(prompt="Your query")
print(result.answer)
except AISearchAPIError as e:
print(f"API Error [{e.status_code}]: {e.description}")
You can set your API key globally:
export AI_SEARCH_API_KEY="your-api-key-here"
Then use:
import os
from aisearchapi_client import AISearchAPIClient
api_key = os.getenv("AI_SEARCH_API_KEY")
client = AISearchAPIClient(api_key=api_key)
Find more examples in the examples/ folder or check the documentation:
- Basic search and balance checking
- Contextual search with history
- Async usage
- Error handling
- Python 3.8+
- requests >= 2.25.0
- typing-extensions >= 4.0.0 (if Python < 3.10)
git clone https://github.com/aisearchapi/aisearchapi-python.git
cd aisearchapi-python
python -m venv venv
source venv/bin/activate
pip install -e ".[dev,test]"
pytest
This project is licensed under the MIT License - see the LICENSE file.
- Get API Key: AI Search API Dashboard
- Documentation: docs.aisearchapi.io
- Homepage: aisearchapi.io
- Issues: GitHub Issues
- Email: admin@aisearchapi.io
AI search API Python client, semantic search Python, contextual AI search, AI API key, AI dashboard, intelligent search SDK