# psopenai-hello.ps1
# Requires: Install-Module -Name PSOpenAI

# Load API key from .env (OPENAI_API_KEY=your-key)
$envPath = Join-Path $PSScriptRoot '.env'
Get-Content $envPath |
    Where-Object { $_ -match '^([^#=]+)=(.+)$' } |
    ForEach-Object {
        $k, $v = $_ -split '=', 2
        $v = $v.Trim().Trim('"')
        [Environment]::SetEnvironmentVariable(
            $k.Trim(), $v)
    }

Request-Response `
    -Model 'gpt-4.1-mini' `
    -SystemMessage 'You are a helpful assistant.' `
    -Message 'Why is the sky blue?' `
    -Stream | ForEach-Object { Write-Host $_ -NoNewline }
Write-Host
