PSAI
High-agency PowerShell AI framework for multi-agent orchestration and autonomous systems engineering
Ask AI about PSAI
Powered by Claude · Grounded in docs
I know everything about PSAI. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
• Documentation •
PSAI
PowerShell-Native AI Agents & Multi-Agent Orchestration
PSAI is a high-agency framework designed to bridge the gap between robust systems engineering and Large Language Models. Built for developers and architects, it transforms AI from a "chatbot" into a functional engineering component within your existing PowerShell ecosystem.
Leveraging multi-decade design patterns, PSAI provides the infrastructure to build, test, and deploy autonomous agents that interact directly with your console, file systems, and enterprise APIs.
Autonomous Agents
PSAI brings the power of autonomous agents to PowerShell, allowing you to seamlessly integrate AI capabilities into your scripts and terminal workflows. PSAI Agents enable you to build powerful, interactive tools that handle a variety of tasks, all powered by OpenAI's models. From quick calculations to detailed web searches, PSAI offers a flexible and intuitive way to create agents that can autonomously solve complex problems.
Think of PSAI Agents as digital Swiss Army knives—each agent is a specialized tool capable of running calculations, interacting with web services, fetching data, and executing multi-step tasks, all from within your PowerShell console.
Check out What Are Autonomous Agents in this README for more information.
Philosophy: Engineering over Prompting
PSAI embodies the principle of "be the automator, not the automated." Modern Agentic Workflows are the latest convergence of long-standing engineering disciplines—TDD, Design Patterns, and System Hooks. PSAI is built by an elite coder for elite coders, focusing on high-agency tools that understand the rigors of professional software development.
Technical Architecture
High-Agency Orchestration: Move beyond simple RAG or chat loops into autonomous multi-step task execution.
Extensible Tooling: Easily register PowerShell functions as "Tools" (Function Calling), allowing LLMs to interact with your local environment securely.
State & Memory Management: Engineered for complex, long-running conversations with rewind and list capabilities.
Provider Agnostic (via my psaisuite): Architected to work across OpenAI, Azure, and Anthropic Claude.
Installation
Install-Module -Name PSAI
After installing the module, you can start working with it by getting your OpenAI API key or Azure OpenAI secrets. Or both.
You can now use the Start-Conversation alias to quickly begin a chat session.
OpenAI API KEY
Get/Create your OpenAI API key from https://platform.openai.com/account/api-keys.
Then set $env:OpenAIKey to your key.
Azure OpenAI
After creating an Azure OpenAI resource, you can use the PSAI module to interact with it.
You need to get the following secrets from the Azure Portal and Azure AI Studio:
apiURIapiVersionapiKeydeploymentName- (Optional)
organizationId(if your Azure OpenAI resource requires theOpenAI-Organizationheader)
$secrets = @{
apiURI = "<Your Azure OpenAI API URI>"
apiKey = "<Your Azure OpenAI API Key>"
apiVersion = "<Your Azure OpenAI API Version>"
deploymentName = "<Your Azure OpenAI Deployment Name>"
organizationId = "<Your Organization ID>" # Optional
}
Set-OAIProvider AzureOpenAI
Set-AzOAISecrets @secrets
If your Azure OpenAI implementation requires the OpenAI-Organization header, provide the organizationId value. Otherwise, you can omit it.
Usage
The full set of functions can be found here https://github.com/dfinke/PSAI/wiki/
Invoke-OAIChat 'How do I output all files in a directory PowerShell?'
GPT Response
To output all files in a directory using PowerShell, you can use the Get-ChildItem cmdlet. Here's an example of how you can do it:
Get-ChildItem -Path "C:\Path\To\Directory" -File
Replace "C:\Path\To\Directory" with the path to the directory whose files you want to output. This command will list only files in the specified directory.
If you want to list all files, including files in subdirectories, you can add the -Recurse parameter to Get-ChildItem:
Get-ChildItem -Path "C:\Path\To\Directory" -File -Recurse
This command will recursively list all files in the specified directory and its subdirectories.
Run either of these commands in PowerShell to output all files in a directory.
What Are Autonomous Agents?
PSAI Agents combine the logic of PowerShell with the reasoning of LLMs. By implementing Model Context Protocol (MCP) style patterns and tool-calling, these agents can navigate codebases, perform data analysis, and execute multi-step workflows without constant human intervention.
Features of PSAI Agents
-
Customizable Agents: Create agents that use predefined tools or add custom ones. Easily expand agent capabilities by registering new tools tailored to specific needs.
-
Natural Language Interaction: Utilize OpenAI models to interpret complex prompts and provide contextual, intelligent responses using natural language.
Examples: What PSAI Agents Can Do
Below are a few examples that showcase PSAI's capabilities:
Basic Agent
Create a simple agent with instructions:
$SecretAgent = New-Agent -Instructions "Recipes should be under 5 ingredients"
$SecretAgent | Get-AgentResponse 'Share a breakfast recipe.'
Slash Commands
PSAI Agents now support slash commands in interactive sessions, allowing you to perform quick actions without leaving the conversation flow.
Available Commands
/clear: Clears the console screen, providing a clean slate for your interaction./rewind [n]: Rewinds the conversation to before the last n user messages, deleting the last n user inputs and all subsequent messages. If n is not specified, defaults to 1./listmsgs: Lists all user messages in the current conversation.
Usage
In an interactive agent session, simply type a slash command at the prompt:
/clear
This will execute the command immediately. Unknown commands will display an error message, and normal input continues the conversation with the agent.
Convert Your Repositories to AI-Ready Format
The ConvertTo-AIPrompt function packages any GitHub repository into an AI-optimized XML format, making it easy to feed your codebase to AI tools like ChatGPT, Claude, or Gemini.
Key Features
- AI-Optimized: Formats your codebase in a way that's easy for AI to understand and process.
- Simple to Use: You need just one command to pack your entire repository.
- Customizable: Easily configure what to include or exclude.
Basic Example
# Export a repository to a single file
ConvertTo-AIPrompt -RepoSlug "dfinke/ImportExcel" -OutputPath "D:\ImportExcel.txt"
# Include only specific file types
ConvertTo-AIPrompt -RepoSlug "dfinke/ImportExcel" -Include "*.ps1","*.md" -OutputPath "D:\ImportExcel-docs-and-code.txt"
# Exclude specific file types
# Look at a single directory in the repo
ConvertTo-AIPrompt -RepoSlug "dfinke/ImportExcel/Examples" -Exclude "*.xlsx" -OutputPath "D:\ImportExcel-examples.txt"
# Return as string instead of saving to file
$repoContent = ConvertTo-AIPrompt -RepoSlug "username/repo"
New Invoke-QuickPrompt feature
Invoke-QuickPrompt now supports two new parameters Tools and ShowToolCalls.
Pass in PowerShell functions, builtin or your own, to the Tools parameter. Use ShowToolCalls to see the tools used in the response to your prompts.
See it In Action
Future Roadmap
We are continuously evolving PSAI Agents to meet more diverse automation needs:
- More Tools: Including weather information, document parsing, and task automation features.
- Interactive Sessions: Richer CLI interactions for more dynamic agent conversations.
- Workflow Automation: Agents capable of multi-step workflows that integrate with existing scripts and systems.
Questions? Feedback?
For questions or feedback, open an issue on GitHub or reach out via Twitter or LinkedIn.
Happy Automating!
🤖 AI-Native Development This repository includes a CLAUDE.md file, optimized for use with Claude Code and other agentic developer environments.

