Skip to content

Instantly share code, notes, and snippets.

@BananaAcid
Last active January 24, 2026 17:59
Show Gist options
  • Select an option

  • Save BananaAcid/6bc2fc33d948d28d255674a7613f120c to your computer and use it in GitHub Desktop.

Select an option

Save BananaAcid/6bc2fc33d948d28d255674a7613f120c to your computer and use it in GitHub Desktop.
Powershell -- ask PollinationsAI for an Image

Ask PollinationsAI for an Image

... in pure Powershell 5+ / 7+ (Win, Linux, OSX, Docker, ...) -- for free (registration, but no moneys)

  • You get 5k of image generations with z-image and others, when you register for free.

https://enter.pollinations.ai/

Warning

PollinationsAI will cache the response to your request indefinitely (possibly the request as well) and the response can be accessed without authentication.

This might be what you are looking for, if you want to get persistent results to a request or want to share the response (the URL visible with -Debug is without authentication).

DO NOT enter private data (name, address, ...), personal information, information about other people, financial data and other sensetive information. It is not save to use in a corporate environment. Handle it as if you would post on X / Facebook.

See Discussion

Usage

PollinationsAI-Img "a cat" -save
# C:\Users\<username>\AppData\Local\Temp\00974dda-c60c-4c4f-b6bc-4c6e948616d5.jpg
PollinationsAI-Img -?
PollinationsAI-Img [-content] <string> [-settings <hashtable>] [-model <string>] [-POLLINATIONSAI_API_KEY <string>] [-bypassCache]
PollinationsAI-Img [-content] <string> -details [-settings <hashtable>] [-model <string>] [-POLLINATIONSAI_API_KEY <string>] [-bypassCache]
PollinationsAI-Img [-content] <string> -save [-details] [-settings <hashtable>] [-model <string>] [-POLLINATIONSAI_API_KEY <string>] [-bypassCache]
PollinationsAI-Img [-content] <string> -out <string> [-details] [-settings <hashtable>] [-model <string>] [-POLLINATIONSAI_API_KEY <string>] [-bypassCache]
PollinationsAI-Img -listModels [-details]
PollinationsAI-Img -getSettingsDefault

Yes: Optional <CommonParameters> is always supported.

Quickly integrate it (install, update)

Note

➡️ Interchangeably use PollinationsAI-Img and .\ask.pollinations_image.ps1 in this documentation. Exact same params apply.

PollinationsAI-Img can be used globally, using the file itself works only where it is saved.

In your Powershell prompt, paste the following to download the comandlet into the Powershell profile folder and activate it:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://gist.githubusercontent.com/BananaAcid/6bc2fc33d948d28d255674a7613f120c/raw/integrate.ps1'))

Note: Non-Windows users will see, which has no effect: Set-ExecutionPolicy: Operation is not supported on this platform.

only download it into your current folder
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; Invoke-WebRequest 'https://gist.githubusercontent.com/BananaAcid/6bc2fc33d948d28d255674a7613f120c/raw/ask.pollinations_image.ps1' -out 'ask.pollinations_image.ps1';

You might want to add your key as environment variable to your profile

