> ## Documentation Index
> Fetch the complete documentation index at: https://docs.glasswarp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Your first session

> Start a session, capture a frame, send input, and clean up.

With an [installed host](/get-started/install-host) and an
[eligible rig](/get-started/pair-rig), you're ready to run a full session.

## Full example

```python theme={null}
import os
from glasswarp import GlasswarpClient

gw = GlasswarpClient(api_key=os.environ["GLASSWARP_API_KEY"])

rig = next(
    (r for r in gw.list_rigs() if r.online and r.api_access_enabled),
    None,
)
if rig is None:
    raise RuntimeError("No online rig with API access enabled")

session = gw.create_session(rig_id=rig.id, mode="desktop")
sid = session.session_id
print("session:", sid)

try:
    frame = gw.screenshot(sid)
    with open("first_frame.jpg", "wb") as f:
        f.write(frame.jpeg)
    print("captured", len(frame.jpeg), "bytes")

    gw.click(sid, x=500, y=400)
    gw.type_text(sid, "Hello from an agent")
    gw.key_press(sid, "Enter")
finally:
    gw.end_session(sid)
```

## What happens

<Steps>
  <Step title="create_session">
    The gateway checks rig ownership and consent, then the host starts a desktop
    session and shows the on-screen "API session active" indicator.
  </Step>

  <Step title="screenshot">
    The host captures a fresh native-resolution JPEG (works with or without a
    live WebRTC stream).
  </Step>

  <Step title="click / type_text / key_press">
    Input is injected as native Win32 events on the real machine.
  </Step>

  <Step title="end_session">
    The host runs `safety_restore` and tears the session down. Always end
    sessions — they meter usage.
  </Step>
</Steps>

<Warning>
  Wrap actions in `try/finally` and always call `end_session`. Sessions meter
  usage and hold the host's pipeline. `safety_restore` also runs automatically
  on disconnect, launch failure, and `END_SESSION`.
</Warning>

## Watch it live

Open **Console → Sessions → Eye** to watch at 60fps while your code runs. See
[Live View](/guides/live-view).

Next: [ground your clicks](/concepts/grounding) and [build an agent
loop](/guides/agent-loop).
