Skip to main content
Glama
156554395

Doubao Image/Video Generation MCP Server

by 156554395

generate_image

Generate images from text prompts, transform existing images with new descriptions, or blend multiple reference images using Doubao Seedream AI models.

Instructions

使用豆包 Seedream 模型生成图片

支持功能:

  • 文生图: 使用文本提示词生成图片

  • 图生图: 使用输入图片和提示词生成新图片

  • 多图融合: 使用多张参考图片融合生成新图片

参数说明:

  • prompt: 图片描述文本 (必需)

  • endpoint_id: 推理接入点 ID (推荐) 在火山引擎控制台创建推理接入点后获取的 Endpoint ID

  • model: 模型名称 (可选,默认: doubao-seedream-4-5)

    • doubao-seedream-4-5: 最新 4.0 模型,支持 4K 分辨率

    • doubao-seedream-3-0-t2i: 3.0 文生图模型 注意: 直接使用模型名称可能需要账户权限,推荐使用 endpoint_id

  • size: 图片尺寸 (可选,默认: 1024x1024) 支持的尺寸: 1024x1024, 1024x1792, 1024x768, 768x1024, 1792x1024, 512x512, 512x768, 768x512

  • image_url: 参考图片 URL (可选,用于图生图)

  • ref_image_urls: 多张参考图片 URL 数组 (可选,用于多图融合)

  • req_key: 请求标识 (可选,用于追踪)

重要提示: 如果遇到 InvalidEndpointOrModel.NotFound 错误,请在火山引擎控制台创建推理接入点,并使用 endpoint_id 参数

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
promptYes图片描述文本
endpoint_idNo推理接入点 ID (在火山引擎控制台创建)
modelNo模型选择,默认: doubao-seedream-4-5
sizeNo图片尺寸,默认: 1920x2160 (注意: 豆包 API 要求图片至少 3686400 像素)
image_urlNo参考图片 URL (图生图)
ref_image_urlsNo多张参考图片 URL 数组 (多图融合)
req_keyNo请求标识
watermarkNo是否添加水印,默认: false