"`n`n`$env:POLLINATIONSAI_API_KEY = `"sk_..............`"" >> $PROFILE.CurrentUserAllHosts

... after restarting your powershell console, the key will be available.

Params

arg default example desc
<string>
or -content <string>
or -prompt <string>
(required) "Some Text-Prompt" The content to be created.
-model <string> "zimage" "flux" The model to use.
-POLLINATIONSAI_API_KEY <string>
or -key <string>
$env:POLLINATIONSAI_API_KEY sk_12345678901234567890 Use a PollonationsAI API Key - if left set to "", $env:POLLINATIONSAI_API_KEY is being checked. Note: Add the API key to your environment variables.
-settings <hashtable>
or -set <hashtable>
see below @{seed = 2147483647} A hashtable of settings passed to the Pollinations AI API.
-bypassCache
or -nocache
Only bypasses the cloudflare cache, and sets the seed to random, resulting in a newly generated response. Without, the first request will generate the result, each subsequent request will result in the cached response.
-out <string> acat.jpg The local path to save the generated image and returns the path.
-save Will save to the system temp folder and returns the path.
-details Does not save the image and returns @{ Headers; Content; Uri; [FilePath] } (FilePath only if -save or -out was used)
-getSettingsDefault
or -get
Get the default settings for the PollinationsAI API.
-listModels
or -list
Outputs a table of models, that are currently available on PollinationsAI.
-listModels -details
or -list -details
Outputs a Hashtable of models, to be used in code.
-debug Outputs the request URI. (This URI does not need authorisation, because it accesses the cached result)

Important

Returns:

  • Default: The generated image as a byte array
  • -details: The headers as and content @{ Headers; Content; Uri; [FilePath] } (FilePath only if -save or -out was used)
    • (HTTP-response Headers, Content of the answer, Uri of the cached request)
  • -save: The local path to generated file
  • -out <name.jpg>: The local path to generated file

⚠️ Because the comandlet returns the paths or data, you can use it within another script!

Caution

on error:

  • throws
    @{ StatusCode = <error code>; Message = <error message> }

Note

You can always shorten a param (to use -c or -con instead of -content)

Make it available to your shell as a function (if you did not do the "quickly integrate it") ... for local use

Function PollinationsAI-Img { & <absolutepath>\ask.pollinations_image.ps1 @args }

Doing this, you can use PollinationsAI-Img -listModels in any folder (while in the same session), instead of .\ask.pollinations_image.ps1 -listModels within the script folder only.

To make it always available in a powershell session, add it a file shown with $Profile | Select-Object * (CurrentUserAllHosts is a good place).

Examples

Generate an image based on the prompt "a cat"

PollinationsAI-Img "a cat" -save
# C:\Users\<username>\AppData\Local\Temp\00974dda-c60c-4c4f-b6bc-4c6e948616d5.jpg

Generate an image based on the prompt "a cat" and open it with your default image viewer

-Debug shows the used URL and the local file path of the generated image.

PollinationsAI-Img "a cat" -save -Debug | Invoke-Item
# DEBUG: URI: https://gen.pollinations.ai/image/a%20cat?model=zimage
# DEBUG: Filepath: C:\Users\<username>\AppData\Local\Temp\00974dda-c60c-4c4f-b6bc-4c6e948616d5.jpg

Generate an image based on the prompt "a cat" using the flux model and save it into the local folder as acat.jpg

PollinationsAI-Img -content "a cat" -model flux -out acat
# acat.jpg

if .jpg (or .png) is missing, it will be added (depending on the model).

Generate an Image and save it

$c = "England"; PollinationsAI-Img "for $c, show the country flag in 3D in the shape of that country with a slight shadow ### DO NOT SHOW ANY PEOPLE" -out .\country_$c
# country_England.jpg

Use different settings

PS> $env:POLLINATIONSAI_API_KEY = "sk_..."
PS> $s = PollinationsAI-Img -getSettingsDefault  # or: PollinationsAI-Img -get
PS> $s
        Name                           Value
        ----                           -----
        safe                           false
        image
        enhance                        false
        negative_prompt                worst quality, blurry
        transparent                    false
        quality                        medium
        width                          1024
        height                         1024
        seed                           0

PS> $s.width = 512
PS> $s.height = 512
PS> PollinationsAI-Img -content "a cat" -settings $s -out acat.jpg
  1. First set the API key,
  2. then get the default settings,
  3. then output the settings (just by typing $s),
  4. then modify them,
  5. then generate an image based on the prompt "a cat" using the modified settings.

Generate an image and save it inline in an html file

$result = PollinationsAI-Img "a cat"
$imgTag = "<center><img src=`"data:image/jpg;base64,{0}`" /></center>" -f [convert]::ToBase64String($result.Content)
$imgTag | Out-File -FilePath test-img.html -Encoding utf8
start test-img.html

Get a list of models and create an image with all of them

$models = PollinationsAI-Img -list -Details |% {$_.name}
$models |% { PollinationsAI-Img "a cat" -model $_ -out imgs\cat_$_.jpg }
# imgs\cat_kontext.jpg
# imgs\cat_turbo.jpg
# ...

