Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.trynebula.ai/llms.txt

Use this file to discover all available pages before exploring further.

How Conversations Work

Conversations are stored as conversation memories. Create one with engram_type="conversation" and a messages list, then append more messages to the same memory_id over time.
  • engram_type="conversation": Marks the memory as a conversation (set on memories.create).
  • messages: A list of message objects, each with role (user, assistant, or system) and content.
  • memory_id: The id returned from memories.create(). Pass it as the first argument to memories.append() to add more messages.
Conversation memories contain the full message history. See Core Concepts for the memory/source model.

Creating and Adding Messages

from nebula import Nebula
nebula = Nebula()

# Get or create your collection
collection = nebula.collections.create(name="Support Chats").results

# Create conversation with initial message
conv = nebula.memories.create(
    collection_id=collection.id,
    engram_type="conversation",
    messages=[{"content": "Hello! How can I help?", "role": "assistant"}],
    metadata={"conversation_name": "Support Chat"},
).results
conv_id = conv.id

# Add a message to the same conversation
nebula.memories.append(
    conv_id,
    collection_id=collection.id,
    messages=[{"content": "I need help with my account", "role": "user"}],
)

# Add multiple messages at once
nebula.memories.append(
    conv_id,
    collection_id=collection.id,
    messages=[
        {"content": "What issue are you having?", "role": "assistant"},
        {"content": "I can't log in", "role": "user"},
    ],
)

Retrieving Conversations

Use memories.list() to retrieve conversations with their message chunks, or memories.retrieve() for a single conversation.
# List conversations in a collection — each chunk is one message: {"text", "role"}
conversations = nebula.memories.list(
    collection_ids=[collection.id],
).results
for conv in conversations:
    for chunk in conv.chunks or []:
        print(f"{chunk['role']}: {chunk['text']}")

# Get a single conversation
memory = nebula.memories.retrieve(conv_id).results

Next Steps