Skip to content
Souloss
Go back

AI Chat Configuration Guide

Complete guide to configuring astro-minimax AI chat: providers, RAG search, Mock mode, author profiles, and quality evaluation.

astro-minimax includes a built-in AI chat assistant with multi-provider failover, RAG retrieval, streaming responses, and Mock fallback. This guide covers the complete setup.

Quick Setup

1. Enable AI

In src/config.ts:

ai: {
  enabled: true,
  mockMode: false,
  apiEndpoint: "/api/chat",
},
typescript

2. Configure Provider

In .env:

AI_BASE_URL=https://api.openai.com/v1
AI_API_KEY=your-api-key
AI_MODEL=gpt-4o-mini
SITE_AUTHOR=YourName
SITE_URL=https://your-blog.com
bash

3. Build AI Data

astro-minimax ai process       # Generate summaries + SEO data
astro-minimax profile build     # Build author profile
bash

4. Start Dev Server

pnpm run dev
bash

Provider Configuration

Cloudflare Workers AI

Free AI with Cloudflare Pages deployment:

# wrangler.toml
[ai]
binding = "AI"
toml

OpenAI Compatible API

AI_BASE_URL=https://api.openai.com/v1
AI_API_KEY=sk-xxx
AI_MODEL=gpt-4o-mini
bash

Failover Chain

flowchart LR
    Request[User Request] --> W{Workers AI}
    W -->|Success| Response[Streaming Response]
    W -->|3 failures| O{OpenAI API}
    O -->|Success| Response
    O -->|Fail| M[Mock Fallback]
    M --> Response

    style W fill:#f97316,color:#fff
    style O fill:#3b82f6,color:#fff
    style M fill:#6b7280,color:#fff
    style Response fill:#22c55e,color:#fff

Security Features

Quality Evaluation

pnpm run ai:eval                             # Test local
pnpm run ai:eval -- --url=https://your.com   # Test production
bash

Edit datas/eval/gold-set.json to customize test cases.

Environment Variables

VariableDescriptionRequired
AI_BASE_URLOpenAI-compatible API URLFor OpenAI
AI_API_KEYAPI keyFor OpenAI
AI_MODELChat modelNo (default: gpt-4o-mini)
SITE_AUTHORAuthor nameNo
SITE_URLSite URLNo


Previous Post
2026 Tech Blog Ecosystem: A Complete Guide to Building Your Own
Next Post
CLI Tools Guide

评论区

文明评论,共建和谐社区