Prepare for production
Check your keys, timeouts, retries, limits, cost, security and monitoring before you send real traffic through Steel. These are the parts of an integration that usually go wrong when it moves from a test to real traffic. Go through the items before you go live, and again before a large increase in traffic. Most items link to the page that shows how.
Keys and projects
- Use one project for each environment. Give development, staging and production each their own project and project key, so that a test key cannot reach production sessions. All projects in the organization share the concurrent session limit. See Projects.
- Keep keys out of the code. Read the key from
STEEL_API_KEYor a secret store, and never send it to a browser or a mobile app. See API keys.
Timeouts and release
- Release every session. Call
releasein afinallyblock, so that a session also ends when the task fails. Browser time counts until the session ends. See Create a session and Pricing. - Set
timeoutfor the task. A session cannot get more time after it starts. Set timeouts has the default and the limits. - Set
inactivityTimeout. Steel then releases a session when the code that drives it stops, for example after a crash, so a stopped worker costs minutes instead of the full timeout. Leave room for model calls and for people who work in the live view. See Set timeouts. - Sweep for sessions that were left live. Tag sessions with metadata, and release a job's live sessions when the job ends. See Run sessions at scale.
Retries
- Retry only the errors that say they are retryable. Most API errors have
retryable, and some haveretryAfterSeconds. The Steel SDK retries these errors for you. See Run sessions at scale and Errors. - Send an
Idempotency-Keywith Commands requests. A retry with the same key returns the stored result and does not run the commands again. From version 0.23.0, the Steel SDK sends a key for you and keeps it across its retries. See Commands. - Check before you repeat a step that has an effect. A form that orders or pays may have gone through even when your code saw an error. Check the result on the site before you try again.
Limits
- Stay under your concurrent session limit. Queue tasks in your own code, and run fewer workers than your limit. See Limits and Know your limits.
- Stay under your rate limits. A
429response with the coderate_limitedmeans that you created too many sessions in a minute, or sent too many Quick action requests. Wait for the time in theRetry-Afterheader. See Limits. - Check your plan's session length. Split a task that needs more time than your plan allows into shorter sessions, or move to a plan with longer sessions. See Limits.
Cost
- Cut the bandwidth that your pages use. With Steel proxies, you pay for the bandwidth that a session uses. Steel blocks ads by default. Block the images and media that the task does not need as well. See Reduce bandwidth.
- Keep the balance up, and set a spending limit. When the balance runs out, new sessions fail with
402andinsufficient_funds. When the organization reaches its monthly spending limit, they fail with402andbudget_exceeded. Neither error is retryable, so alert on both. See Billing and usage. - Measure cost by customer or by job. Tag sessions with metadata and read each session's cost. See Track cost per customer.
Security
- Treat page content as untrusted input. A page can hold text that tries to give your agent instructions. Do not let page content decide which tools the agent may use or where it sends data.
- Let Steel hold the credentials that your agent uses. Stored credentials fill the sign-in form inside the session, so the password does not pass through your code or the model. See Credentials.
- Protect the live view URL. Anyone with a session's
debugUrlcan watch the session, and can control it while the view is interactive. Send it only to users that your app has checked. See Embed a live browser in your app. - Protect saved state. A session context holds a signed-in account's cookies. Store it like a password. See Session context.
- Keep secrets out of metadata. Steel shows metadata in the dashboard. See Add metadata.
- Review how Steel handles your data. See Security and compliance.
Observability
- Log the session ID with each job. With the ID, you can find any run's recording, logs and cost. See Debug a failed session.
- Watch signals. Count the sessions with
bot_detection_triggered,captcha_encounteredorproxy_connection_failedfor each job, and alert when the count rises. See Signals. - Find failed and crashed sessions. List sessions with
statusset tofailedto find the ones whose browser did not start. A crash can end a session asreleased, so filter byreleaseReasonto find the runs that crashed (browser_crashed) or ran out of time (timeout). See Debug a failed session. - Watch session cost. Read each session's cost after release, to find the jobs that cost the most. See Session cost.
Next steps
- Run sessions at scaleQueue work behind your concurrency limit, and retry and release sessions safely.
- Make sessions faster and cheaperRelease sessions on time, load less, and turn on paid features only where they help.
- Debug a failed sessionFind out why a session failed, starting from its ID.
- SupportLearn where to ask for help, and what to send with each question.