微信扫码
与创始人交个朋友
我要投稿
“这几天各大自媒体都对ideogram2.0吹爆了,我试了一下,这个新的文生图模型质量确实不错,要说媲美midjourney,好像也差不多了。目前ideogram2.0官方是提供api接口的。所以我就基于官方的api弄了一个dify的自定义工具源码,希望对大家有帮助。”
ideogram2.0的api是需要去他们官网注册一个账户,然后绑定支付的卡。请注意,这里我需要提醒你,这个平台不是绑定一个卡就能用它的api了,而是绑定之后,它会从你的卡里先扣除40刀乐。然后你才能用它的api,我估摸着,它担心你白P不付款吧,哈哈。
好了,玩笑归玩笑,ideogram官方是有api的,开通了api服务之后,你才能设置apikey。其实这个是最重要的。
话不多说,直接放dify工具的源码吧:
{"openapi": "3.0.0","info": {"title": "ideogram文生图","description": "生成图像的API接口。微信公众号:提示日记","version": "1.0.0"},"tags": [],"paths": {"/generate": {"post": {"summary": "生成图像","operationId": "ideogram","deprecated": false,"description": "根据提供的提示生成图像。","tags": [],"parameters": [],"requestBody": {"required": true,"content": {"application/json": {"schema": {"type": "object","properties": {"prompt": {"type": "string","description": "生成图像的描述性提示词。","example": "A stunning cinematic-inspired photoshoot of a cosplayer dressed as Sailor Moon. She is standing on a rooftop, with a dramatic and moody skyline in the background."},"model": {"type": "string","enum": ["V_2","V_2_TURBO"],"description": "使用的模型版本。推荐填写:V_2或V_2_TURBO。如果不填,默认是V_2","example": "V_2"},"magic_prompt_option": {"type": "string","enum": ["AUTO", "ON","OFF"],"description": "是否启用魔法提示选项。可填写的参数有:AUTO、ON、OFF。这个功能是用来优化提示词的,一般对新手用户有点用,如非必要,填写为OFF就行","example": "OFF"},"aspect_ratio": {"type": "string","enum": ["ASPECT_16_9", "ASPECT_16_10","ASPECT_9_16","ASPECT_16_9","ASPECT_3_2","ASPECT_2_3","ASPECT_4_3", "ASPECT_3_4", "ASPECT_1_1", "ASPECT_1_3", "ASPECT_3_1"],"description": "生成图像的宽高比。仅支持填写的参数有:ASPECT_16_9 、 ASPECT_16_10 、ASPECT_9_16 、 ASPECT_16_9 、 ASPECT_3_2 、ASPECT_2_3 、 ASPECT_4_3 、 ASPECT_3_4 、 ASPECT_1_1 、 ASPECT_1_3 、ASPECT_3_1 ","example": "ASPECT_16_9"},"seed": {"type": "integer","description": "用于生成图像的种子值。0 ~ 2147483647之间任意整数都行","example": 116969},"style_type": {"type": "string","enum": ["GENERAL", "REALISTIC", "DESIGN", "ANIME", "RENDER_3D"],"description": "图像风格类型。只能填写这几个参数:GENERAL、REALISTIC、DESIGN、ANIME、RENDER_3D","example": "RENDER_3D"}},"required": ["prompt"]}}}},"responses": {"200": {"description": "成功生成图像","content": {"application/json": {"schema": {"type": "object","properties": {"url": {"type": "string","description": "生成图像的URL。","example": "https://ideogram.ai/api/images/direct/8YEpFzHuS-S6xXEGmCsf7g"}}}}}},"400": {"description": "错误请求 - 输入数据无效"},"401": {"description": "未授权 - 无效的API密钥"}},"security": [{"api_key": []}]}}},"components": {"securitySchemes": {"api_key": {"type": "apiKey","in": "header","name": "Api-Key"}}},"servers": [{"url": "https://api.ideogram.ai"}]}
以上是根据ideogram官方api文档改写成适配dify的swagger标准。
仅供参考哈,自行调试调试就行。
光复制上述的代码还不行,你需要在添加这个工具的时候,设置一下接口的apikey,如下所示:
在dify中添加了这个自定义工具之后,在工作流页面就可以使用了。如下所示
好了,至此,就代表整个工具全部可用了。
下面看看我用ideogram2.0画的图吧。ideogram2.0确实有点东西的。
已经可以根据提示词,直接出UI设计图了。
Web design draft of AIGC content and information platform:Home page banner part title: "Aitrainee | AI Trainee"Subtitle: "Embrace the AIGC era, become an innovative super-individual"Background: Full width image slider highlighting the transformative potential of AIGC in personal and professional development: "Join Us" buttonSections: Path of Self-Cultivation | Seek Like-Minded Souls Community | Cutting-Edge Technology Insights | User Success Stories | Latest AIGC Trends
53AI,企业落地应用大模型首选服务商
产品:大模型应用平台+智能体定制开发+落地咨询服务
承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2024-11-22
Dify 保姆级教程之:零代码打造个性化记忆助手
2024-11-22
Dify 保姆级教程之:零代码打造图像生成专家(上)
2024-11-22
Dify 保姆级教程之:零代码打造 AI 搜索引擎
2024-11-15
dify案例分享-基于jina和http实现36氪新闻热榜文章
2024-11-10
安装 Dify 并集成 Ollama 和 Xinference
2024-11-05
【附案例源码】把阿里云验证码短信接入到dify中
2024-11-05
Dify 中的 Bearer Token 与 API-Key 鉴权方式
2024-11-01
Gitee AI 入驻 Dify,成倍加速 AI 应用开发落地
2024-04-25
2024-04-24
2024-07-20
2024-05-08
2024-05-07
2024-07-16
2024-05-09
2024-06-21
2024-04-25
2024-07-08