generate-image
Create images from text prompts using HuggingFace's FLUX.1-schnell model. Specify inference steps and provide your HF_TOKEN to generate visual content.
Instructions
HuggingFace Inference API를 사용해 텍스트 프롬프트로 이미지를 생성합니다. (모델: black-forest-labs/FLUX.1-schnell, 환경변수 HF_TOKEN 필요)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | 이미지 생성 프롬프트 | |
| num_inference_steps | No | 추론 스텝 수 (기본값: 4, 범위: 1~10) |
Implementation Reference
- src/index.ts:579-623 (handler)The handler logic for the 'generate-image' tool, which uses HuggingFace Inference API to generate an image from a prompt.
async ({ prompt, num_inference_steps }) => { const token = process.env.HF_TOKEN if (!token) { return { content: [ { type: 'text' as const, text: 'HF_TOKEN 환경변수가 설정되지 않았습니다. Hugging Face 액세스 토큰을 HF_TOKEN 환경변수로 설정해주세요.' } ] } } try { const client = new InferenceClient(token) const imageBlob = await client.textToImage( { provider: 'together', model: 'black-forest-labs/FLUX.1-schnell', inputs: prompt, parameters: { num_inference_steps } }, { outputType: 'blob' } ) const base64 = await blobToBase64(imageBlob) return { content: [ { type: 'image' as const, data: base64, mimeType: 'image/png' } ] } } catch (error) { const message = error instanceof Error ? error.message : String(error) return { content: [ { type: 'text' as const, text: `이미지 생성 실패: ${message}` } ] - src/index.ts:567-577 (schema)Input schema definition for the 'generate-image' tool, including prompt and num_inference_steps.
inputSchema: z.object({ prompt: z.string().describe('이미지 생성 프롬프트'), num_inference_steps: z .number() .int() .min(1) .max(10) .optional() .default(4) .describe('추론 스텝 수 (기본값: 4, 범위: 1~10)') }) - src/index.ts:562-578 (registration)Registration of the 'generate-image' tool using server.registerTool.
server.registerTool( 'generate-image', { description: 'HuggingFace Inference API를 사용해 텍스트 프롬프트로 이미지를 생성합니다. (모델: black-forest-labs/FLUX.1-schnell, 환경변수 HF_TOKEN 필요)', inputSchema: z.object({ prompt: z.string().describe('이미지 생성 프롬프트'), num_inference_steps: z .number() .int() .min(1) .max(10) .optional() .default(4) .describe('추론 스텝 수 (기본값: 4, 범위: 1~10)') }) },