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.1.0.tar.gz (22.9 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.1.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: vectorai_sdk-1.1.0.tar.gz
  • Upload date:
  • Size: 22.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 a15241673711dbd163757afc1e2511296b7d9bc17dccbe1cdf8083fc5ecf30af
MD5 f7d8dc9c4f2bfc1cb430007ccfbfa653
BLAKE2b-256 c4c7763cd5db0e5001b507af87146538e23de038c4779464f4c58814cb7a81fc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: vectorai_sdk-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59bc9a41d3511ad3a12a60708908c44c202ae2bc0f60a62d4c3f39aff9b63761
MD5 592b4d27218e9527412ac01e9052f3be
BLAKE2b-256 1be3fd9ab574fd667e1c8429daf333e176be99f4ed415c88a374feea39e36f3f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page