Tint an image and set as wallpaper

  1. Get the Set-Wallpaper commandlet (choose the updated version) from here: https://www.joseespitia.com/2017/09/15/set-wallpaper-powershell-function/

    • save it as set-wallpaper.ps1
    • ⚠️ but DO NOT include the last line that says Set-WallPaper -Image "C:\Wallpaper\Background.jpg" -Style Fit
  2. Your script update.wallpaper.ps1

    • Prerequisites:
      • Function PollinationsAI-Img is set (see above), otherwise replace its occurence with .\ask.pollinations_image.ps1
      • $env:POLLINATIONSAI_API_KEY = "sk_..." is set
    param ([switch]$Test, [string]$Color)
    
    
    $colors = @("green", "blue", "black", "white", "orange", "purple")
    
    # $model = "seedream" # according to `.\ask.pollinations_image.ps1 -List` it supports image input. 1 Pollen == 33 images (0.03/image)
    $model = "klein-large" # .. is cheaper 0.012/image
    
    $color = $color ? $color : (Get-Random $colors)
    
    Write-Output "Setting wallpaper to $color"
    
    # Only generate if it does not exist, for speed (reduces unnecessary calls and the model takes its time)
    # You can add `width = "3440"; height = "1440";` or whatever you need, to the -Settings to force the output size
    if (-not (Test-path ".\wp_$color.jpg")) {
        Write-Output "Generating new image ..."
        # this might return a cached instance from PollinationsAI without any cost
        $newImage = PollinationsAI-Img `
            -Content "change the logo to be in $color with tint in $color" `
            -Settings @{ image = "https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg/960px-Wikipedia-logo-v2.svg.png"} `
            -Model $model `
            -Out ".\wp_$color.jpg"
    }
    else {
        $newImage = ".\wp_$color.jpg"
    }
    
    Write-Output "New image: $newImage"
    
    # if -Test was used, do not continue
    if ($Test) { return }
    
    # import the Set-Wallpaper function
    . .\set-wallpaper.ps1
    
    # set the new wallpaper
    Set-Wallpaper -Image $newImage -Style Center

    Logo Reference https://en.wikipedia.org/wiki/File:Wikipedia-logo-v2.svg

Note

You can test it with (without actually changing the wallpaper):

.\update.wallpaper.ps1 -Test
.\update.wallpaper.ps1 -Test -Color red 

And to test changing the wallpaper:

.\update.wallpaper.ps1            # random color
.\update.wallpaper.ps1 -Color red # specifically red color
  1. Use Windows Task Scheduler to set the script to be repeated and be started on system start ...

    example code to manually add it

    ⚠️ You need to change pwsh.exe into powershell.exe in the script, if you do not have Powershell 6+ installed.

    # Define the script path and name for the task
    $scriptPath = "C:\Scripts\update.wallpaper.ps1" # Replace with the actual path to your .ps1 file
    $taskName = "ChangeWallpaperHourlyAtLogon"
    $taskDescription = "Runs update.wallpaper.ps1 every hour after user login"
    
    # Define the action (start powershell.exe with arguments)
    $action = New-ScheduledTaskAction -Execute "pwsh.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File $scriptPath"
    
    # Define the trigger (at logon, repeating every hour indefinitely)
    # The -AtLogOn trigger doesn't directly support RepetitionInterval in one line
    # We must use a workaround by setting the Repetition properties after creating the task
    $trigger = New-ScheduledTaskTrigger -AtLogOn
    
    # Define the principal (runs as the current user when logged in)
    $principal = New-ScheduledTaskPrincipal -UserId "$env:USERDOMAIN\$env:USERNAME" -LogonType Interactive
    
    # Register the initial task (without the repetition settings configured directly)
    Register-ScheduledTask -TaskName $taskName -Description $taskDescription -Action $action -Trigger $trigger -Principal $principal -Force | Out-Null
    
    # Retrieve the newly created task object to modify its repetition settings
    $task = Get-ScheduledTask -TaskName $taskName
    
    # Set the repetition interval and duration
    $task.Triggers.Repetition.Interval = (New-TimeSpan -Hours 1)
    $task.Triggers.Repetition.Duration = ([System.TimeSpan]::MaxValue) # Indefinite duration
    
    # Update the task with the modified trigger settings
    $task | Set-ScheduledTask

