Skip to main content

Documentation Index

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

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

What this builds. A real-time chat against an already-saved Chatbot, fetched by name. You’ll end up with. A connected session id and a streamed assistant reply — proving the Session API is identical for agents and chatbots. Demonstrates that the same Session class works for chatbots, providing a unified real-time experience across both agents and chatbots.
import asyncio

from vectorshift import Chatbot
from vectorshift.events import SessionEventType


async def main() -> None:
    # Fetch an existing chatbot (must already exist)
    chatbot = Chatbot.fetch(name="My Chatbot")
    print(f"Fetched chatbot: {chatbot.name} (id={chatbot.id})")

    # Open a session - same API as agent.create_session()
    async with await chatbot.create_session() as session:
        print(f"Session connected: {session.session_id}")

        await session.send("Hello! What can you help me with?")

        print("\nAssistant: ", end="", flush=True)
        async for event in session.listen(
            event_types=[
                SessionEventType.MESSAGE_DELTA,
                SessionEventType.MESSAGE_COMPLETE,
            ]
        ):
            if event.delta:
                print(event.delta, end="", flush=True)
            if event.is_complete:
                break
        print()

    print("\nDone.")


if __name__ == "__main__":
    asyncio.run(main())

Expected output

Fetched chatbot: My Chatbot (id=...)
Session connected: ...

Assistant: Hi there! I can help you with...

Done.
The Chatbot.create_session() API is intentionally identical to Agent.create_session() — every session example in this section works against a Chatbot just by swapping the wrapper.
See Session overview for the streaming model shared by agents and chatbots.

See also

Single-turn session

The same shape with an Agent instead of a Chatbot.

Resume a session

Reconnect to a saved chatbot session by id.

Session reference

The unified Session surface.