Skip to main content
POST
/
api
/
v1
/
session
/
pingsession
Ping Session
curl --request POST \
  --url https://api.mor.org/api/v1/session/pingsession \
  --header 'Authorization: <authorization>'
{
  "status": "<string>",
  "session_id": "<string>",
  "response_time_ms": 123,
  "message": "<string>"
}
Ping the session by attempting a simple chat completion. If the chat completion fails, the session is considered dead and will be closed automatically. This is useful for health checks and monitoring session availability.

Headers

Authorization
string
required
API key in format: Bearer sk-xxxxxx

Response

status
string
Status of the session: alive, dead, or no_session
session_id
string
The session ID that was pinged (if a session exists)
response_time_ms
integer
Response time in milliseconds for the ping test
message
string
Status message describing the ping result
How It Works: The ping endpoint sends a minimal chat completion request to the provider. If the provider responds successfully within the timeout period, the session is considered alive. If it fails or times out, the session is automatically closed.
Automatic Closure: If a session fails the ping test, it will be automatically closed to prevent billing for an unresponsive session. You’ll need to create a new session to continue.
Health Monitoring: Use this endpoint in your application’s health checks or monitoring systems to proactively detect and handle dead sessions before users encounter errors.
Best Practice: Implement periodic pings (e.g., every 5 minutes) for long-running sessions to ensure they remain active and responsive. This is especially important for sessions that may experience periods of inactivity.