PA
pAIrprogio/nestjs-gpt-action-api-template
Boilerplate project to quickly launch a NestJS powered API for ChatGPT GPT actions
NestJS GPT Action API Template
Installation
git clone https://github.com/pairprog/nestjs-gpt-action-template.git
cd nestjs-gpt-action-template
pnpm install
cp .env.example .envConfigure
- In package.json
> scripts > tunnel, changedomain_namewith yours - In .env
- Change
BASE_URLwith yours - (Not required) Set
SENTRY_DSNto enable Sentry error reporting
- Change
- In main.ts
- Set the
TitleandDescriptionof the API
- Set the
Run Locally
pnpm run tunnelAnd in another terminal window
pnpm run start:dev
# or
pnpm run start:debug- The OpenAPI schema's URL will be shown in the terminal window in blue.
- Copy it
- In "actions" section of your GPT app:
- Click "Create New Action"
- Click on "Import from URL"
- Paste the URL.
- Click "Import"
Add an action
- Look at wikipedia.controller.ts and wikipedia.dto.ts to see how to add a new action
Other
OpenAI specific headers
OpenAI provides identifying information with each query. You can access them in routes using the ChatGptHeaders decorator
@Post('/my/path')
function myPath(@ChatGptHeaders() headers: ChatGptHeaders) {
// ...
}On this page
Languages
TypeScript89.2%JavaScript10.8%
Contributors
Apache License 2.0
Created March 1, 2024
Updated March 5, 2025
