Skip to content

opuu/elysia-llms-txt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elysia LLMs TXT

An Elysia plugin that generates llms.txt documentation from OpenAPI/Swagger specifications. Transform your API specs into LLM-friendly documentation with automatic endpoint generation.

npm version License: MIT TypeScript Elysia

Why Elysia LLMs TXT?

Elysia LLMs TXT bridges the gap between your API documentation and AI consumption, making it perfect for:

  • LLM Integration: Generate AI-friendly documentation that large language models can easily parse
  • API Documentation: Convert OpenAPI/Swagger specs into readable markdown format
  • Developer Experience: Provide /llms.txt endpoints for instant API documentation access
  • AI Training: Create structured documentation suitable for training AI models on your API
  • Documentation Automation: Automatically generate and serve API documentation without manual maintenance

Key Features

  • OpenAPI/Swagger Support: Works with both file-based and URL-based OpenAPI specifications
  • LLM-Optimized Output: Generates markdown documentation specifically formatted for AI consumption
  • Elysia Native: Built specifically for Elysia with TypeScript support
  • Flexible Configuration: Customizable headers, footers, and content types
  • Standard Endpoints: Provides /llms.txt and /llms-full.txt endpoints automatically
  • Zero Dependencies: Lightweight plugin with minimal overhead

Installation

npm install @opuu/elysia-llms-txt
pnpm add @opuu/elysia-llms-txt
yarn add @opuu/elysia-llms-txt
bun add @opuu/elysia-llms-txt

Quick Start

1. Basic Usage

import { Elysia } from "elysia";
import { llms } from "@opuu/elysia-llms-txt";

const app = new Elysia()
  .use(
    llms({
      source: {
        type: "url",
        url: "/swagger/json",
      },
    })
  )
  .listen(3000);

// Visit: http://localhost:3000/llms.txt

2. File-based Configuration

import { Elysia } from "elysia";
import { llms } from "@opuu/elysia-llms-txt";

const app = new Elysia()
  .use(
    llms({
      source: {
        type: "file",
        file: "./openapi.json",
      },
      header: "# My API Documentation",
      footer: "Generated for LLM consumption",
    })
  )
  .listen(3000);

3. Advanced Configuration

import { Elysia } from "elysia";
import { llms } from "@opuu/elysia-llms-txt";

const app = new Elysia()
  .use(
    llms({
      source: {
        type: "url",
        url: "https://petstore.swagger.io/v2/swagger.json",
      },
      header: `# Petstore API Documentation
    
This documentation is optimized for Large Language Models.`,
      footer: `
---
Last updated: ${new Date().toISOString()}
Generated by @opuu/elysia-llms-txt`,
      contentType: "text/markdown",
    })
  )
  .listen(3000);

API Reference

Configuration Options

The plugin accepts an LLMsOptions object with the following properties:

Option Type Description Default
source object Source configuration for OpenAPI spec Required
source.type "file" | "url" Whether to load from file or URL Required
source.file string File path (when type is "file") Optional
source.url string URL path (when type is "url") Optional
header string Optional header content Optional
footer string Optional footer content Optional
contentType "text/markdown" | "text/plain" Response content type "text/markdown"

Generated Endpoints

The plugin automatically adds these endpoints to your Elysia application:

  • GET /llms.txt - Returns the generated LLM documentation
  • GET /llms-full.txt - Redirects to /llms.txt (for compatibility)

Requirements

  • Node.js >= 18.0.0
  • Bun >= 1.0.0
  • Elysia >= 1.0.0

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

Elysia plugin to generate `llms.txt` from OpenAPI/Swagger

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published