本项目是一个图像生成服务器,借助API可实现图像的创建与编辑,为图像生成需求提供高效解决方案。
运行以下命令安装所需的依赖:
npm install
可以通过以下命令启动开发服务器:
npm run dev
或者构建生产版本后启动:
npm run build && npm start
项目的配置文件位于 config.json,以下是默认配置:
{
"port": 5050,
"openai_key": "your_openai_api_key",
"storage_path": "./storage"
}
| 属性 | 详情 |
|---|---|
| port | 服务监听的端口,默认为5050 |
| openai_key | OpenAI API密钥,用于图像生成 |
| storage_path | 图片存储路径 |
POST http://localhost:5050/api/create-image
Content-Type: application/json
{
"prompt": "描述图片的内容",
"filename": "图片文件名",
"width": 800,
"height": 600,
"background": "#ffffff"
}
POST http://localhost:5050/api/edit-image
Content-Type: application/json
{
"prompt": "编辑描述",
"filename": "existing-image.png",
"width": 1024,
"height": 768,
"background": "transparent"
}
DELETE http://localhost:5050/api/delete-image
Content-Type: application/json
{
"filename": "要删除的图片名"
}
docker build -t image-generator .
docker run -d --name image-server -e OPENAI_API_KEY="your_api_key" image-generator:latest
npm run dev
npm test
MIT License