Skip to content

Install

Before using this integration, you’ll need:

  1. Upstash Account: Sign up at upstash.com and create a Search Database
  2. OpenAI API Key: Get your API key from platform.openai.com

Create a .env file in your project root:

UPSTASH_SEARCH_REST_URL=your_upstash_rest_url
UPSTASH_SEARCH_REST_TOKEN=your_upstash_rest_token
OPENAI_API_KEY=your_openai_api_key

Install the integration automatically using the Astro CLI:

Terminal window
pnpm astro add astro-chatty-gpt
Terminal window
npx astro add astro-chatty-gpt
Terminal window
yarn astro add astro-chatty-gpt

Or install it manually:

  1. Install the required dependencies
Terminal window
pnpm add astro-chatty-gpt
Terminal window
npm install astro-chatty-gpt
Terminal window
yarn add astro-chatty-gpt
  1. Add the integration to your astro config
import AstroChattyGpt from "astro-chatty-gpt";
import { loadEnv } from "vite";
const env = loadEnv("", process.cwd(), "");
export default defineConfig({
integrations: [
AstroChattyGpt({
upstashUrl: env.UPSTASH_SEARCH_REST_URL!,
upstashToken: env.UPSTASH_SEARCH_REST_TOKEN!,
openAiKey: env.OPENAI_API_KEY!,
maxOutputTokens: 500,
excludeRoutes: ['admin/', 'private/'],
maxContextDocs: 10,
maxContentLength: 2000,
contentTag: 'main',
searchLimit: 10,
excludeTags: ['.sidebar', '.ads', '.navigation'],
botName: 'AstroChattyGpt',
systemPrompt: 'You are a helpful assistant for my website.',
}),
],
});