npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@santillana-ai/typescript-tutor-sdk

v5.9.0

Published

TypeScript SDK for integrating Santillana's AI-powered tutoring system into educational applications.

Readme

Santillana AI Tutor SDK

TypeScript SDK for integrating Santillana's AI-powered tutoring system into educational applications.

📚 Table of Contents

Introduction

Santillana AI Tutor SDK provides a simple, type-safe interface for interacting with the intelligent tutoring system. It enables management of learning activities, personalized tutoring sessions, and real-time communication with the AI agent.

🚀 Key Features

  • Pedagogical AI Tutor: Specialized tutoring system with Socratic method
  • Flexible Sessions: With structured activities or free-form
  • Content Adaptation: Universal Design for Learning (DUA) principles for inclusive content
  • Native TypeScript: Full autocomplete and type-safety
  • Easy Integration: Compatible with Next.js, React, and Node.js

Installation

🎯 Quick Start with Template

The fastest way to get started is using our Next.js template:

npx @santillana-ai/create-tutor-app@latest my-tutor-app
cd my-tutor-app
npm run dev

📦 Manual Installation

NPM

npm install @santillana-ai/typescript-tutor-sdk

PNPM

pnpm add @santillana-ai/typescript-tutor-sdk

Bun

bun add @santillana-ai/typescript-tutor-sdk

Yarn

yarn add @santillana-ai/typescript-tutor-sdk zod

Note: Yarn requires manually installing zod as a peer dependency.

Configuration

1. Get API Key

Request your API Key from the Santillana AI Tutor administration system.

2. Environment Variables Setup

Create a .env.local file in your project:

SANTILLANA_API_KEY=sk_live_your_api_key_here
SANTILLANA_API_URL=https://ai-tutor-sdk-api.vercel.app

3. Initialize SDK

import { SDK } from '@santillana-ai/typescript-tutor-sdk';

const sdk = new SDK({
  apiKey: process.env.SANTILLANA_API_KEY!,
  serverURL: process.env.SANTILLANA_API_URL || 'https://ai-tutor-sdk-api.vercel.app'
});

Quick Start

Basic Example

// 1. List available activities
const activities = await sdk.activities.findAll({
  limit: 10,
  offset: 0
});

// 2. Start session with an activity
const session = await sdk.sessions.startSession({
  activityId: activities.data[0].id,
  studentId: 'student-123'
});

// 3. Send message to tutor
const response = await sdk.sessions.sendMessage({
  sessionId: session.data.session.id,
  content: 'Can you help me with this exercise?'
});

console.log('Tutor:', response.data.assistantMessage.content);

Core Features

Activity Management

Activities are structured learning units with objectives, exercises, and evaluation.

// Get all activities
const activities = await sdk.activities.findAll({
  limit: 20,
  offset: 0
});

// Get specific activity with exercises
const activity = await sdk.activities.findOne({
  id: 'activity-id'
});

// Get exercises from an activity
const exercises = await sdk.activities.getExercises({
  activityId: 'activity-id'
});

Activity Sessions

Activity sessions provide a structured and guided learning experience.

// Start session with activity
const session = await sdk.sessions.startSession({
  activityId: 'activity-id',
  studentId: 'student-123'
});

// Send message to the tutor
const response = await sdk.sessions.sendMessage({
  sessionId: session.data.session.id,
  content: "I don't understand this concept"
});

// View student progress
const progress = await sdk.sessions.getSessionProgress({
  sessionId: session.data.session.id
});

Free Sessions

Perfect for quick questions, topic exploration, or self-directed learning.

// Start free session with custom configuration
const freeSession = await sdk.freeSessions.startFreeSession({
  userId: 'student-123',
  config: {
    enableSocraticMethod: true,  // Guide with reflective questions
    enableBloomTaxonomy: true,   // Gradual progression
    topic: 'Mathematics',
    learningObjective: 'Understand fractions'
  }
});

