Skip to main content

Python client library for AI Search API - search and retrieve intelligent responses with context awareness

Project description

AI Search API Python Client

PyPI version Python Support License: MIT

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

  1. Sign up at aisearchapi.io.
  2. Log in to the dashboard.
  3. 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

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

aisearchapi_client-1.0.8.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

aisearchapi_client-1.0.8-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

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

Hashes for aisearchapi_client-1.0.8.tar.gz
Algorithm Hash digest
SHA256 1e5a65bbdb717edb0bb1e790fa13f8ea56b8a8767eb0df54c1e667aa72d8a23a
MD5 5dd8eb52b03a18b4130ea57dfb7aff07
BLAKE2b-256 b21586415f89df2b66391be0361ad6e03a2c15b21ef7d45c1771c439f1b56d72

See more details on using hashes here.

File details

Details for the file aisearchapi_client-1.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for aisearchapi_client-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 3bc0586a8fb9c3d8266a3960993bec9a7124959ec2b97242e22c5e2c8fda7b5d
MD5 253f592897f9343cada3072b0caaf39d
BLAKE2b-256 76e3155766871afda8f4dc1c95d961dc631ddd5033b1fa9cbaaa776d0085ef3c

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