Skip to main content

Python SDK for Qader AI services

Project description

Qader AI Library

A Python library for interacting with Qader AI services and AI processing utilities.


Features

  • Python SDK for Qader AI
  • Predict API
  • Chat API
  • Usage API
  • Subscription API
  • API Key Authentication
  • Custom Exceptions
  • AI Processing Utilities
  • Duplicate Cleaning
  • Configurable Settings

Requirements

  • Python 3.9+
  • requests
  • pydantic
  • pydantic-settings
  • openai
  • pandas
  • numpy
  • tqdm
  • scikit-learn
  • sentence-transformers
  • pytest (for testing)
  • responses (for testing)

Install the library:

pip install -e .

Install with testing dependencies included:

pip install -e ".[test]"

Prerequisites

This library is a client for the Qader backend API — it does not work standalone. Before using it, make sure:

  1. The Qader backend is running and reachable (defaults to http://127.0.0.1:8000).
  2. You have a valid API key. Create one via the backend's POST /api-keys/create endpoint (see the backend's /docs page for details).
  3. That API key has an active subscription and remaining usage, otherwise calls will raise SubscriptionExpiredError or UsageLimitExceededError.

Project Structure

Qader-AI-Library/
│
├── src/
│   └── qader_ai/
│       ├── __init__.py
│       ├── sdk.py
│       ├── config.py
│       ├── exceptions.py
│       ├── clients.py
│       ├── duplicate_cleaner.py
│       ├── ai_processing/
│       │   ├── __init__.py
│       │   ├── ...
│       │
│       └── enums/
│           ├── __init__.py
│           ├── ...
│
├── tests/
│   ├── test_sdk_unit.py          # mocked, no backend needed
│   └── test_sdk_integration.py   # requires the backend running
│
├── README.md
├── pyproject.toml
└── requirements.txt

Installation

Clone the repository

git clone <repository-url>

Move to the project

cd Qader-AI-Library

Install the package

pip install -e .

Configuration

Configuration is managed through config.py, using environment variables (or a .env file in the project root).

Available SDK settings:

Setting Default Description
base_url http://127.0.0.1:8000 The Qader backend's base URL
timeout 30 Request timeout in seconds

Example .env file:

base_url=http://127.0.0.1:8000
timeout=30

Additional AI processing settings are also available inside the same configuration file.


Quick Start

from qader_ai import QaderAI

client = QaderAI(
    api_key="YOUR_API_KEY"
)

Predict

result = client.predict(
    question="What is Artificial Intelligence?"
)

print(result)

Chat

result = client.chat(
    message="Hello!"
)

print(result)

Usage

result = client.usage(
    api_key_id=1
)

print(result)

Subscription

result = client.subscription(
    user_id=1
)

print(result)

Exception Handling

The library provides the following exceptions:

  • QaderAIError — base exception for all library errors
  • InvalidAPIKeyError — raised when the API key is missing, invalid, or inactive (HTTP 401)
  • SubscriptionExpiredError — raised when the subscription is expired or inactive (HTTP 403)
  • NotFoundError — raised when a requested usage or subscription record doesn't exist (HTTP 404)
  • ValidationError — raised when the request data is invalid (HTTP 422)
  • UsageLimitExceededError — raised when the API key has hit its usage limit (HTTP 429)
  • RateLimitExceededError — raised when too many requests are sent in a short time window (HTTP 429)
  • ServerError — raised for backend server errors (HTTP 500+)

Example:

from qader_ai.exceptions import InvalidAPIKeyError

try:
    client.predict("Hello")
except InvalidAPIKeyError:
    print("Invalid API Key")

Running Tests

Unit tests (mocked, no backend required):

pytest tests/test_sdk_unit.py -v

Integration tests (requires the Qader backend running locally):

pytest tests/test_sdk_integration.py -v

Run everything:

pytest -v

License

This project is intended for educational and internal use.

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

qader_ai-0.1.0.tar.gz (34.5 kB view details)

Uploaded Source

Built Distribution

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

qader_ai-0.1.0-py3-none-any.whl (40.7 kB view details)

Uploaded Python 3

File details

Details for the file qader_ai-0.1.0.tar.gz.

File metadata

  • Download URL: qader_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 34.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for qader_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4e1f0eb3886b0c311fc75c4d1ccbe879f18bf6d82f70764b476c3e4b70da5041
MD5 b209296b3ed1cbfa3f054bacc6891258
BLAKE2b-256 8b69ae140172710ac3c98d7a5d476fc547cef6a70e24f41a99dd01cfb6f3ba5f

See more details on using hashes here.

File details

Details for the file qader_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qader_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 40.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for qader_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72c08415f5817afc70440b63fe80a725e5f50b62509ae795087f4c851f50f019
MD5 b3573365337ae5929f54d52bdad4a180
BLAKE2b-256 c9fc44d85460a5c20ef3e8dbd38b07c892d2fb00071749fad09d28eb76a5e34b

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