Python client library for AI Search API - search and retrieve intelligent responses with context awareness
Project description
AI Search API Python Client
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.
Features
- 🔍 AI-Powered Semantic Search: Natural language search powered by embeddings
- 🎯 Context Awareness: Include history for smarter results
- ⚡ Simple API Client: Clean Python interface with error handling
- 🛡️ Type Safety: Strong type hints
- 🔄 Flexible Output: Get text or markdown results
- 💰 Usage Tracking: Monitor your API credit balance anytime
Installation
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 .
Quick Start
Get Your API Key
- 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")
Basic Usage Example
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()
Advanced Usage
Contextual Search
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)
Custom Configuration
client = AISearchAPIClient(
api_key="your-api-key-here",
base_url="https://api.aisearchapi.io",
timeout=60
)
API Reference
Full API reference is available in the official documentation.
Error Handling
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}")
Environment Variables
export AI_SEARCH_API_KEY="your-api-key-here"
Then use in Python:
import os
from aisearchapi_client import AISearchAPIClient
api_key = os.getenv("AI_SEARCH_API_KEY")
client = AISearchAPIClient(api_key=api_key)
Development
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
License
MIT License - see the LICENSE file.
Support
- Get API Key: AI Search API Dashboard
- Documentation: docs.aisearchapi.io
- Homepage: aisearchapi.io
- Issues: GitHub Issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aisearchapi_client-1.0.8.tar.gz.
File metadata
- Download URL: aisearchapi_client-1.0.8.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e5a65bbdb717edb0bb1e790fa13f8ea56b8a8767eb0df54c1e667aa72d8a23a
|
|
| MD5 |
5dd8eb52b03a18b4130ea57dfb7aff07
|
|
| BLAKE2b-256 |
b21586415f89df2b66391be0361ad6e03a2c15b21ef7d45c1771c439f1b56d72
|
File details
Details for the file aisearchapi_client-1.0.8-py3-none-any.whl.
File metadata
- Download URL: aisearchapi_client-1.0.8-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bc0586a8fb9c3d8266a3960993bec9a7124959ec2b97242e22c5e2c8fda7b5d
|
|
| MD5 |
253f592897f9343cada3072b0caaf39d
|
|
| BLAKE2b-256 |
76e3155766871afda8f4dc1c95d961dc631ddd5033b1fa9cbaaa776d0085ef3c
|