Skip to main content
Needs an API key and a published agent. Nothing else — no connection, no keypair, no endpoint of your own.

The script

Handling a pause

The loop above exits on closed or failed. A real client also has to handle a run that stops and waits — awaiting_input is not terminal, so the loop would spin forever. Poll the thread list instead, which tells you why it paused:
At most one is ever set. Answer a question by posting a message; resolve the other two with confirm or outcome.

Reusing the thread

Keep the thread id. The same subject talking to the same agent should reuse it — that is what gives a returning user their history. Start a new thread when the conversation should start clean.