Skip to main content

AI API

The AI service provides LLM-powered scripture study tools — passage explanations, study question generation, and AI-inferred cross-references.

OpenAPI Spec Not Yet Created

This API reference will be auto-generated from services/ai/api/openapi.yaml using docusaurus-plugin-openapi-docs once the OpenAPI spec is created. The content below is a high-level summary.

What This API Covers

Passage Explanation

  • POST /api/v1/ai/explain — Generate a scholarly explanation of a scripture passage, grounded in original-language analysis and LDS theological context

Study Questions

  • POST /api/v1/ai/study-questions — Generate study questions for a passage, suitable for personal study or Come Follow Me discussion

Cross-Reference Discovery

  • POST /api/v1/ai/cross-references — Find AI-inferred connections between passages that go beyond the standard cross-reference system

Architecture Notes

  • Primary LLM: Anthropic Claude (via Anthropic SDK)
  • Fallback LLM: OpenAI (via OpenAI SDK)
  • Caching: Responses are cached in Redis using a prompt hash key with a 1-hour TTL
  • Prompt templates: Jinja2 .j2 files for consistent, versioned prompts

Authentication & Rate Limits

All AI endpoints are plan-gated — they require a valid subscription (Scholar or Academic tier). Free-tier users have limited access (5 requests/hour). Paid-tier users get 50 requests/hour.

See the API Overview for rate limit details.