Skip to content

voytas75/PSAOAI

Repository files navigation

PowerShell Azure OpenAI (PSAOAI) Module

PowerShell 5.1+ PowerShell 7 PowerShell Gallery Version PowerShell Gallery Downloads Codacy Badge Module Version 0.6.5

PSAOAI

ko-fi

PSAOAI is a PowerShell module for working with Azure OpenAI from scripts, consoles, and automation workflows.

It gives you a PowerShell-native surface for chat completions, embeddings, image generation, and environment handling without forcing you to drop into raw REST calls every time.

It is most useful when you want a practical PowerShell wrapper around Azure OpenAI that is easy to install from PowerShell Gallery, script, and reuse across automation tasks.

PSAOAI

Who this is for

PSAOAI is a good fit for:

  • PowerShell users who want a reusable Azure OpenAI module instead of ad-hoc REST snippets
  • automation engineers who want repeatable prompt, embedding, or image-generation workflows
  • people building higher-level tools on top of a PowerShell-native OpenAI integration layer

PSAOAI is not the best fit for:

  • users who want a provider-agnostic framework first
  • people expecting a full desktop product rather than a scriptable module layer
  • cases where raw API experimentation is preferred over a PowerShell command surface

Quick start

1. Install the module

Install-Module -Name PSAOAI
Import-Module -Name PSAOAI

2. See what the module exports

Get-Command -Module PSAOAI

3. Configure Azure OpenAI

Set the environment values needed by your Azure OpenAI deployment:

  • PSAOAI_API_AZURE_OPENAI_ENDPOINT
  • PSAOAI_API_AZURE_OPENAI_APIVERSION
  • PSAOAI_API_AZURE_OPENAI_CC_DEPLOYMENT
  • PSAOAI_API_AZURE_OPENAI_KEY

4. Run a simple chat completion

"Explain Azure Logic App IF conditions in simple terms." |
  Invoke-PSAOAIChatCompletion -Deployment "your_deployment" -SimpleResponse -Stream $false

Supported scenarios

  • chat completions for scripted or interactive use
  • embeddings for search, similarity, or downstream automation
  • image generation through DALL-E 3
  • environment and key handling for repeated local usage
  • logging and reusable PowerShell-native integration in other tools

Known limitations

  • The module is primarily positioned around Azure OpenAI; it is not a broad multi-provider abstraction layer.
  • Real usability depends on correct local environment configuration and valid deployment settings.
  • The smoothest first-run path is a single verified Azure OpenAI deployment, not a complex multi-model setup.
  • This repo currently presents itself more as a practical module than as a heavily packaged developer platform.

Core capabilities

  • Chat completions for interactive or scripted Azure OpenAI calls, including o1 and o3-style usage.
  • Embeddings for similarity, retrieval, and downstream automation workflows.
  • Image generation through DALL-E 3.
  • Secure key and environment handling for repeated local usage.
  • Response logging for debugging, auditing, and operational review.
  • PowerShell-native commands that are easier to script and reuse than raw REST calls.

Usage examples

Chat completion

  • Basic o1-style usage

    "<describe reasoning problem>" | Invoke-PSAOAIChatCompletion -Deployment "model_o1" -o1
  • Structured non-streaming example

    "AZURE Logic App 'IF' element" | Invoke-PSAOAIChatCompletion -APIVersion "2024-05-01-preview" -Endpoint 
    "https://example.openai.azure.com" -Deployment "example_model_gpt35_!" -User "BobbyK" -Temperature 0.2 -TopP 0.7 
    -FrequencyPenalty 0 -PresencePenalty 0 -simpleresponse -SystemPrompt "Explain to me" -Stream $false -JSONMode
  • Capture a streamed response into a variable

    $resule = "AZURE Logic App 'IF' element" | Invoke-PSAOAIChatCompletion -APIVersion "2024-05-01-preview" -Endpoint 
    "https://example.openai.azure.com" -Deployment "example_model_gpt35_!" -User "BobbyK" -Temperature 0.2 -TopP 0.7 
    -FrequencyPenalty 0 -PresencePenalty 0 -simpleresponse -SystemPrompt "Explain to me" -Stream $true
  • o3-style usage

    Invoke-PSAOAIChatCompletion -Deployment "model_o3" -o3 -usermessage "Explain to me: $(Get-Content <plain_text_file_path> | out-string) `nReturn as Markdown format" -OneTimeUserPrompt

Completion

Invoke-PSAOAIcompletion -usermessage "explain winform" -Deployment "gpt45" -User "BobbyK" -simpleresponse -Stream $false

Image generation

Invoke-PSAOAIDalle3 -Prompt "A finely detailed, broken marble figure head half-submerged in sandy terrain. The scene is 
bathed in the illuminating glow of daylight. The artistic style of the image evokes the feel of Polish romanticism, 
characterized by a realistic approach with an underlying emotional dimension and emphasis on symbolic compositions often seen 
in Malczewski's works who was active before 1912. Please note, the marble figure head should be of no particular person, just 
a generic, anonymous sculpture." -quality hd 

Embeddings

$response = "Hello, World!" | Invoke-PSAOAIEmbedding -User "Gemini" -Verbose -Deployment "gpt-45" -simpleresponse
$response

Default log and data folder

If specific paths are not provided, PSAOAI uses:

  • <User's document folder>/PSAOAI/

That folder is used for logs and module data and is created automatically when the module is imported.

Versioning

We use SemVer for versioning.

Contributing

Contributions, issue reports, and improvement suggestions are welcome.

If you want to extend the module, start by reviewing the exported commands, current release notes, and the existing PowerShell module layout in this repo.

License

PSAOAI is released under the MIT License.

Contact

If you have questions, bug reports, or improvement ideas, use GitHub Issues.

About

PowerShell module for Azure OpenAI chat, embeddings, image generation, and automation workflows.

Resources

Stars

Watchers

Forks

Releases

Used by

Contributors

Languages