Skip to main content

Overview

The Sessions API allows you to retrieve conversation history and access message details. All sessions are scoped to your organization and the API key creator.
Sessions are automatically created when you send messages via Chat Completions API.
Read-Only API: Sessions API provides read-only access. Session deletion and modification are not currently supported via API.

Required Scopes

All Sessions API endpoints require specific API key scopes:
When creating an API key in the Admin panel, ensure you enable the appropriate scopes. Without the required scopes, requests will return a 403 Forbidden error.

Endpoints


List Sessions

Retrieve all sessions created by your API key.

Request

Query Parameters:
Sessions are automatically sorted by last_update_time (most recent first). Custom sorting is not currently supported.

Response

Status Code: 200 OK

Response Fields

cURL Example


Get Session Messages

Retrieve all messages from a specific session.

Request

Path Parameters: Query Parameters:

Response

Status Code: 200 OK

Message Object

Messages are always returned in chronological order (oldest first).

cURL Example


Get Session Processing Status

Check if a session is currently processing a message.

Request

Path Parameters:

Response

Status Code: 200 OK
When not processing:
When timed out (30 minutes):

Response Fields

Sessions automatically timeout after 30 minutes of processing.

cURL Example


Error Handling

Common Errors

Best Practices

  • Use Pagination: Always use pagination with appropriate page_size (max: 100 for sessions, 200 for messages) to avoid timeouts
  • Cache Session Data: Implement caching to reduce API calls (recommended TTL: 5 minutes)
  • Poll Status for Long-Running Requests: Use the status endpoint to check if a session is still processing
  • Handle Errors: Check for 404 (session not found) and 400 (invalid parameters) responses

Next Steps

Chat Completions API

Send messages and create sessions

Authentication

Learn about API key authentication

Rate Limits

Understand rate limiting