Pollinations开源免费的AIGC服务

Pollinations简介

Pollinations.AI 是一家总部位于柏林的开源 AI 初创公司,提供最易用的免费文本和图像生成 API,无需注册或 API 密钥。

优势

  • 不需要注册
  • 国内可用
  • 免费开源
  • 支持web和API接口调用

Pollinations主要特点

  • 🔓 100% 开源
  • 🆓 免费使用
  • 🔒 简单和隐私:无需登录,无需密钥,无数据存储
  • 🖼️ 像普通图像或文本一样嵌入
  • 🌍 超过 50,000 名活跃用户,每月生成超过 2000 万张图像
  • 🤝 被各种开源 LLM、机器人和社区使用
  • 🎣 易于使用的 React Hooks(React Hooks 示例)
  • 🤖 自主开发:通过 GitHub 问题,由我们的 MentatBot 编码助手实现的功能

Pollinations官网

官网地址:pollinations.ai/

Github地址:github.com/pollination...

Pollinations核心功能

Pollinations提供了 图像生成、文本生成、文生音频、音频转文字、Vision视觉 等功能:

  • 图像生成:基于文本描述的图像生成服务
  • 文本生成:基于提示词生成自然语言文本
  • 文生音频 :文本生成音频文件
  • 音频转文字:将音频文件转为文本
  • Vision视觉:支持图片内容解析

图像生成

Pollinations.ai 提供基于文本描述的图像生成服务,用户可以通过 API 生成高分辨率图像。支持的模型包括 flux 和 turbo,用户还可以自定义图像尺寸、随机种子等参数。

Web端

web端没有API接口响应快

图像生成官网地址:pollinations.ai/

图像生成模型列表:image.pollinations.ai/models

进入首页,切换到【尝试】

输入下面提示词,【Model】选择【TURBO】,点击【想象】

vbnet 复制代码
An old wizard with a long white beard, wearing a classic pointed wizard hat, sits comfortably in a wooden chair on top of his stone wizard tower. He leisurely smokes a pipe, with magical smoke swirling in the air around him, creating faint glowing shapes. The tower's top is high above the clouds, and a vast sky stretches out in the background, giving the scene a tranquil, isolated vibe. At the top of the image, large whimsical text reads: 'I'm done procrastinating!' Further down, near the bottom-middle of the image, text in a similar whimsical style reads: 'I'm straight up not working anymore!' The text is a key focal point, blending humorously into the laid-back, magical atmosphere. aidmaMJ6.1, hkmagic.

API调用

官方文档:github.com/pollination...

根据官方文档我们可以使用以下 URL 可以直接生成图像:

arduino 复制代码
GET https://image.pollinations.ai/prompt/{prompt}

Image Generation API 提供了很多可选参数:

  • prompt(必需):要生成的图像的文本描述,需要进行URL编码
  • model:用于生成的模型,目前只有flux和turbo
  • seed:随机种子,用于保证图像的相识度
  • width:生成的图片的宽度,默认值:1024
  • height:生成的 image 的高度,默认值:1024
  • nologo:是否带水印,设置为true以关闭徽标的渲染,默认值:false
  • private:私有化,设置为true以防止图像显示在公共源中。默认值:false
  • enhance:增强效果,设置为true可打开提示增强(通过提示添加LLM详细信息),默认值:false
  • safe:非工作场合限制,设置为true以启用严格的 NSFW 内容过滤,如果检测到 NSFW 内容,则会引发错误。默认值:false

生成的图片格式通常为 JPEG 或 PNG

perl 复制代码
# 编码前
https://image.pollinations.ai/prompt/A beautiful sunset over the ocean?width=1280&height=720&seed=42
# 编码后
https://image.pollinations.ai/prompt/A%20beautiful%20sunset%20over%20the%20ocean?width=1280&height=720&seed=42

效果如下:

使用代码调用

