Skip to main content
Connect over WebSocket to the deployment associated with the specified environment.

Parameters

string
required
Use model for a model or chain for a Chain.
string
required
The ID of the model or Chain.
string
required
The environment name, such as production.
string
required
Your Baseten API key, passed as Authorization: Bearer $BASETEN_API_KEY. Api-Key is also accepted as the scheme.

Connection behavior

Send the Authorization header in the opening HTTP request over wss://. A successful handshake returns 101 Switching Protocols and opens the WebSocket connection. Your model or Chain defines the message format and exchange. It can send and receive text or binary messages, with no fixed request or response schema across deployments. Each message has a 100 MiB limit in either direction. If Baseten rejects the opening request, it returns an HTTP error before the upgrade. After the upgrade, use WebSocket close codes to diagnose a closed connection. For keepalive configuration, see runtime.transport. The browser’s native WebSocket API can’t set the required Authorization header. Connect through your backend, which supplies the header and keeps your Baseten API key on the server. For server implementation and deployment behavior, see WebSockets. For regional URLs, see Regional environments and Regional deployments.

Example

Set BASETEN_API_KEY to your API key, then replace the URL placeholders with your target. Use websocat to connect: