Skip to content

Conversations

Conversations allow you to organize and persist interactions within the Airia platform. See the Conversations API reference and response types for more details.

Create Conversation

You can create a conversation using the create_conversation method.

from airia import AiriaClient

client = AiriaClient(api_key="your_api_key")
# Or with bearer token: client = AiriaClient.with_bearer_token(bearer_token="your_bearer_token")

# Create a basic conversation
conversation = client.conversations.create_conversation(
    user_id="user_123"
)
print(f"Created conversation: {conversation.conversation_id}")
print(f"WebSocket URL: {conversation.websocket_url}")

# Create a conversation with all options
conversation = client.conversations.create_conversation(
    user_id="user_123",
    title="My Research Session",
    deployment_id="deployment_456", 
    data_source_files={"documents": ["doc1.pdf", "doc2.txt"]},
    is_bookmarked=True
)
print(f"Created bookmarked conversation: {conversation.conversation_id}")

Get Conversation

You can retrieve information about existing conversations using the get_conversation method:

from airia import AiriaClient

client = AiriaClient(api_key="your_api_key")
# Or with bearer token: client = AiriaClient.with_bearer_token(bearer_token="your_bearer_token")

# Get conversation details
conversation = client.conversations.get_conversation(conversation_id="your_conversation_id")

print(f"Conversation ID: {conversation.conversation_id}")
print(f"User ID: {conversation.user_id}")
print(f"Title: {conversation.title}")
print(f"Created: {conversation.created_at}")
print(f"Updated: {conversation.updated_at}")
print(f"Bookmarked: {conversation.is_bookmarked}")
if conversation.deployment_id:
    print(f"Deployment ID: {conversation.deployment_id}")

Delete Conversation

You can permanently delete conversations using the delete_conversation method:

from airia import AiriaClient

client = AiriaClient(api_key="your_api_key")

# Delete a conversation (permanently removes all data)
client.conversations.delete_conversation(conversation_id="your_conversation_id")
print("Conversation deleted successfully")

# Handle deletion of non-existent conversations
try:
    client.delete_conversation(conversation_id="nonexistent_id")
except AiriaAPIError as e:
    if e.status_code == 404:
        print("Conversation not found")
    else:
        print(f"Error deleting conversation: {e.message}")