Skip to content
StudyFetch API

Performance Insights

Stream analytics response

Streams an AI-powered analytics response using server-sent events (SSE). The AI can query TrueLearn data, generate charts, and provide insights about learner performance.

OpenAPI specification
POST/api/v1/performance-insights/stream

Authentication

x-api-key

Request

curl --globoff --request POST \
  --url 'https://api.example.com/api/v1/performance-insights/stream' \
  --header 'x-api-key: <API_KEY>' \
  --header 'Content-Type: application/json' \
  --data-raw '{}'

Replace credential and <field> placeholders with your own values. URL placeholders appear as %3Cfield%3E. Review the example values before sending your request.

Replace https://api.example.com with the API server URL.

Use the sample JSON body as your starting point, and enter values that match the endpoint's schema.

Parameters

x-user-idheader · string

User ID (used when authenticating via API key)

x-embed-tokenheader · string

Embed token containing the TrueLearn userContextJwt

Request body schema or example

{
  "type": "object",
  "properties": {
    "messages": {
      "description": "Messages array for AI SDK format - list of conversation messages with roles",
      "example": [
        {
          "role": "user",
          "content": "Hello"
        },
        {
          "role": "assistant",
          "content": "Hi there!"
        },
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "What is in this image?"
            },
            {
              "type": "image",
              "image_url": {
                "url": "https://example.com/image.jpg"
              }
            }
          ]
        }
      ],
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "message": {
      "description": "Single message for custom format - contains text and optional images",
      "allOf": [
        {
          "type": "object",
          "properties": {
            "text": {
              "type": "string",
              "description": "Text content of the message"
            },
            "images": {
              "description": "Images attached to the message",
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "description": "URL of the image"
                  },
                  "base64": {
                    "type": "string",
                    "description": "Base64 encoded image data"
                  },
                  "mimeType": {
                    "type": "string",
                    "description": "MIME type of the image"
                  },
                  "caption": {
                    "type": "string",
                    "description": "Caption for the image"
                  }
                }
              }
            }
          }
        }
      ]
    },
    "componentId": {
      "type": "string",
      "description": "Component ID"
    },
    "userId": {
      "type": "string",
      "description": "User ID"
    },
    "groupIds": {
      "description": "Group IDs for access control",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "sessionId": {
      "type": "string",
      "description": "Session ID"
    },
    "id": {
      "type": "string",
      "description": "Session ID (AI SDK uses \"id\")"
    },
    "timezone": {
      "type": "string",
      "description": "IANA timezone string (e.g. \"America/New_York\")"
    },
    "context": {
      "type": "object",
      "description": "Additional context"
    },
    "trigger": {
      "type": "string",
      "description": "Trigger for AI SDK (what triggered the message)"
    }
  }
}

Responses

200SSE stream of analytics response (text/plain)
400Messages array is required