An Elysia plugin that generates llms.txt documentation from OpenAPI/Swagger specifications. Transform your API specs into LLM-friendly documentation with automatic endpoint generation.
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.txtendpoints 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
- 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.txtand/llms-full.txtendpoints automatically - Zero Dependencies: Lightweight plugin with minimal overhead
npm install @opuu/elysia-llms-txtpnpm add @opuu/elysia-llms-txtyarn add @opuu/elysia-llms-txtbun add @opuu/elysia-llms-txtimport { 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.txtimport { 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);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);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" |
The plugin automatically adds these endpoints to your Elysia application:
GET /llms.txt- Returns the generated LLM documentationGET /llms-full.txt- Redirects to/llms.txt(for compatibility)
- Node.js >= 18.0.0
- Bun >= 1.0.0
- Elysia >= 1.0.0
MIT License - see LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.