API Reference
Full API reference for geo-ai-core and geo-ai-next.
createGeoAI(config)
Creates a GeoAI instance. Accepts a GeoAIConfig object. Returns a GeoAI instance with methods for generating all GEO AI outputs.
typescript
import { createGeoAI } from 'geo-ai-core';
const geo = createGeoAI({
siteName: 'My Site',
siteUrl: 'https://example.com',
provider: { Pages: [{ title: 'Home', url: '/', description: 'Welcome' }] },
});GeoAI instance methods
| Method | Returns | Description |
|---|---|---|
| generateLlms(full) | Promise<string> | Generate llms.txt (false) or llms-full.txt (true) content |
| generateRobotsTxt() | string | Generate robots.txt block for all configured crawlers |
| generateMetaTags() | MetaTag[] | Generate meta tag objects for page head |
| generateLinkHeader() | string | Generate Link header value string |
| generateJsonLd() | object | object[] | Generate JSON-LD Schema.org object(s) |
generateLlms(full)
typescript
// llms.txt — concise index
const llmsTxt = await geo.generateLlms(false);
// llms-full.txt — extended with full content
const llmsFullTxt = await geo.generateLlms(true);generateMetaTags()
typescript
const tags = geo.generateMetaTags();
// Returns:
// [
// { name: 'llms', content: 'https://example.com/llms.txt' },
// { name: 'llms-full', content: 'https://example.com/llms-full.txt' },
// ]generateLlmsFiles(config)
From geo-ai-next. Writes llms.txt and llms-full.txt to the output directory. Used by the CLI and can be called directly in build scripts.
typescript
import { generateLlmsFiles } from 'geo-ai-next';
await generateLlmsFiles({
siteName: 'My Site',
siteUrl: 'https://example.com',
provider: new MyProvider(),
outDir: 'public', // default
crawlers: 'all',
});geoAIMiddleware(config)
From geo-ai-next. Returns a Next.js middleware function. Intercepts /llms.txt and /llms-full.txt requests and optionally injects the Link header on all responses.
typescript
import { geoAIMiddleware } from 'geo-ai-next';
export default geoAIMiddleware({
// All GeoAIConfig options +
cacheMaxAge: 3600, // Cache-Control max-age (seconds)
injectLinkHeader: true, // Inject Link header on all responses
});createLlmsHandler(config)
From geo-ai-next. Returns a { GET } object for use as an App Router route handler.
typescript
import { createLlmsHandler } from 'geo-ai-next';
export const { GET } = createLlmsHandler({
siteName: 'My Site',
siteUrl: 'https://example.com',
provider: new MyProvider(),
cacheMaxAge: 3600,
});AiGenerator
From geo-ai-core/ai. Generates AI-optimized descriptions via Claude or OpenAI.
typescript
import { AiGenerator } from 'geo-ai-core/ai';
const ai = new AiGenerator({
provider: 'anthropic' | 'openai',
apiKey: string,
model?: string,
promptTemplate?: string, // supports {title}, {content}, {type}, {price}, {category}
rateLimit?: number, // requests per minute, default 10
});
// Single generation
const description = await ai.generate({
title: string,
content?: string,
type?: string,
price?: string,
category?: string,
});
// Bulk generation
const results = await ai.bulkGenerate(items, {
batchSize?: number, // default 5
maxItems?: number, // default 50
onProgress?: (completed: number, total: number) => void,
});