python 复制代码
import requestsdef download_image(prompt, width=768, height=768, model='flux', seed=None):
    url = f"https://image.pollinations.ai/prompt/{prompt}?width={width}&height={height}&model={model}&seed={seed}"response = requests.get(url)
    with open('generated_image.jpg', 'wb') as file:
        file.write(response.content)
    print('Image downloaded!')
download_image("A beautiful sunset over the ocean", width=1280, height=720, model='flux', seed=42)

文本生成

Pollinations.ai 支持文本生成功能,用户可以通过 API 生成自然语言文本。

Web端

文本生成官网地址:sur.pollinations.ai/

文本生成模型列表:text.pollinations.ai/models

整体页面偏80年代魂斗罗游戏风格😃

点击顶部【Model】可以进行模型切换

选择完模型就可以进行聊天了,Claude模型本人尝试报错

API调用

官方文档:github.com/pollination...

Get方式

根据官方文档我们可以使用以下 URL 可以直接生成文本:

vbnet 复制代码
GET https://text.pollinations.ai/{prompt}

Text Generation API提供了很多可选参数:

  • prompt(必需):要生成的图像的文本描述,需要进行URL编码
  • model:用于生成的模型,如openai、mistral等
  • seed:随机种子
  • json:设置为true以接收 JSON 格式的响应
  • system:用于设置 AI 行为的系统提示符,需要进行 URL 编码
  • private:私有化,设置为true以防止图像显示在公共源中。默认值:false
perl 复制代码
# 编码前
https://text.pollinations.ai/北京今天天气
# 编码后
https://text.pollinations.ai/%E5%8C%97%E4%BA%AC%E4%BB%8A%E5%A4%A9%E5%A4%A9%E6%B0%94

POST方式

文本生成也支持POST请求方式

bash 复制代码
POST https://text.pollinations.ai/
# 参数
{
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What is artificial intelligence?"}
  ],
  "model": "openai",
  "seed": 42,
  "private": true
}

使用示例如下:

python 复制代码
import requests
def generate_text():
    url = 'https://text.pollinations.ai/'
    headers = {
        'Content-Type': 'application/json',
    }
    data = {
        'messages': [
            {'role': 'system', 'content': 'You are a helpful assistant.'},
            {'role': 'user', 'content': 'What is artificial intelligence?'}
        ],
        # 'seed': 42,
        'model': 'mistral'
    }
    response = requests.post(url, headers=headers, json=data)
    if response.status_code == 200:
        print(response.text)
    else:
        print('Error:', response.status_code)
# 调用函数
generate_text()

OpenAI能力

Pollinations也可以直接使用openai格式进行调用

GET方式

根据官方文档我们可以使用以下 URL 可以直接使用OpenAI生成文本

vbnet 复制代码
GET https://text.pollinations.ai/openai/{prompt}

OpenAI API提供了很多可选参数:

  • prompt(必需):要生成的图像的文本描述,需要进行URL编码
  • model:用于生成的模型,如openai、mistral等
  • seed:随机种子
  • json:设置为true以接收 JSON 格式的响应
  • system:用于设置 AI 行为的系统提示符,需要进行 URL 编码
  • private:私有化,设置为true以防止图像显示在公共源中。默认值:false
perl 复制代码
# 编码前
https://text.pollinations.ai/openai/9.9和9.11哪个大
# 编码后
https://text.pollinations.ai/openai/9.9%E5%92%8C9.11%E5%93%AA%E4%B8%AA%E5%A4%A7

POST方式

文本生成也支持POST请求方式

bash 复制代码
POST https://text.pollinations.ai/openai/
# 参数
{
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What is artificial intelligence?"}
  ],
  "model": "openai",
  "seed": 42,
  "private": true
}

使用示例如下:

css 复制代码
import requests
def generate_text():
    url = 'https://text.pollinations.ai/openai'
    headers = {
        'Content-Type': 'application/json',
    }
    data = {
        'messages': [
            {'role': 'system', 'content': 'You are a helpful assistant.'},
            {'role': 'user', 'content': 'What is artificial intelligence?'}
        ],
        # 'seed': 42,
        'model': 'mistral'
    }
    response = requests.post(url, headers=headers, json=data)
    if response.status_code == 200:
        print(response.json())
        return response.json()
    else:
        print('Error:', response.status_code)
