Python SDK for the Backboard API - Build conversational AI applications with persistent memory and intelligent document processing
Project description
Backboard Python SDK
A developer-friendly Python SDK for the Backboard API. Build conversational AI applications with persistent memory and intelligent document processing.
✨ New in v1.1.5
- Simplified Tool Definitions: Use plain JSON objects instead of verbose SDK classes
- Enhanced Tool Call Handling: Object-oriented access with automatic JSON parsing
- Simplified Tool Outputs: Use plain dictionaries for tool results
- Improved Developer Experience: Less boilerplate, more intuitive APIs
Installation
pip install backboard-sdk
Quick Start
from backboard import BackboardClient
# Initialize the client
client = BackboardClient(api_key="your_api_key_here")
# Create an assistant
assistant = client.create_assistant(
name="Support Bot",
description="A helpful customer support assistant"
)
# Create a conversation thread
thread = client.create_thread(assistant.assistant_id)
# Send a message
response = client.add_message(
thread_id=thread.thread_id,
content="Hello! Can you help me with my account?"
)
print(response.latest_message.content)
Features
Assistants
- Create, list, get, update, and delete assistants
- Configure custom tools and capabilities
- Upload documents for assistant-level context
Threads
- Create conversation threads under assistants
- Maintain persistent conversation history
- Support for message attachments
Documents
- Upload documents to assistants or threads
- Automatic processing and indexing for RAG
- Support for PDF, Office files, text, and more
- Real-time processing status tracking
Messages
- Send messages with optional file attachments
- Streaming and non-streaming responses
- Tool calling support
- Custom LLM provider and model selection
API Reference
Client Initialization
client = BackboardClient(api_key="your_api_key")
Assistants
# Create assistant
assistant = client.create_assistant(
name="My Assistant",
description="Assistant description",
tools=[tool_definition] # Optional
)
# List assistants
assistants = client.list_assistants(skip=0, limit=100)
# Get assistant
assistant = client.get_assistant(assistant_id)
# Update assistant
assistant = client.update_assistant(
assistant_id,
name="New Name",
description="New description"
)
# Delete assistant
result = client.delete_assistant(assistant_id)
Threads
# Create thread
thread = client.create_thread(assistant_id)
# List threads
threads = client.list_threads(skip=0, limit=100)
# Get thread with messages
thread = client.get_thread(thread_id)
# Delete thread
result = client.delete_thread(thread_id)
Messages
# Send message
response = client.add_message(
thread_id=thread_id,
content="Your message here",
files=["path/to/file.pdf"], # Optional attachments
llm_provider="openai", # Optional
model_name="gpt-4o", # Optional
stream=False # Set to True for streaming
)
# Streaming messages
for chunk in client.add_message(thread_id, content="Hello", stream=True):
if chunk.get('type') == 'content_streaming':
print(chunk.get('content', ''), end='', flush=True)
Tool Integration (Simplified in v1.0.3)
Tool Definitions
# Use plain JSON objects (no verbose SDK classes needed!)
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}
}
]
assistant = client.create_assistant(
name="Weather Assistant",
tools=tools
)
Tool Call Handling
# Enhanced object-oriented access with automatic JSON parsing
response = client.add_message(thread_id, content="What's the weather in NYC?")
if response.status == 'REQUIRES_ACTION' and response.tool_calls:
for tc in response.tool_calls:
function_name = tc.function.name # Direct property access
function_args = tc.function.parsed_arguments # Auto JSON parsing
tool_call_id = tc.id # Direct property access
# Your tool logic here
result = handle_tool_call(function_name, function_args)
# Submit results using plain dictionaries
client.submit_tool_outputs(
thread_id=thread_id,
run_id=response.run_id,
tool_outputs=[{
"tool_call_id": tool_call_id,
"output": result
}]
)
Documents
# Upload document to assistant
document = client.upload_document_to_assistant(
assistant_id=assistant_id,
file_path="path/to/document.pdf"
)
# Upload document to thread
document = client.upload_document_to_thread(
thread_id=thread_id,
file_path="path/to/document.pdf"
)
# List assistant documents
documents = client.list_assistant_documents(assistant_id)
# List thread documents
documents = client.list_thread_documents(thread_id)
# Get document status
document = client.get_document_status(document_id)
# Delete document
result = client.delete_document(document_id)
Error Handling
The SDK includes comprehensive error handling:
from backboard import (
BackboardAPIError,
BackboardValidationError,
BackboardNotFoundError,
BackboardRateLimitError,
BackboardServerError
)
try:
assistant = client.get_assistant("invalid_id")
except BackboardNotFoundError:
print("Assistant not found")
except BackboardValidationError as e:
print(f"Validation error: {e}")
except BackboardAPIError as e:
print(f"API error: {e}")
Supported File Types
The SDK supports uploading the following file types:
- PDF files (.pdf)
- Microsoft Office files (.docx, .xlsx, .pptx, .doc, .xls, .ppt)
- Text files (.txt, .csv, .md, .markdown)
- Code files (.py, .js, .html, .css, .xml)
- JSON files (.json, .jsonl)
Requirements
- Python 3.8+
- requests >= 2.28.0
License
MIT License - see LICENSE file for details.
Support
- Documentation: https://docs.backboard.io
- Issues: https://github.com/backboard/backboard-python-sdk/issues
- Email: support@backboard.io
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file backboard_sdk-1.1.5.tar.gz.
File metadata
- Download URL: backboard_sdk-1.1.5.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7813e41190236226e7d5b3c0b4ab743206c5437292cd5a5903a06ce851206643
|
|
| MD5 |
21acf94fb463dbc7fa6f386135a9c8c3
|
|
| BLAKE2b-256 |
85ab4a2b383b3579f7b514030b61cf8acad6940c666afc520d4b3c9982cfe100
|
File details
Details for the file backboard_sdk-1.1.5-py3-none-any.whl.
File metadata
- Download URL: backboard_sdk-1.1.5-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c5ad7dc3d844b28222dbb926634a59a81db651424f5748b1c8344fdf6e532ba
|
|
| MD5 |
b8baec6d1ec132ced3ff93f3322df0f7
|
|
| BLAKE2b-256 |
e480caa77768e52840ea2d51fe0a03d2b22e440c3220ca74a1ce74075adef9b3
|