Implementation Reference

  • The main handler function that executes the image generation logic by constructing the request to the Doubao API and handling the response.
    export async function generateImage( apiKey: string, options: GenerateImageOptions ): Promise<ImageGenerationResponse> { const { prompt, model, endpoint_id, size = "1920x2160", image_url, ref_image_urls, req_key, watermark = false, // 默认不加水印 } = options; // 优先使用 endpoint_id,如果没有则使用 model const modelOrEndpoint = endpoint_id || model || "doubao-seedream-4-5"; // 构建请求体 const requestBody: Record<string, any> = { model: modelOrEndpoint, prompt, size, watermark, // 添加水印参数 }; // 添加可选参数 if (image_url) { requestBody.image_url = image_url; } if (ref_image_urls && ref_image_urls.length > 0) { requestBody.ref_image_urls = ref_image_urls; } if (req_key) { requestBody.req_key = req_key; } try { const response = await fetch(`${BASE_URL}/images/generations`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify(requestBody), }); const result: ImageGenerationResponse = await response.json(); // 检查是否有错误 if (result.error) { throw new Error( `图片生成失败: ${result.error.message || "未知错误"}` ); } // 检查 HTTP 状态码 if (!response.ok) { throw new Error(`HTTP 错误: ${response.statusText}`); } return result; } catch (error) { throw new Error( `图片生成请求失败: ${error instanceof Error ? error.message : String(error)}` ); } }
  • TypeScript interface defining the input parameters for the generateImage handler.
    interface GenerateImageOptions { prompt: string; model?: string; size?: string; image_url?: string; ref_image_urls?: string[]; req_key?: string; endpoint_id?: string; // 推理接入点 ID watermark?: boolean; // 是否添加水印,默认 false }
  • MCP protocol inputSchema defining the parameters and validation for the generate_image tool.
    inputSchema: { type: "object", properties: { prompt: { type: "string", description: "图片描述文本", }, endpoint_id: { type: "string", description: "推理接入点 ID (在火山引擎控制台创建)", }, model: { type: "string", description: `模型选择,默认: ${DEFAULT_IMAGE_MODEL}`, enum: ["doubao-seedream-4-5", "doubao-seedream-3-0-t2i"], }, size: { type: "string", description: "图片尺寸,默认: 1920x2160 (注意: 豆包 API 要求图片至少 3686400 像素)", enum: [ "1920x2160", "1920x2560", "2160x3840", ], }, image_url: { type: "string", description: "参考图片 URL (图生图)", }, ref_image_urls: { type: "array", items: { type: "string" }, description: "多张参考图片 URL 数组 (多图融合)", }, req_key: { type: "string", description: "请求标识", }, watermark: { type: "boolean", description: "是否添加水印,默认: false", }, }, required: ["prompt"], },
  • src/index.ts:54-123 (registration)
    Registration of the generate_image tool in the ListToolsRequestHandler, including name, description, and schema.
    name: "generate_image", description: `使用豆包 Seedream 模型生成图片 支持功能: - 文生图: 使用文本提示词生成图片 - 图生图: 使用输入图片和提示词生成新图片 - 多图融合: 使用多张参考图片融合生成新图片 参数说明: - prompt: 图片描述文本 (必需) - endpoint_id: 推理接入点 ID (推荐) 在火山引擎控制台创建推理接入点后获取的 Endpoint ID - model: 模型名称 (可选,默认: ${DEFAULT_IMAGE_MODEL}) * doubao-seedream-4-5: 最新 4.0 模型,支持 4K 分辨率 * doubao-seedream-3-0-t2i: 3.0 文生图模型 注意: 直接使用模型名称可能需要账户权限,推荐使用 endpoint_id - size: 图片尺寸 (可选,默认: 1024x1024) 支持的尺寸: 1024x1024, 1024x1792, 1024x768, 768x1024, 1792x1024, 512x512, 512x768, 768x512 - image_url: 参考图片 URL (可选,用于图生图) - ref_image_urls: 多张参考图片 URL 数组 (可选,用于多图融合) - req_key: 请求标识 (可选,用于追踪) 重要提示: 如果遇到 InvalidEndpointOrModel.NotFound 错误,请在火山引擎控制台创建推理接入点,并使用 endpoint_id 参数`, inputSchema: { type: "object", properties: { prompt: { type: "string", description: "图片描述文本", }, endpoint_id: { type: "string", description: "推理接入点 ID (在火山引擎控制台创建)", }, model: { type: "string", description: `模型选择,默认: ${DEFAULT_IMAGE_MODEL}`, enum: ["doubao-seedream-4-5", "doubao-seedream-3-0-t2i"], }, size: { type: "string", description: "图片尺寸,默认: 1920x2160 (注意: 豆包 API 要求图片至少 3686400 像素)", enum: [ "1920x2160", "1920x2560", "2160x3840", ], }, image_url: { type: "string", description: "参考图片 URL (图生图)", }, ref_image_urls: { type: "array", items: { type: "string" }, description: "多张参考图片 URL 数组 (多图融合)", }, req_key: { type: "string", description: "请求标识", }, watermark: { type: "boolean", description: "是否添加水印,默认: false", }, }, required: ["prompt"], }, },
  • src/index.ts:240-255 (registration)
    Dispatch handler in CallToolRequestHandler that invokes the generateImage function for the generate_image tool.
    case "generate_image": { // 如果没有提供 endpoint_id 且环境变量中有,则使用环境变量的值 const imageArgs = { ...args }; if (!imageArgs.endpoint_id && DEFAULT_IMAGE_ENDPOINT_ID) { imageArgs.endpoint_id = DEFAULT_IMAGE_ENDPOINT_ID; } const result = await generateImage(API_KEY, imageArgs as any); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/156554395/doubao-image-video-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server