Back to Blog
Engineering

Michael Rodriguez5 min
Home

Stateless predict is a single-shot loop: you send a screenshot and instruction, you get actions back, you capture again, and you keep looping until status is done. Stateless predict costs $0.05 per call. Stateful sessions instead create a trajectory with a session ID, then predict against that trajectory. The first session creation costs $0.10, and each subsequent predict against that session costs $0.04. Sessions are the right choice when you need the agent to remember context across steps, such as multi-page workflows, login flows, or long-running tasks.

How stateless predict works

Stateless predict uses POST /v1/predict. The request body includes base64 screenshot, instruction, and cua_version. The response contains actions and a status. You loop capture, predict, act until status is done. Each predict call is billed $0.05. This mode is ideal for one-off, short interactions where you do not need to store history between calls.

bash
curl -X POST https://coasty.ai/v1/predict \ 
  -H "X-API-Key: $COASTY_API_KEY" \ 
  -H "Content-Type: application/json" \ 
  -d '{
    "screenshot": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==",
    "instruction": "Click the first link you see",
    "cua_version": "v3"
  }'

How stateful sessions work

Stateful sessions start with POST /v1/sessions, which creates a trajectory and returns a session_id. The first call costs $0.10. Then you send POST /v1/sessions/{id}/predict with the same screenshot and instruction fields. Each predict against that session costs $0.04. The server retains the trajectory between calls, so the agent can reference previous actions and context. Sessions are ideal for multi-step flows where the agent needs to remember prior steps.

bash
curl -X POST https://coasty.ai/v1/sessions \ 
  -H "X-API-Key: $COASTY_API_KEY" \ 
  -H "Content-Type: application/json" \ 
  -d '{
    "screenshot": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==",
    "instruction": "Click the first link you see",
    "cua_version": "v3"
  }'

# Response
{
  "session_id": "sess_abc123",
  "status": "running",
  "trajectory": [...]
}

# Later predict against the session
curl -X POST https://coasty.ai/v1/sessions/sess_abc123/predict \ 
  -H "X-API-Key: $COASTY_API_KEY" \ 
  -H "Content-Type: application/json" \ 
  -d '{
    "screenshot": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==",
    "instruction": "Wait for the page to load then click the login button",
    "cua_version": "v3"
  }'

Key differences

  • Stateless predict: one-shot, $0.05 per predict, no trajectory storage.
  • Stateful sessions: first predict costs $0.10 to create a trajectory, subsequent predicts cost $0.04.
  • Sessions retain trajectory between calls, allowing the agent to reference previous actions.
  • Use stateless predict for simple, short interactions without history.
  • Use stateful sessions for multi-step flows that need context.

Sessions cost $0.10 to create a trajectory, then $0.04 per predict. Stateless predict costs $0.05 per predict and does not store history.

Why computer use beats brittle automation

Stateless predict and stateful sessions both see the screen, so they work with UI elements by description, not by brittle selectors. An agent can click a button that has no stable ID, or navigate a dynamic DOM. This visual understanding lets you build agents that work across different browsers, versions, and layouts without maintaining a separate selector database. Computer use agents handle visual changes gracefully, whereas API-only tools break when minor UI updates occur.

Choose stateless predict for quick, single-shot tasks. Choose stateful sessions when you need the agent to remember context across steps. Build robust automation that adapts to visual changes. Get your API key at https://coasty.ai/developers to start building.

© 2026 Coasty

Backed byYCombinator