Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

QAnswer Python SDK

PyPI version Python Versions License: MIT

Official Python SDK for the QAnswer API, automatically generated from the OpenAPI specification.

This SDK allows Python applications to interact with QAnswer's services programmatically without needing to craft raw HTTP requests.


🚀 Features

  • Full coverage of QAnswer API endpoints
  • Type-safe models via Pydantic
  • Easy configuration of authentication and base URL
  • Auto-generated and versioned with each API release

📦 Installation

You can install from PyPI:

pip install qanswer-sdk

Or add it to your requirements.txt

qanswer-sdk==3.1184.0

🔑 Authentication

Most endpoints require authentication. You can configure authentication in several ways:

API Key Authentication

from qanswer_sdk import Configuration, ApiClient
from qanswer_sdk.api.chatbot_api import ChatbotApi

# Configure API key authorization
config = Configuration(
    host="https://app.qanswer.ai/backend",
    api_key={"QAnswer-Api-Key": "your-api-key-here"},
)

# Initialize client
with ApiClient(config) as client:
    api = ChatbotApi(client)
    # Use the API...

Bearer Token Authentication

from qanswer_sdk import Configuration, ApiClient
from qanswer_sdk.api.chatbot_api import ChatbotApi

# Configure Bearer token authorization
config = Configuration(
    host="https://app.qanswer.ai/backend", access_token="your-jwt-token-here"
)

# Initialize client
with ApiClient(config) as client:
    api = ChatbotApi(client)
    # Use the API...

📖 Usage Examples

Chatbot API

from qanswer_sdk import Configuration, ApiClient
from qanswer_sdk.api.chatbot_api import ChatbotApi
from qanswer_sdk.models.chatbot_chat_payload import ChatbotChatPayload

config = Configuration(
    host="https://app.qanswer.ai/backend", api_key={"QAnswer-Api-Key": "your-api-key"}
)

with ApiClient(config) as client:
    api = ChatbotApi(client)

    # Create chat payload
    payload = ChatbotChatPayload(
        question="What is artificial intelligence?",
        username="admin",
        conversation_id="df150332-97c2-4b6a-9d83-cd35e14cf89c",
        llm_choice="openai-large",
        # Add other required fields based on your model
    )

    # Send chat message
    response = api.free_text_chatbot_chat(payload)
    print(response.ai_response)  # Access response data

Chat Completion API

from qanswer_sdk.api.chat_completion_api import ChatCompletionApi

with ApiClient(config) as client:
    api = ChatCompletionApi(client)
    # Use chat completion endpoints...

Handle Different Response Types

# Get just the data
response_data = api.free_text_chatbot_chat(payload)

# Get full HTTP response info
full_response = api.free_text_chatbot_chat_with_http_info(payload)
print(full_response.status_code)
print(full_response.headers)
print(full_response.data)

# Get raw HTTP response for streaming
raw_response = api.free_text_chatbot_chat_without_preload_content(payload)

⚙️ Configuration Options

from qanswer_sdk import Configuration

config = Configuration(
    host="https://app.qanswer.ai/backend",  # API base URL
    api_key={"QAnswer-Api-Key": "your-key"},  # API key auth
    access_token="jwt-token",  # Bearer token auth
    username="user",  # Basic auth username
    password="pass",  # Basic auth password
    verify_ssl=True,  # SSL verification
    ssl_ca_cert="/path/to/ca.pem",  # Custom CA certificate
    connection_pool_maxsize=10,  # Connection pool size
    retries=3,  # Number of retries
    debug=False,  # Enable debug logging
    proxy="http://proxy:8080",  # Proxy URL
)

🛠 Error Handling

from qanswer_sdk.exceptions import (
    ApiException,
    BadRequestException,
    UnauthorizedException,
    NotFoundException,
)

try:
    response = api.free_text_chatbot_chat(payload)
except UnauthorizedException:
    print("Invalid authentication credentials")
except BadRequestException as e:
    print(f"Bad request: {e}")
except ApiException as e:
    print(f"API error: {e.status} - {e.reason}")

📝 Models and Type Safety

All request and response objects are Pydantic models with full type safety:

from qanswer_sdk.models.chatbot_chat_payload import ChatbotChatPayload
from qanswer_sdk.models.chatbot_response import ChatbotResponse

# Create typed request payload
payload = ChatbotChatPayload(
    message="Hello",
    # IDE will provide autocomplete for available fields
)

# Response is fully typed
response: ChatbotResponse = api.free_text_chatbot_chat(payload)
# Access typed response fields with autocomplete
print(response.answer)

📌 Versioning

This SDK follows the version of the QAnswer API. The current version is: 3.2049.0.dev11741 (branch: main)


🤝 Support

For issues related to:

  • SDK usage: Open an issue in this repository
  • API functionality: Contact QAnswer support
  • Authentication: Check your API key and permissions

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ by The QA Company

Metadata

Release files for qanswer-sdk 3.2049.0.dev11741

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qanswer-sdk 3.2049.0.dev11741
File Size Uploaded Provenance Actions
qanswer_sdk-3.2049.0.dev11741.tar.gz 673.5 kB Without provenance Details for qanswer_sdk-3.2049.0.dev11741.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qanswer-sdk 3.2049.0.dev11741
File Interpreter ABI Platform Actions
qanswer_sdk-3.2049.0.dev11741-py3-none-any.whl Python 3 none any Details for qanswer_sdk-3.2049.0.dev11741-py3-none-any.whl

Total release size: 2.1 MB

Release files / qanswer_sdk-3.2049.0.dev11741.tar.gz

Download URL qanswer_sdk-3.2049.0.dev11741.tar.gz
Size 673.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b100182f1f8c11281a3fb6e73abf1a593ed3890e057a18901dd6f217a8c5040d
BLAKE2b-256 checksum
How to use checksums
d42cb851cb8a7cec3da630d3b43adc78f0877db1ccf07946d10ceff0cc18207b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / qanswer_sdk-3.2049.0.dev11741-py3-none-any.whl

Download URL qanswer_sdk-3.2049.0.dev11741-py3-none-any.whl
Size 1.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2c2d3ddba566b6ca41b1b717e8a60b685be9b1cf859551e624bf43817092bea5
BLAKE2b-256 checksum
How to use checksums
0ac47c7319ecb915148917d2d1e1c3d99bc71f5c1b8ee29413154e16bcec5be8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Security for qanswer-sdk 3.2049.0.dev11741

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
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