// Send message in free session
const response = await sdk.freeSessions.sendFreeSessionMessage({
  sessionId: freeSession.data.session.id,
  sendFreeSessionMessageDto: {
    content: 'What is a fraction?'
  }
});

Content Adaptation Tool

Adapt any educational content using Universal Design for Learning (DUA) principles to make it more accessible and inclusive.

Available DUA Features

Representation (Multiple ways to present information):

  • r1_simplifiedLanguage: Simplify vocabulary and sentence structure
  • r2_visualSupports: Add visual aids and diagrams suggestions
  • r3_audioSupports: Include detailed audio descriptions
  • r4_languageScaffolds: Add definitions and language support

Engagement (Multiple ways to motivate):

  • e5_chunkingTime: Break content into manageable segments
  • e6_interestsChoice: Provide choices based on interests
  • e7_collaboration: Include collaborative elements

Action & Expression (Multiple ways to demonstrate learning):

  • a8_guidedSteps: Provide step-by-step instructions
  • a9_alternativeOutputs: Allow different response formats
  • a10_fineMotorSupports: Adapt for motor difficulties
  • a11_processingSpeed: Adjust for different processing speeds

Basic Usage

// Simple content adaptation
const adaptedContent = await sdk.tools.adaptContent({
  content: "The water cycle consists of evaporation, condensation, and precipitation.",
  duaFeatures: {
    representation: {
      r1_simplifiedLanguage: true,
      r2_visualSupports: true
    }
  },
  metadata: {
    subject: "Science",
    grade: "4th grade",
    language: "es"
  }
});

// Access the adapted content
console.log(adaptedContent.adaptedContent);
console.log(adaptedContent.appliedFeatures);
console.log(adaptedContent.suggestions);

Comprehensive Adaptation

// Apply multiple DUA features for inclusive content
const fullAdaptation = await sdk.tools.adaptContent({
  content: "Photosynthesis is the process by which plants convert light energy into chemical energy stored in glucose.",
  duaFeatures: {
    representation: {
      r1_simplifiedLanguage: true,
      r2_visualSupports: true,
      r4_languageScaffolds: true
    },
    engagement: {
      e5_chunkingTime: true,
      e6_interestsChoice: true
    },
    actionExpression: {
      a8_guidedSteps: true,
      a9_alternativeOutputs: true
    }
  },
  metadata: {
    subject: "Biology",
    grade: "7th grade",
    context: "Students with diverse learning needs"
  }
});

Example Use Cases

For Visual Learners
const adapted = await sdk.tools.adaptContent({
  content: "Complex mathematical concepts...",
  duaFeatures: {
    representation: {
      r2_visualSupports: true,
      r4_languageScaffolds: true
    }
  }
});
For Students with Attention Challenges
const adapted = await sdk.tools.adaptContent({
  content: "Long historical text...",
  duaFeatures: {
    engagement: {
      e5_chunkingTime: true,
      e6_interestsChoice: true
    },
    representation: {
      r1_simplifiedLanguage: true
    }
  }
});
For Diverse Learning Styles
const adapted = await sdk.tools.adaptContent({
  content: "Science experiment instructions...",
  duaFeatures: {
    actionExpression: {
      a8_guidedSteps: true,
      a9_alternativeOutputs: true,
      a11_processingSpeed: true
    }
  }
});

Implementation Examples

Next.js: Chat Component

'use client';

import { useState } from 'react';
import { SDK } from '@santillana-ai/typescript-tutor-sdk';

const sdk = new SDK({
  apiKey: process.env.NEXT_PUBLIC_SANTILLANA_API_KEY!
});

