Quickstart

Create a thread, stream the agent's reply, and generate the conversation's title.

Install

pip install aice-agent-platform

The package brings the LangGraph SDK with it (langgraph-sdk / @langchain/langgraph-sdk).

Create a client for the user

The Agent Platform needs to know which user a conversation belongs to, so the user is required and fixed when you build the client.

import os
from aice_agent_platform import AgentPlatformClient

client = AgentPlatformClient(
    base_url=os.environ["AICE_AGENT_URL"],  # http://localhost:6060 locally
    api_key=os.environ["AICE_API_KEY"],
    user_id=current_user.id,                # a UUID
)

Stream a reply

Create a thread, then stream a run on it. agent_platform is the graph ID and never changes.

thread = client.threads.create()
thread_id = thread["thread_id"]

for chunk in client.runs.stream(
    thread_id,
    "agent_platform",
    input={"messages": [{"role": "user", "content": "Hello!"}]},
    stream_mode=["messages-tuple"],
):
    if chunk.event == "messages":
        message, _metadata = chunk.data
        print(message.get("content", ""), end="", flush=True)

Finish the turn

The service can't tell a finished stream from a dropped connection, so your code says when a turn is done. This one call writes the thread's title and returns follow-up suggestions:

result = client.suggestions.create_for_thread(thread_id)
print("\n", result["thread_name"])
for s in result["suggestions"]:
    print(" ·", s["title"])

Skip it and the thread keeps a placeholder title and never gets follow-ups.

That's the whole happy path. From here:

  • Streaming: accumulate chunks per message, cancel, and recover from a dropped connection.
  • Build a chat UI: put this behind your backend and stream it to a browser.

Async Python

AsyncAgentPlatformClient has the same methods. Use it in async frameworks so a long reply doesn't hold a worker thread: await client.threads.create() and async for chunk in client.runs.stream(...).

On this page