This is the Python snippet from your agent’s page in the dashboard, which fills in the agent’s URL for you. It uses httpx, and there is no Onecortex SDK to install.
Before you begin
- A deployed agent and its ID, from its page in the dashboard.
- An API key in
ONECORTEX_API_KEY.
pip install httpx.
Stream the reply
Replace agt_... with your agent’s ID:
For the quickstart’s echo agent:
httpx waits 5 seconds for data by default, and an agent can think for longer than that before its first token. For a long running agent pass timeout=None, or a timeout longer than 15 seconds: Onecortex keeps an idle stream alive with a comment line every 15 seconds.
A stream that has started has already sent 200 OK, and cannot change it. If the run fails after that, the failure arrives in the stream as event: error. Handle it: a client that reads only text and done shows a failed run as an empty success.
Get one JSON response
Leave out "stream": True to wait for the whole run and get one body:
Every field of the body is on the invoke API.
Continue a conversation
Send the same sessionId on each call to reach the same running instance of your agent:
See Sessions for what a session keeps, and what it does not.