export function ChatTutor({ studentId }: { studentId: string }) {
  const [sessionId, setSessionId] = useState<string>('');
  const [messages, setMessages] = useState<any[]>([]);
  const [input, setInput] = useState('');
  // Start free session
  const startSession = async () => {
    const session = await sdk.freeSessions.startFreeSession({
      userId: studentId,
      config: {
        enableSocraticMethod: true,
        enableBloomTaxonomy: true
      }
    });
    setSessionId(session.data.session.id);
  };

  // Send message
  const sendMessage = async () => {
    if (!input.trim() || !sessionId) return;

    const response = await sdk.freeSessions.sendFreeSessionMessage({
      sessionId,
      sendFreeSessionMessageDto: {
        content: input
      }
    });

    setMessages([
      ...messages,
      { role: 'user', content: input },
      { role: 'assistant', content: response.data.assistantMessage.content }
    ]);
    setInput('');
  };

  return (
    <div className="chat-container">
      {!sessionId ? (
        <button onClick={startSession}>Start Session</button>
      ) : (
        <>
          {/* Messages */}
          <div className="messages">
            {messages.map((msg, idx) => (
              <div key={idx} className={`message ${msg.role}`}>
                {msg.content}
              </div>
            ))}
          </div>

          {/* Input */}
          <div className="input-area">
            <input
              value={input}
              onChange={(e) => setInput(e.target.value)}
              onKeyPress={(e) => e.key === 'Enter' && sendMessage()}
              placeholder="Type your question..."
            />
            <button onClick={sendMessage}>Send</button>
          </div>
        </>
      )}
    </div>
  );
}

API Route in Next.js

// app/api/sessions/start/route.ts
import { NextResponse } from 'next/server';
import { SDK } from '@santillana-ai/typescript-tutor-sdk';

const sdk = new SDK({
  apiKey: process.env.SANTILLANA_API_KEY!
});

export async function POST(request: Request) {
  const body = await request.json();
  const { userId, accessibilityProfile } = body;

  try {
    const session = await sdk.freeSessions.startFreeSession({
      userId,
      config: {
        enableSocraticMethod: true,
        enableBloomTaxonomy: true,
        // Content adaptation now available via sdk.tools.adaptContent()
      }
    });

    return NextResponse.json(session);
  } catch (error) {
    return NextResponse.json(
      { error: 'Error starting session' },
      { status: 500 }
    );
  }
}

API Reference

Available Modules

Activities

  • findAll() - List activities with pagination
  • findOne() - Get activity by ID
  • create() - Create new activity
  • update() - Update activity
  • remove() - Delete activity
  • getExercises() - Get exercises
  • addExercise() - Add exercise
  • updateExercise() - Update exercise
  • removeExercise() - Remove exercise

Sessions

  • startSession() - Start/resume session with activity
  • sendMessage() - Send message to AI tutor
  • getMessages() - Get message history
  • getSession() - Get session details
  • getSessionProgress() - View progress
  • resetSession() - Reset session

FreeSessions

  • startFreeSession() - Start free session with configuration
  • sendFreeSessionMessage() - Send message to AI tutor
  • getFreeSessionMessages() - Get history
  • getFreeSession() - Get details

Configuration Types

// Free session configuration
interface SessionConfig {
  enableSocraticMethod?: boolean;
  enableBloomTaxonomy?: boolean;
  topic?: string;
  learningObjective?: string;
  // Note: For content adaptation use sdk.tools.adaptContent() with DUA features
}

Error Handling

Error Catching

import { SDK } from '@santillana-ai/typescript-tutor-sdk';
import * as errors from '@santillana-ai/typescript-tutor-sdk/models/errors';

const sdk = new SDK({ apiKey: 'your-api-key' });

try {
  const activities = await sdk.activities.findAll();
} catch (error) {
  if (error instanceof errors.SDKError) {
    switch (error.httpMeta.response.status) {
      case 401:
        console.error('Invalid API Key');
        break;
      case 403:
        console.error('No permissions');
        break;
      case 404:
        console.error('Resource not found');
        break;
      case 429:
        console.error('Request limit exceeded');
        break;
      case 500:
        console.error('Server error');
        break;
    }
  }
}

Retry Configuration

const sdk = new SDK({
  apiKey: 'your-api-key',
  retryConfig: {
    strategy: 'backoff',
    backoff: {
      initialInterval: 1,
      maxInterval: 50,
      exponent: 1.1,
      maxElapsedTime: 100,
    },
    retryConnectionErrors: true,
  },
});

