AI Features Overview
Chat, image, and video generation powered by Volcano Engine.
Overview
NimBuild Starter integrates with Volcano Engine (ByteDance's Doubao API) for AI capabilities:
| Feature | Model | Endpoint |
|---|---|---|
| Chat | doubao-1-5-thinking-pro-250415 | /api/chat/stream |
| Image Generation | doubao-seededit-3-0-i2i-250628 | /api/image/generate |
| Video Generation | doubao-seedance-1-0-pro-250528 | /api/video/generate |
Configuration
All AI integrations require a Volcano Engine API key:
VOLCANO_ENGINE_API_KEY="your-api-key"
VOLCANO_ENGINE_API_URL="https://ark.cn-beijing.volces.com/api/v3"Architecture
The provider adapter lives in extensions/ai/volcano-engine/:
extensions/ai/volcano-engine/
├── config.ts # API configuration
├── chat.ts # Chat completion + streaming
├── image.ts # Image generation
├── video.ts # Video generation (async)
└── types.ts # TypeScript interfacesFeature-owned server workflows live in features/demo/server/. They validate inputs, deduct credits, call the provider adapter, persist chat or generation history through modules/db, and mirror generated media through extensions/storage/r2 when storage is configured.
Credit Integration
Every AI operation follows the deduct-first, refund-on-failure pattern:
- Check if user has enough credits
- Deduct credits from balance
- Call AI API
- If API fails, refund credits automatically
Replacing the AI Provider
To switch from Volcano Engine to OpenAI, Anthropic, or another provider:
- Add a new adapter under
extensions/ai/your-provider/ - Update the server workflows in
features/demo/server/ - Update environment variables
- Adjust model configuration
- Keep the same credit deduction and refund-on-failure pattern