Skip to main content
This quickstart sends one message to a StefanBrain Agent Run and waits for the finished response.

Before you start

Create an API key in Settings → Developers. StefanBrain displays the full secret once, when you create it.
Store the key as a secret. Do not commit it to your repository or include it in client-side code.

Start a run

"sync": true holds the connection for up to about 90 seconds while the run completes:
A run that finishes inside the synchronous wait window returns 200:
Read the finished response from output.

If the run takes longer

When a run outlives the synchronous wait window, the same request returns 202 with its run identifier and lifecycle URLs. No work is lost. Set your HTTP client’s timeout to 120 seconds so it receives that response. Poll the run until its status is completed, failed, or cancelled:
Poll once every 3–10 seconds. Polling does not count against rate limits.

Continue the conversation

Keep the chat identifier from the response. Send it with the next run to continue the same conversation:
Next, read Agent Runs for attachments, structured outputs, events, and cancellation.