Support

Resources

Recommended Use Cases

Use Activity Sessions when:

  • ✅ You need formal structure and evaluation
  • ✅ Following a defined curriculum
  • ✅ Requiring specific progress measurement
  • ✅ Students need clear guidance

Use Free Sessions when:

  • ✅ Solving quick questions
  • ✅ Exploring topics of interest
  • ✅ Review without rigid structure
  • ✅ Self-directed learning

Use Accessibility Profiles when:

  • ✅ Students with special educational needs
  • ✅ Personalizing the learning experience
  • ✅ Adapting to different cognitive styles
  • ✅ Complete educational inclusion

License

MIT © Santillana

Changelog

v0.3.0 (Current)

  • ✨ Accessibility options with 9 predefined profiles
  • ✨ Custom accessibility configuration
  • 📝 Complete documentation in English
  • 🔧 SDK structure improvements

v0.2.3

  • ✨ Free sessions without activities
  • ✨ Socratic method and Bloom's taxonomy configuration
  • 🎯 Customizable topics and objectives

v0.2.0

  • 🚀 Initial SDK release
  • 📚 Activity and exercise management
  • 💬 AI tutor chat system

Summary

Santillana AI Tutor API: Unified API Gateway for Santillana AI Tutor - Combines all microservices

Table of Contents

SDK Installation

The SDK can be installed with either npm, pnpm, bun or yarn package managers.

NPM

npm add @santillana-ai/typescript-tutor-sdk

PNPM

pnpm add @santillana-ai/typescript-tutor-sdk

Bun

bun add @santillana-ai/typescript-tutor-sdk

Yarn

yarn add @santillana-ai/typescript-tutor-sdk

[!NOTE] This package is published with CommonJS and ES Modules (ESM) support.

Requirements

For supported JavaScript runtimes, please consult RUNTIMES.md.

SDK Example Usage

Example

import { SDK } from "@santillana-ai/typescript-tutor-sdk";

