text2img.js 793 B

1234567891011121314151617181920212223242526272829
  1. const config = require('../config');
  2. const PATH = 'images/generations';
  3. const TIMEOUT_MS = 180000;
  4. // 普通 AI 请求参数
  5. function getBody(prompt, outputPath) {
  6. return {
  7. model: 'dall-e-2',
  8. prompt,
  9. n: 1,
  10. size: '1024x1024',
  11. response_format: outputPath ? 'b64_json' : 'url'
  12. };
  13. }
  14. // 豆包文生图请求参数(优先用 DOUBAO_IMAGE_MODEL,未配置则用 DOUBAO_MODEL)
  15. function getDoubaoBody(prompt, outputPath) {
  16. const model = (config.DOUBAO_IMAGE_MODEL && config.DOUBAO_IMAGE_MODEL.trim()) ? config.DOUBAO_IMAGE_MODEL.trim() : config.DOUBAO_MODEL;
  17. return {
  18. model,
  19. prompt,
  20. n: 1,
  21. size: '1024x1024',
  22. response_format: outputPath ? 'b64_json' : 'url'
  23. };
  24. }
  25. module.exports = { path: PATH, getBody, getDoubaoBody, timeoutMs: TIMEOUT_MS };