License: MIT

# Nabil Redmann - 2026-01-24
# License: MIT
# https://gist.github.com/BananaAcid/6bc2fc33d948d28d255674a7613f120c
[CmdletBinding(DefaultParameterSetName="None")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingCmdletAliases', '', Scope = 'Function', Target = '*')]
<#
.SYNOPSIS
Generate an image using the Pollinations AI API.
.DESCRIPTION
Generate an image based on the given prompt using the Pollinations AI API.
.PARAMETER content
The prompt for the image.
.PARAMETER prompt
Alternative to content.
The prompt for the image.
.PARAMETER settings
A hashtable of settings passed to the Pollinations AI API.
.PARAMETER model
The model to use for image generation. Defaults to 'zimage'.
.PARAMETER POLLINATIONSAI_API_KEY
The API key to use for the Pollinations AI API.
.PARAMETER key
Alternative to POLLINATIONSAI_API_KEY.
The API key to use for the Pollinations AI API.
.PARAMETER bypassCache
Does bypasses the cloudflare cache, and sets the seed to random, resulting in a newly generated response.
.PARAMETER out
The local path to save the generated image.
.PARAMETER save
Will save to the system temp folder.
.PARAMETER details
Will return the details of the generated text (headers + content).
.PARAMETER getSettingsDefault
Get the default settings for the Pollinations AI API.
.PaRAMETER listModels
Get the list of available models for the Pollinations AI API.
.EXAMPLE
PS C:\> .\ask.pollinations_image.ps1 -listModels
PS C:\> .\ask.pollinations_image.ps1 -content "a cat" -model "flux" -save
List the available models, then generate an image based on the prompt "a cat" using the 'flux' model.
.EXAMPLE
PS C:\> $env:POLLINATIONSAI_API_KEY = "sk_..."
PS C:\> $s = .\ask.pollinations_image.ps1 -getSettingsDefault
PS C:\> $s
Name Value
---- -----
safe false
image
enhance false
negative_prompt worst quality, blurry
transparent false
quality medium
width 1024
height 1024
seed 0
PS C:\> $s.width = 512
PS C:\> $s.height = 512
PS C:\> .\ask.pollinations_image.ps1 -content "a cat" -settings $s -out acat.jpg
First set the API key, then get the default settings, then output the settings (just by typing $s), then modify them, then generate an image based on the prompt "a cat" using the modified settings.
.NOTES
Use -Debug to see the Write-Debug output
TEST with httpie:
https GET gen.pollinations.ai/image/a%20cat --verbose -A bearer -a sk_* model==zimage
.OUTPUTS
The generated image as a byte array
OR
content and headers as @{ Headers; Content; Uri } using: -details
OR
The local path to generated file using: -save
OR
The local path to generated file using: -out <name.jpg>
Error:
throws @{ StatusCode = <error code>; Message = <error message> }
#>
param (
[string]
[Parameter(Mandatory=$true, ParameterSetName='None', Position=0, HelpMessage="Prompt for the image")]
[Parameter(Mandatory=$true, ParameterSetName='WithOut', Position=0, HelpMessage="Prompt for the image")]
[Parameter(Mandatory=$true, ParameterSetName='WithSave', Position=0, HelpMessage="Prompt for the image")]
[Parameter(Mandatory=$true, ParameterSetName='WithDetails', Position=0, HelpMessage="Prompt for the image")]
[Alias("prompt")]
$content,
[hashtable]
[Parameter(Mandatory=$false, ParameterSetName='None', HelpMessage="A hashtable of settings passed to the Pollinations AI API, see https://enter.pollinations.ai/api/docs#tag/genpollinationsai/GET/image/{prompt}")]
[Parameter(Mandatory=$false, ParameterSetName='WithOut', HelpMessage="A hashtable of settings passed to the Pollinations AI API, see https://enter.pollinations.ai/api/docs#tag/genpollinationsai/GET/image/{prompt}")]
[Parameter(Mandatory=$false, ParameterSetName='WithSave', HelpMessage="A hashtable of settings passed to the Pollinations AI API, see https://enter.pollinations.ai/api/docs#tag/genpollinationsai/GET/image/{prompt}")]
[Parameter(Mandatory=$false, ParameterSetName='WithDetails', HelpMessage="A hashtable of settings passed to the Pollinations AI API, see https://enter.pollinations.ai/api/docs#tag/genpollinationsai/GET/image/{prompt}")]
$settings = @{},
[string]
[Parameter(Mandatory=$false, ParameterSetName='None', HelpMessage="The model to use for image generation. Defaults to 'zimage'. See https://enter.pollinations.ai/api/docs#tag/genpollinationsai/GET/image/{prompt}.query.model")]
[Parameter(Mandatory=$false, ParameterSetName='WithOut', HelpMessage="The model to use for image generation. Defaults to 'zimage'. See https://enter.pollinations.ai/api/docs#tag/genpollinationsai/GET/image/{prompt}.query.model")]
[Parameter(Mandatory=$false, ParameterSetName='WithSave', HelpMessage="The model to use for image generation. Defaults to 'zimage'. See https://enter.pollinations.ai/api/docs#tag/genpollinationsai/GET/image/{prompt}.query.model")]
[Parameter(Mandatory=$false, ParameterSetName='WithDetails', HelpMessage="The model to use for image generation. Defaults to 'zimage'. See https://enter.pollinations.ai/api/docs#tag/genpollinationsai/GET/image/{prompt}.query.model")]
$model = "zimage",
[string]
[Parameter(Mandatory=$false, ParameterSetName='None')]
[Parameter(Mandatory=$false, ParameterSetName='WithOut')]
[Parameter(Mandatory=$false, ParameterSetName='WithSave')]
[Parameter(Mandatory=$false, ParameterSetName='WithDetails')]
[Alias("key")]
$POLLINATIONSAI_API_KEY = $env:POLLINATIONSAI_API_KEY,
[switch]
[Parameter(Mandatory=$false, ParameterSetName='None')]
[Parameter(Mandatory=$false, ParameterSetName='WithOut')]
[Parameter(Mandatory=$false, ParameterSetName='WithSave')]
[Parameter(Mandatory=$false, ParameterSetName='WithDetails')]
[Alias("nocache")]
$bypassCache = $false, # does bypasses the cloudflare cache, and sets the seed to random, resulting in a newly generated response.
[string]
[Parameter(Mandatory=$true, ParameterSetName='WithOut')]
$out = "",
[switch]
[Parameter(Mandatory=$true, ParameterSetName='WithSave')]
$save = $false, # save a file with `-out <name.jpg>` or `-save` to save it with a provided name to the sys temp
[switch]
[Parameter(Mandatory=$true, ParameterSetName='WithDetails')]
[Parameter(Mandatory=$false, ParameterSetName='WithOut')]
[Parameter(Mandatory=$false, ParameterSetName='WithSave')]
[Parameter(Mandatory=$false, ParameterSetName='GetModelsList')]
$details = $false,
# stand alone
[switch]
[Parameter(Mandatory=$true, ParameterSetName='GetSettingsDefault')]
$getSettingsDefault = $false,
# stand alone
[switch]
[Parameter(Mandatory=$true, ParameterSetName='GetModelsList')]
$listModels = $false
)
# ---------------------------------------------------------------
<#
.LINK
https://enter.pollinations.ai/api/docs#tag/genpollinationsai/GET/image/{prompt}
#>
$defaultSettingsByApi = @{
width = 1024 # models have different min and max (1024 should always work)
height = 1024
seed = 0 # -1 == random, min 0, max 2147483647
enhance = "false"
negative_prompt = "worst quality, blurry"
safe = "false"
quality = "medium" # gptimage only
image = "" # Reference image URL(s). Comma/pipe separated for multiple.
transparent = "false" # gptimage only
# video models
duration = "" # video models only, veo: 4, 6, or 8. seedance: 2-10
aspectRatio = "" # video models only, veo, seedance: 16:9 or 9:16
audio = "false" # veo only
}
if ($getSettingsDefault) {
return $defaultSettingsByApi
}
if ($listModels -eq $true) {
$response = Invoke-WebRequest -Uri "https://gen.pollinations.ai/image/models" -Method Get -UseBasicParsing
$list = $response.content | ConvertFrom-Json |? {$_.output_modalities -Contains "image"}
if ($details) {
return $list
}
else {
return $list | Format-Table
}
}
# ---------------------------------------------------------------
if (-not $POLLINATIONSAI_API_KEY) { throw "⚠️ POLLINATIONSAI API KEY is missing! (-key or -POLLINATIONSAI_API_KEY or set `$env:POLLINATIONSAI_API_KEY=`"sk_...`")" }
# ---------------------------------------------------------------
#* we do not merge the defaults into this settings object by default, because the generated URL query would be longer then necessary
$querySettings = @{
"model" = if (-not $model) { "zimage" } else { $model }
} + $settings
# bypasses cloudflare cache
if ($bypassCache) {
$querySettings["cacheBuster"] = [string](Get-Date).Ticks + (Get-Random)
$querySettings["seed"] = -1
}
$headers = @{
"Authorization" = "Bearer $POLLINATIONSAI_API_KEY"
}
$baseUrl= "https://gen.pollinations.ai/image"
# stringify query and convert prompt
$queryStr = ($querySettings.GetEnumerator() |% { [uri]::EscapeDataString($_.Key) + "=" + [uri]::EscapeDataString($_.Value) } ) -join "&"
$promptSlug = [uri]::EscapeDataString($content)
# construct URI
$uri = "{0}/{1}?{2}" -f $baseUrl, $promptSlug, $queryStr
Write-Debug "URI: $uri"
# check for PowerShell 7+
$canSkip = (Get-Command Invoke-WebRequest).Parameters.ContainsKey('SkipHttpErrorCheck')
if ($canSkip) {
$response = Invoke-WebRequest -Uri $uri -Method Get -Headers $headers -UseBasicParsing -SkipHttpErrorCheck # get the error message in the response
}
else {
# Fallback for PowerShell 5.1 --> does only show the status code, since the response is dropped by Invoke-WebRequest
try {
$response = Invoke-WebRequest -Uri $uri -Method Get -Headers $headers -UseBasicParsing -ErrorAction Stop
}
catch {
$response = @{ StatusCode = $_.Exception.Response.StatusCode.Value__; Message = $_.Exception.Response.StatusCode }
}
}
# check for errors
if ($response.StatusCode -ne 200) {
$err = if ($response.content) {$response.content | ConvertFrom-Json |% { @{ StatusCode = $_.status; Message = $_.error.message} }} else { $response }
Write-Error $err
# set error code
$global:LASTEXITCODE = $response.StatusCode
throw [PSCustomObject]$err
}
elseif ($response.Headers["Content-Type"] -like "text/*" -or $response.Headers["Content-Type"] -like "application/*") {
Write-Error $response.Content
# set error code
$global:LASTEXITCODE = 200
throw [PSCustomObject]@{ StatusCode = $response.StatusCode; Message = $response.Content }
}
$ret = ""
# save the image
if ($out -ne "" -or $save -eq $true) {
if ($out -eq "") {
# filename from header, extract filename from within filename arg (might be empty and might have quotes or not)
# e.g. 'Content-Disposition' = 'attachment; filename="acat.jpg"' -> acat.jpg
$targetFilename = $response.Headers["Content-Disposition"] -split "filename=" | Select-Object -Last 1 |% { $_.Trim('"') }
if ($targetFilename -eq "") { $targetFilename = $response.Headers["X-Request-ID"].Trim() }
# dir is temp dir
$targetDir = [IO.Path]::GetTempPath()
$filepath = [IO.Path]::Combine($targetDir, $targetFilename)
}
else {
$filepath = [IO.Path]::Combine($PWD, $out)
}
# check .jpg and ignore case
if ($response.Headers["Content-Type"] -eq "image/jpeg" -and -not $filepath.EndsWith(".jpg", [System.StringComparison]::OrdinalIgnoreCase)) {
$filepath += ".jpg"
}
# png and others, like video
if ($Null -eq (Split-Path $filepath -Leaf).Split(".")[1]) { #PWSH 6+ "" -eq (Split-Path $filepath -Leaf | Split-Path -Extension)
$type = $response.Headers["Content-Type"] -split ";" | select -First 1 |% { $_ -split "/"} | Select-Object -Last 1
$filepath += "." + $type
}
Write-Debug "Filepath: $filepath"
# save the image
[IO.File]::WriteAllBytes($filepath, $response.Content)
$ret = $filepath
}
if ($details -eq $true) {
$ret = if ($ret) { @{ FilePath = $ret } } else { @{} } #filename available
$ret = $ret + @{
Headers = $response.Headers
Content = $response.Content
Uri = $uri
}
}
if ($ret) {
return $ret
}
else {
return $response.Content
}
<#
!== 200
Content-Type: application/json
{
"error": {
"code": "FORBIDDEN",
"message": "Model 'zimage' is not allowed for this API key",
"timestamp": "2026-01-15T16:57:43.416Z"
},
"status": 403,
"success": false
}
? 200 - positive result, uncached
NOTE:
header has Content-Type: image/jpeg
body is binary
HEADERS:
Key Value
--- -----
Date {Thu, 15 Jan 2026 21:08:56 GMT}
Transfer-Encoding {chunked}
Connection {keep-alive}
Server {cloudflare}
CF-Ray {9be859e129a87869-AMS}
CF-Cache-Status {DYNAMIC}
Access-Control-Allow-Origin {*}
Cache-Control {public, max-age=31536000, immutable}
Vary {Origin, Accept-Encoding}
Access-Control-Allow-Headers {Content-Type}
Access-Control-Allow-Methods {GET, POST, OPTIONS}
Access-Control-Expose-Headers {Content-Length,Content-Disposition}
X-Content-Type-Options {nosniff}
Access-Control-Allow-Credentials {true}
X-Cache {MISS}
x-model-used {zimage}
X-Request-ID {afdbbe82-4ed8-42b8-9d3a-60bd0bb158e6}
x-usage-completion-image-tokens {1}
x-usage-total-tokens {1}
Strict-Transport-Security {max-age=0; includeSubDomains; preload}
speculation-rules {"/cdn-cgi/speculation"}
Alt-Svc {h3=":443"}
Content-Type {image/jpeg}
Content-Disposition {inline; filename="acat.jpg"}
#>
<#
Download and integrate into Powershell Profile
#>
$p = $PROFILE.CurrentUserAllHosts
$path = $p | Split-Path -Parent
# create profile.ps1 if it is missing (linux, ...)
if (-not (Test-Path -Path $p -PathType Leaf)) {
New-Item -Path $p -ItemType File -Force | Out-Null
}
# download newset version of ask.pollinations_image.ps1
Invoke-WebRequest "https://gist.githubusercontent.com/BananaAcid/6bc2fc33d948d28d255674a7613f120c/raw/ask.pollinations_image.ps1" -OutFile "$path\ask.pollinations_image.ps1"
# add function to profile
$integrate = "`n`n# ask.pollinations_image.ps1`nFunction PollinationsAI-Img { `$p = `$PSScriptRoot; if (`$args -contains `"-?`") { `$x = & `$p\ask.pollinations_image.ps1 -?; `$x -replace `"ask.pollinations_image.ps1`", `"PollinationsAI-Img`"} else { & `$p\ask.pollinations_image.ps1 @args } }"
if ( $null -eq (Select-String -Path $p -Pattern "ask.pollinations_image.ps1") ) {
$integrate | Out-File -FilePath $p -Append
}
# active in current session
Remove-Item Function:PollinationsAI-Img -ErrorAction SilentlyContinue
Invoke-Expression $integrate.replace("`$PSScriptRoot", "`"$path`"")
Write-Output "🟢 Done, PollinationsAI-Img is now available.`n`n 💡 Run 'PollinationsAI-Img -List' to see available models.`n ⭐ Set `$env:POLLINATIONSAI_API_KEY to your API key, or use the -key param.`n 📄 Have a look at the documentation: https://gist.github.com/BananaAcid/6bc2fc33d948d28d255674a7613f120c`n`n ➡️ Try it out: 'PollinationsAI-Img `"a cat`" -save'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment