微信扫码
与创始人交个朋友
我要投稿
“这几天各大自媒体都对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+中大型企业
2025-01-13
前后端源码部署:Dify v0.15.0 升级 v1.0.0-beta.1 的尝试
2025-01-11
Dify v1.0.0-beta:插件开启公测
2025-01-07
Dify v0.15.0:全新父子检索策略 - 更精准,更全面的知识检索
2024-12-27
【场景驱动】企业的哪些重复性任务,最适合用Coze循环节点来解决?——慢慢学AI146
2024-12-24
Coze,Dify,FastGPT,哪个更强?全方位对比分析来了!
2024-12-19
打开日本市场背后,Dify 是怎么做 AI 全球化的?
2024-12-15
有了 NewAPI 之后,Dify 的可玩儿性又高了
2024-12-06
太强大了!Coze史诗级提升,零门槛做自己的AI产品!
2024-04-25
2024-04-24
2024-07-20
2024-07-16
2024-05-08
2024-05-07
2024-05-09
2024-06-21
2024-08-06
2024-04-25