# 调用函数
result = generate_text()
print(result['choices'][0]['message']['content'])

Vision视觉功能

之前应该只支持post方式

arduino 复制代码
POST https://text.pollinations.ai/openai

目前只有以下模型支持图像分析:

  • openai
  • openai-large
  • claude-hybridspace

messages支持如下消息类型:

  • text:文本类型
  • image_url:图像url
  • input_audio:音频base64格式
  • refusal:不了解
  • file:文件类型,需传递id

我们可以传递图片url或者 base64-encoded 数据,请求消息体如下:

json 复制代码
{
  "messages": [
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "What's in this image?"},
        {
          "type": "image_url",
          "image_url": {
            "url": "https://example.com/image.jpg"
          }
        }
      ]
    }
  ],
  "model": "openai"
}

{
  "messages": [
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "What's in this image?"},
        {
          "type": "input_audio",
          "input_audio": {
               "data": audio_base64,
               "format": "mp3"
          }
        }
      ]
    }
  ],
  "model": "openai"
}          
python 复制代码
import requests
def analyze_image(image_url):
    response = requests.post('https://text.pollinations.ai/openai', json={
        "messages": [
            {
                "role": "user",
                "content": [
                    {"type": "text", "text": "What's in this image?"},
                    {
                        "type": "image_url",
                        "image_url": {"url": image_url}
                    }
                ]
            }
        ],
        "model": "openai"
    })
    return response.json()
# Example usage
result = analyze_image("https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg")
print(result['choices'][0]['message']['content'])

音频生成

Pollinations.ai 还提供音频生成服务,用户可以通过文本生成音频文件。

官方文档:github.com/pollination...

Text-to-Speech文本转语音

文本转语言生成模型列表:text.pollinations.ai/models

根据官方文档我们可以使用以下 URL 可以直接将文本转为语音:

css 复制代码
GET https://text.pollinations.ai/{prompt}?model=openai-audio&voice=nova

Text-to-Speech API提供了很多可选参数:

  • prompt(必需):要生成的图像的文本描述,需要进行URL编码
  • model:用于生成的模型,必须设置为 openai-audio
  • voice(可选):用于音频生成的语音,选择voices中的模型,如alloy、echo、fable等,默认为alloy

返回格式:MP3

  • 格式的音频文件类型为 audio/mpeg
ini 复制代码
# 编码前
GET https://text.pollinations.ai/Welcome to Pollinations?model=openai-audio&voice=nova
# 编码后
GET https://text.pollinations.ai/Welcome%20to%20Pollinations?model=openai-audio&voice=nova

GET方式调用:

python 复制代码
import requests
import urllib.parse
def generate_audio():
    # 要转换为音频的文本
    text = "Welcome to Pollinations, where creativity blooms!"
    # 可选的语音参数
    voice = "nova"
    # 构造请求 URL
    url = f"https://text.pollinations.ai/{urllib.parse.quote(text)}?model=openai-audio&voice={voice}"
    
    # 发送 GET 请求
    response = requests.get(url)
    
    # 检查请求是否成功
    if response.status_code == 200:
        # 保存音频文件
        with open('generated_audio.mp3', 'wb') as f:
            f.write(response.content)
        print('Audio generated and saved!')
    else:
        print(f"Failed to generate audio. Status code: {response.status_code}")
        print(f"Response: {response.text}")
# 调用函数
generate_audio()

POST方式调用:

python 复制代码
def generate_audio():
    response = requests.post('https://text.pollinations.ai', json={
        "messages": [
            {
                "role": "user",
                "content": "Welcome to Pollinations, where creativity blooms!"
            }
        ],
        "voice": "nova",
        "model": "openai-audio"
    })
    # 检查请求是否成功
    if response.status_code == 200:
        # 保存音频文件
        with open('generated_audio2.mp3', 'wb') as f:
            f.write(response.content)
        print('Audio generated and saved!')
    else:
        print(f"Failed to generate audio. Status code: {response.status_code}")
        print(f"Response: {response.text}")
