Skip to main content
WS /v1/ws reads every frame you send with one model and method, and returns the model’s reply as a result event. The reply is what Chat Completions returns for the same image. You name the model and method once, in session.create, then send each frame as one binary message of raw image bytes. The session reads one frame at a time by default. A frame that arrives while a read is outstanding is dropped with reason: "busy", and a frame that arrives faster than the model’s max_fps is dropped with reason: "rate". The lifecycle, close codes, and models are on Realtime.

Example

The sample opens a pose session on usyd-community/vitpose-plus-large, sends one photo 20 times at the model’s max_fps, and prints each result, frame.dropped, and error. It then sends session.close and prints session.stats.

The result event

content is the pose method’s output as a JSON string: an img.pose.kpts container with one item per person. response.usage.cost is null. The socket does not bill per frame: it bills the session by the second, as session.stats.cost.

Session stats

Of the 20 frames, 5 were read and 15 arrived while a read was outstanding. The session was open about 1.8 seconds, which is $0.0015 at $3 / hour. The frame count does not change the price. Read the row back with GET /v1/completions/{id}.

Read more of the frames

Backpressure drops. It never queues. A queued frame would answer for a moment you have already moved past. Each dropped frame is reported, so you can count what you skipped.
  • Raise max_inflight. Set it in session.create, up to 8. The session keeps that many reads outstanding, and a slot frees when its read returns.
  • Pace at max_fps. session.created returns the model’s rate. Sending faster only adds rate drops.
  • Close the session when you stop. A session bills every second it is open, with or without frames. Send session.close instead of leaving it to the 30 second idle close.

Pick the model and method

session.create takes the same method and method_params as a Chat Completions request. See Methods. prompt is optional text that goes with every frame.
geopavlakos/hamer returns one world.pose.kpts item per hand, with 2D and 3D joints. A model without realtime support is refused at session.create. The models that stream on this socket are listed in Supported models.

Errors

An error event with a frame applies to that frame only, and the session stays open. A frame that is not JPEG, PNG, WebP, or GIF, or is larger than max_frame_bytes, returns invalid_request_error. A model failure returns overloaded_error or api_error with retry_after. An error at open, or when the session reaches its spend ceiling, ends the session, and a close follows. The error types are in the reference. What to do after each close code is in Close codes.

Limits and cost

A session lasts up to 10 minutes, closes after 30 seconds idle, and stops at $5 of spend. Frames are capped at 2 MiB. Sessions per plan are on Rate Limits, and the price of each model on the socket is in Supported models.

Next steps

WS /v1/ws reference

Every client and server event, with its fields.

Response Types

The keypoint payload each result carries.

Realtime System One

Typed decisions per frame instead of a model reply.

Rate Limits

Sessions per plan and per-session bounds.