Sign in to the dashboard and go to Settings → API Keys → Create API key. Copy the sb_live_... value shown in the banner — it’s displayed exactly once. Lose it and you’ll need to mint a new one.
Never commit the key to source control. Put it in a secret manager, an env var, or your deploy pipeline’s secret store. A leaked key lets anyone call the API as you until you revoke it.
import osfrom stablebrowse import Stablebrowseclient = Stablebrowse(api_key=os.environ["STABLEBROWSE_API_KEY"])result = client.tasks.run( end_user_id="alice", task="What is the current top story on Hacker News?",)print(result.result)
That’s it. The SDK submits the task, polls the server until it completes, and returns the answer. Typical latency: 5-30 seconds for public sites, 10-60 seconds for sites behind logins.
The first task minted a session_id on the server. Pass it back to continue the conversation — the agent will have the first answer as context:
follow_up = client.tasks.run( end_user_id="alice", task="How many comments does that story have?", session_id=result.session_id,)print(follow_up.result)
If you need data from Twitter, Reddit, TikTok, YouTube, or Instagram behind a login, upload your end-user’s cookies first:
client.end_users("alice").credentials.set( twitter_auth_token="...", twitter_ct0="...",)result = client.tasks.run( end_user_id="alice", task="Give me the two most recent tweets from @narendramodi.",)
See Platforms for the full list of supported sites and which cookies each one needs.