generate_audio()

Speech-to-Text语音转文本

语音转文本功能也可以通过 openai-audio 模型获得

python 复制代码
import base64
import requests
def analyze_image(audio_file_path):
    with open(audio_file_path, "rb") as audio_file:
        audio_data = audio_file.read()
        audio_base64 = base64.b64encode(audio_data).decode("utf-8")
        response = requests.post('https://text.pollinations.ai/openai', json={
            "messages": [
                {
                    "role": "user",
                    "content": [
                        {"type": "text", "text": "What's in this audio?"},
                        {
                            "type": "input_audio",
                            "input_audio": {
                                "data": audio_base64,
                                "format": "mp3"
                            }
                        }
                    ]
                }
            ],
            "model": "openai-audio"
        })
        print('RESULT ', response.json())
        return response.json()
# Example usage
result = analyze_image("./Welcome to Pollinations.mp3")

Pollinations SDK

Pollinations提供了Python版本的SDK接入方式

php 复制代码
$ pip install pollinations          
ini 复制代码
import pollinations as ai
model_obj = ai.Model()
image = model_obj.generate(
    prompt=f'A beautiful landscape {ai.realistic}',
    model=ai.flux,
    width=1024,
    height=1024,
    seed=42
)
image.save('image-output.jpg')
print(image.url)

Pollinations还提供了其他接入方式,需要的小伙伴可以到官网查

Pollinations.DIY

Pollinations推出的一个使用 Pollinations 服务构建的基于浏览器的开发环境,类似于v0.dev和bolt平台,可以在这里一句话生成应用、编辑、运行和调试,初步看该平台应该是基于bolt部署的。

官网地址:pollinations.diy/

模型选择

Pollinations.DIY提供了一系列模型可供选择

基本使用

Pollinations.DIY提供了文本对话、图片处理、语言输入、开发环境等功能

图片内容分析

开发环境是一个可实时提问、编辑、预览、下载代码和安装依赖的的环境

该平台偶尔会有问题,具体以实际为主

MentatBot

付费产品,新注册赠送3000额度

官网地址:mentat.ai/agents

MentatBot是一款自主 AI 编码助手,可直接从 GitHub 问题中实现新功能,感兴趣的小伙伴可以自行探索

友情提示

见原文:Pollinations开源免费的AIGC服务

本文同步自微信公众号 "程序员小溪" ,这里只是同步,想看及时消息请移步我的公众号,不定时更新我的学习经验。

相关推荐
魔珐科技4 分钟前
专访中兴通讯蒋军:AI数字人驱动企业培训,“内容生产”与“用户体验”双重提升
人工智能·aigc·ai数字人
小酒星小杜1 小时前
为了投入AI的怀抱,将Nextjs项目从Vercel迁移到了CF,结果是好的,过程是痛苦的
前端·aigc·next.js
Jokeny3 小时前
快速上手!FastGPT+Claude 一键生成小红书爆款图文,轻松吸粉10万+!
aigc
信鑫8 小时前
基于 MCP 的 AI Agent 应用开发实践
llm·aigc·mcp
Jokeny8 小时前
DeepSeek V3震撼登场!国产AI逆袭,全球第一梯队稳了!
aigc
AI技研社9 小时前
一文讲透、不再混淆 AI Function Call 和 MCP Server
aigc
Baihai_IDP10 小时前
图解「模型上下文协议(MCP)」:从与传统 API 的比较入手
人工智能·llm·aigc
charles_vaez10 小时前
开源模型应用落地-语音转文本-whisper模型-AIGC应用探索(五)
深度学习·whisper·aigc
敲上瘾11 小时前
定长内存池原理及实现
c++·缓存·aigc·池化技术
Donvink17 小时前
【Dive Into Stable Diffusion v3.5】2:Stable Diffusion v3.5原理介绍
人工智能·深度学习·语言模型·stable diffusion·aigc·transformer