Skip to main content

VectorAI Python SDK (vectorai-sdk)

PyPI version Python versions License Documentation

Official Python SDK for VectorAI by AcadmyAI — High-Performance, Stateless Multi-Modal Vector Storage, Document Chunking & Hybrid Semantic Search Gateway.


⚡ Key Features

  • Mandatory Authentication & Security: Secure Bearer API key authentication with SHA-256 validation.
  • Multi-Modal Document Parsing: Ingest raw text strings, local files (PDF, DOCX, CSV, Text, Code), or remote URLs.
  • Configurable Chunking: Built-in recursive, sentence, paragraph, fixed, and semantic chunking strategies.
  • Sub-45ms Semantic Search: Hybrid BM25 Reciprocal Rank Fusion (RRF) and Cohere neural reranking.
  • Programmatic Quota & Balance: Track remaining chunk balances, API call volumes, subscription status, and renewal dates.
  • Framework Adapters: 1-line integrations for LangChain and LlamaIndex.
  • Dual Sync & Async: Synchronous VectorClient and asynchronous AsyncVectorClient for FastAPI / asyncio microservices.
  • Terminal CLI: Run vector searches and ingest files directly from the command line (vectorai).

📦 Installation

# Standard SDK installation
pip install vectorai-sdk

# With LangChain support
pip install "vectorai-sdk[langchain]"

# With LlamaIndex support
pip install "vectorai-sdk[llamaindex]"

🚀 Quickstart

1. Initialize Client (API Key is Mandatory)

Get your API key from the VectorAI Console.

from vectorai import VectorClient

# Option A: Pass api_key directly
client = VectorClient(api_key="sk-lvl1-9988aabbcc...")

# Option B: Or set the environment variable
# export VECTORAI_API_KEY="sk-lvl1-..."
client = VectorClient()

2. Ingest Content (Text or Files)

# Ingest raw text
result = client.ingest(
    raw_text="AcadmyAI provides enterprise AI security, vector retrieval, and market telemetry.",
    collection_name="enterprise_kb",
    chunking_strategy="recursive",
    chunk_size=512,
    chunk_overlap=64,
    metadata={"author": "Team", "version": "1.0"}
)
print(f"Ingested {result.chunks_created} chunks into collection: {result.collection_name}")

# Ingest local file directly (PDF, DOCX, CSV, TXT, Markdown)
file_result = client.ingest_file(
    file_path="./quarterly_report.pdf",
    collection_name="financial_docs"
)

3. Semantic & Hybrid Search

results = client.search(
    query="What products does AcadmyAI offer?",
    collection_name="enterprise_kb",
    limit=5,
    hybrid=True,  # Combines BM25 lexical keyword search with dense vectors
    rerank=True   # Applies cross-encoder neural reranking
)

for item in results:
    print(f"[{item.score:.4f}] Chunk #{item.chunk_index}: {item.text}")

4. Check Account Quota & Left-Over Balances

balance = client.get_usage()

print(f"Tier: {balance.subscription.tier}")
print(f"Days Left: {balance.subscription.days_remaining}")
print(f"Chunks Stored: {balance.quota.total_chunks_stored} / {balance.quota.max_chunks_allowed}")
print(f"Chunks Remaining: {balance.quota.chunks_remaining}")

⚡ Asynchronous Client (AsyncVectorClient)

For high-throughput async microservices (FastAPI, aiohttp, Celery):

import asyncio
from vectorai import AsyncVectorClient

async def main():
    async with AsyncVectorClient(api_key="sk-lvl1-...") as client:
        # Ingest
        await client.ingest(
            raw_text="Real-time knowledge streaming...",
            collection_name="live_stream"
        )

        # Search
        res = await client.search(
            query="knowledge streaming",
            collection_name="live_stream",
            limit=3
        )
        for r in res.results:
            print(r.score, r.text)

asyncio.run(main())

🔗 LangChain Integration

from vectorai.integrations.langchain import VectorAIStore

vectorstore = VectorAIStore(
    api_key="sk-lvl1-...",
    collection_name="langchain_kb"
)

# Add texts
vectorstore.add_texts(["LangChain makes LLM agents easy", "VectorAI stores high-dimensional embeddings"])

# Retrieve
retriever = vectorstore.as_retriever(search_kwargs={"k": 2, "hybrid": True})
docs = retriever.get_relevant_documents("How to use VectorAI with LangChain?")

💻 Terminal CLI (vectorai)

The package includes a command-line interface:

# Ingest local file
vectorai ingest ./annual_report.pdf --collection finance --strategy recursive

# Ingest raw text
vectorai ingest "Vector databases index embeddings for semantic retrieval" --collection ai_kb

# Execute semantic search
vectorai search "What was our Q3 EBITDA?" --collection finance --limit 3 --hybrid

# Check remaining quota and subscription balance
vectorai quota

# Check cluster SLA and uptime
vectorai health

⚠️ Error Handling

The SDK exposes clean, typed exceptions mapping to API status codes:

from vectorai import VectorClient
from vectorai.exceptions import (
    AuthenticationError,
    SubscriptionRequiredError,
    QuotaExceededError,
    RateLimitError,
    VectorAIError
)

try:
    client = VectorClient(api_key="sk-lvl1-...")
    results = client.search("query", collection_name="docs")
except AuthenticationError:
    print("Invalid or missing API key.")
except SubscriptionRequiredError:
    print("Subscription is inactive or expired. Recharge at https://vector.acadmyai.com/console")
except QuotaExceededError:
    print("Storage chunk quota exceeded.")
except RateLimitError as e:
    print(f"Throttled. Retry after {e.retry_after} seconds.")
except VectorAIError as e:
    print(f"VectorAI error: {e}")

📄 License

Apache 2.0 License. Powered by AcadmyAI.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vectorai_sdk-1.0.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

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

vectorai_sdk-1.0.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file vectorai_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: vectorai_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for vectorai_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 346b7d5eb17539664876013a8124d67cdf6480723ff155215ca17e953b054ec6
MD5 f6d7a860d52ac043bfd8201a02193b72
BLAKE2b-256 acfec129e30ea8ce38592e17b3dfb280bc6d7e8951f0884cf562dbe8640a62d1

See more details on using hashes here.

File details

Details for the file vectorai_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: vectorai_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for vectorai_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d7ea9c351e4bbb6c4e4f0530685e850545d26a02ef05868ddf1a7f72ae5f4a4
MD5 ffe1de4b2a0b6601caf6e0f01d14356c
BLAKE2b-256 42b6a8f3a7a62011612a7656af7f1f5920b1e2d09be808ad2d1e00d5de85b2a9

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 Sentry Error logging StatusPage Status page