AIInbx Python Client
The official Python library for interacting with the AIInbx API. It provides a convenient way to access AIInbx services, handling authentication and data serialization. The library is actively maintained with frequent releases, often daily or weekly, reflecting ongoing API updates.
Common errors
-
aiinbx.APIStatusError: 401 Unauthorized
cause The AIInbx API Key is missing, incorrect, or expired.fixEnsure the `AIINBX_API_KEY` environment variable is set correctly or pass the `api_key` argument directly to the `AIInbx` client constructor with a valid key: `client = AIInbx(api_key='YOUR_SECRET_KEY')`. -
AttributeError: 'Messages' object has no attribute 'get_all'
cause An API method name has changed (e.g., from `get_all` to `list`) or was never exposed under that name.fixRefer to the latest AIInbx API documentation or the library's source code/changelog for the correct method names (e.g., `client.messages.list()`). API endpoints often standardize on `list`, `retrieve`, `create`, `update`, `delete`. -
TypeError: Expected a sync client, but got an async client. You likely used 'await' with a sync client method.
cause You are trying to use `await` on a method of the synchronous `AIInbx` client.fixIf you intend to use asynchronous operations, instantiate `AsyncAIInbx` instead of `AIInbx`: `from aiinbx import AsyncAIInbx; async_client = AsyncAIInbx(...)`. Then, ensure your code runs within an `async` function and uses `await` correctly for all API calls.
Warnings
- gotcha The AIInbx API and its Python client are under active development, leading to frequent version updates (often daily or weekly). While semantic versioning is generally followed, minor versions may introduce new features or slight breaking changes that require keeping your library updated.
- breaking Frequent 'api update' features in minor versions (e.g., v0.826.0 -> v0.827.0) indicate that the available methods, their signatures, or the structure of response objects may change. Your existing code might break if methods are renamed or removed, or if data structures evolve.
- gotcha When uploading files, ensure they are passed correctly as a single parameter, especially if using a dictionary for multipart forms. A bug fix in v0.827.2 addressed an issue where file data might be sent incorrectly.
Install
-
pip install aiinbx
Imports
- AIInbx
from aiinbx import AIInbx
- AsyncAIInbx
from aiinbx import AsyncAIInbx
- APIStatusError
from aiinbx.errors import APIStatusError
from aiinbx import APIStatusError
Quickstart
import os
from aiinbx import AIInbx
# Initialize the client with your API key from an environment variable
client = AIInbx(
api_key=os.environ.get("AIINBX_API_KEY", ""),
)
# Example: List messages
try:
# This call might vary based on specific AIInbx API methods
# Check official documentation for the latest methods (e.g., client.messages.list())
messages_page = client.messages.list()
for message in messages_page.data:
print(f"Message ID: {message.id}, Content snippet: {message.content[:50]}...")
print(f"Total messages retrieved: {len(messages_page.data)}")
except Exception as e:
print(f"An error occurred: {e}")
if not os.environ.get("AIINBX_API_KEY"):
print("Please ensure the AIINBX_API_KEY environment variable is set.")