A template for creating plugins using OpenAPI specifications.
# Install dependencies
pnpm install
# Start development server
pnpm devServer runs at http://localhost:3400
openapi/
├── api/
│ ├── gateway.ts # Plugin gateway
│ ├── greet.ts # Greet endpoint
│ └── calculate.ts # Calculate endpoint
├── public/
│ ├── manifest.json # Plugin manifest
│ └── openapi.json # OpenAPI specification
├── package.json
└── README.md
- The
openapi.jsondefines your API endpoints - Each endpoint in
pathsbecomes a callable function - The host reads the OpenAPI spec and creates Function Call definitions
- When AI calls a function, the request routes to your API endpoint
- Add the endpoint to
public/openapi.json:
{
"paths": {
"/api/new-endpoint": {
"post": {
"operationId": "newEndpoint",
"summary": "Description for AI",
"requestBody": { ... }
}
}
}
}- Create the handler in
api/new-endpoint.ts:
export default async function handler(req: Request) {
const body = await req.json();
// Your logic
return new Response(JSON.stringify(result));
}Test API directly:
curl -X POST http://localhost:3400/api/greet \
-H "Content-Type: application/json" \
-d '{"name": "World", "language": "es"}'# Deploy to Vercel
vercel --prodUpdate public/openapi.json servers URL:
{
"servers": [
{ "url": "https://your-plugin.vercel.app" }
]
}Remove gateway field from manifest for production.