const sdk = new SDK({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.activities.listActivities();

  console.log(result);
}

run();

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

| Name | Type | Scheme | | -------- | ------ | ------- | | apiKey | apiKey | API key |

To authenticate with the API the apiKey parameter must be set when initializing the SDK client instance. For example:

import { SDK } from "@santillana-ai/typescript-tutor-sdk";

const sdk = new SDK({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.activities.listActivities();

  console.log(result);
}

run();

Available Resources and Operations

activities

metrics

sessions

tools

users

Standalone functions

All the methods listed above are available as standalone functions. These functions are ideal for use in applications running in the browser, serverless runtimes or other environments where application bundle size is a primary concern. When using a bundler to build your application, all unused functionality will be either excluded from the final bundle or tree-shaken away.

To read more about standalone functions, check FUNCTIONS.md.

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:

import { SDK } from "@santillana-ai/typescript-tutor-sdk";

const sdk = new SDK({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.activities.listActivities({
    retries: {
      strategy: "backoff",
      backoff: {
        initialInterval: 1,
        maxInterval: 50,
        exponent: 1.1,
        maxElapsedTime: 100,
      },
      retryConnectionErrors: false,
    },
  });

  console.log(result);
}

run();

If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:

import { SDK } from "@santillana-ai/typescript-tutor-sdk";

const sdk = new SDK({
  retryConfig: {
    strategy: "backoff",
    backoff: {
      initialInterval: 1,
      maxInterval: 50,
      exponent: 1.1,
      maxElapsedTime: 100,
    },
    retryConnectionErrors: false,
  },
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.activities.listActivities();

  console.log(result);
}

run();

Error Handling

SDKError is the base class for all HTTP error responses. It has the following properties:

| Property | Type | Description | | ------------------- | ---------- | ------------------------------------------------------ | | error.message | string | Error message | | error.statusCode | number | HTTP response status code eg 404 | | error.headers | Headers | HTTP response headers | | error.body | string | HTTP body. Can be empty string if no body is returned. | | error.rawResponse | Response | Raw HTTP response |

Example

import { SDK } from "@santillana-ai/typescript-tutor-sdk";
import * as errors from "@santillana-ai/typescript-tutor-sdk/models/errors";

const sdk = new SDK({
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  try {
    const result = await sdk.activities.listActivities();

    console.log(result);
  } catch (error) {
    if (error instanceof errors.SDKError) {
      console.log(error.message);
      console.log(error.statusCode);
      console.log(error.body);
      console.log(error.headers);
    }
  }
}

run();

Error Classes

Primary error:

  • SDKError: The base class for HTTP error responses.

Network errors:

Inherit from SDKError:

  • ResponseValidationError: Type mismatch between the data returned from the server and the structure expected by the SDK. See error.rawValue for the raw value and error.pretty() for a nicely formatted multi-line string.

Server Selection

Select Server by Index

You can override the default server globally by passing a server index to the serverIdx: number optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

| # | Server | Variables | Description | | --- | ----------------------------------------------------------------------------- | ------------- | ------------------------ | | 0 | https://dx14o9a9s8.execute-api.us-east-1.amazonaws.com/{environment}/api/v1 | environment | AWS Lambda API Gateway | | 1 | http://localhost:3000/api/v1 | | Local Development Server |

If the selected server has variables, you may override its default values through the additional parameters made available in the SDK constructor:

| Variable | Parameter | Supported Values | Default | Description | | ------------- | --------------------------------------- | ---------------------------------- | ----------- | ---------------------------------------------- | | environment | environment: models.ServerEnvironment | - "staging"- "production" | "staging" | Deployment environment (staging or production) |

Example

import { SDK } from "@santillana-ai/typescript-tutor-sdk";

const sdk = new SDK({
  environment: "production",
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.activities.listActivities();

  console.log(result);
}

run();

Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the serverURL: string optional parameter when initializing the SDK client instance. For example:

import { SDK } from "@santillana-ai/typescript-tutor-sdk";

const sdk = new SDK({
  serverURL: "http://localhost:3000/api/v1",
  apiKey: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await sdk.activities.listActivities();

  console.log(result);
}

run();

Custom HTTP Client

The TypeScript SDK makes API calls using an HTTPClient that wraps the native Fetch API. This client is a thin wrapper around fetch and provides the ability to attach hooks around the request lifecycle that can be used to modify the request or handle errors and response.

The HTTPClient constructor takes an optional fetcher argument that can be used to integrate a third-party HTTP client or when writing tests to mock out the HTTP client and feed in fixtures.

The following example shows how to use the "beforeRequest" hook to to add a custom header and a timeout to requests and how to use the "requestError" hook to log errors:

import { SDK } from "@santillana-ai/typescript-tutor-sdk";
import { HTTPClient } from "@santillana-ai/typescript-tutor-sdk/lib/http";

const httpClient = new HTTPClient({
  // fetcher takes a function that has the same signature as native `fetch`.
  fetcher: (request) => {
    return fetch(request);
  }
});

httpClient.addHook("beforeRequest", (request) => {
  const nextRequest = new Request(request, {
    signal: request.signal || AbortSignal.timeout(5000)
  });

  nextRequest.headers.set("x-custom-header", "custom value");

  return nextRequest;
});

httpClient.addHook("requestError", (error, request) => {
  console.group("Request Error");
  console.log("Reason:", `${error}`);
  console.log("Endpoint:", `${request.method} ${request.url}`);
  console.groupEnd();
});

const sdk = new SDK({ httpClient: httpClient });

Debugging

You can setup your SDK to emit debug logs for SDK requests and responses.

You can pass a logger that matches console's interface as an SDK option.

[!WARNING] Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.

import { SDK } from "@santillana-ai/typescript-tutor-sdk";

const sdk = new SDK({ debugLogger: console });