{"id":19954067,"url":"https://github.com/mkht/psopenai","last_synced_at":"2026-02-07T14:12:26.225Z","repository":{"id":154039430,"uuid":"611242867","full_name":"mkht/PSOpenAI","owner":"mkht","description":"PowerShell module for OpenAI API.","archived":false,"fork":false,"pushed_at":"2026-01-28T12:28:42.000Z","size":26045,"stargazers_count":64,"open_issues_count":2,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-29T04:46:06.227Z","etag":null,"topics":["azureopenai","chatgpt","openai","powershell"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mkht.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2023-03-08T12:26:27.000Z","updated_at":"2026-01-28T12:23:30.000Z","dependencies_parsed_at":"2023-11-12T14:25:33.325Z","dependency_job_id":"f7252199-9a38-4aa8-b80c-c67ada6564f8","html_url":"https://github.com/mkht/PSOpenAI","commit_stats":null,"previous_names":[],"tags_count":111,"template":false,"template_full_name":null,"purl":"pkg:github/mkht/PSOpenAI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkht%2FPSOpenAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkht%2FPSOpenAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkht%2FPSOpenAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkht%2FPSOpenAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkht","download_url":"https://codeload.github.com/mkht/PSOpenAI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkht%2FPSOpenAI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29196833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T12:38:28.597Z","status":"ssl_error","status_checked_at":"2026-02-07T12:38:23.888Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azureopenai","chatgpt","openai","powershell"],"created_at":"2024-11-13T01:18:48.397Z","updated_at":"2026-02-07T14:12:26.219Z","avatar_url":"https://github.com/mkht.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PSOpenAI\r\n\r\n[![Test](https://github.com/mkht/PSOpenAI/actions/workflows/test.yml/badge.svg)](https://github.com/mkht/PSOpenAI/actions/workflows/test.yml)\r\n\r\nPowerShell module for OpenAI and Azure OpenAI Service.  \r\nYou can use OpenAI functions such as ChatGPT, Speech-to-Text, Text-to-Image from PowerShell.\r\n\r\n**This is a community-based project and is not an official offering of OpenAI.**\r\n\r\n+ About OpenAI API  \r\nhttps://platform.openai.com/docs\r\n\r\n+ About Azure OpenAI Service  \r\nhttps://learn.microsoft.com/en-us/azure/ai-services/openai/overview\r\n\r\n----\r\n## Supported Platforms\r\n\r\n+ Windows PowerShell 5.1\r\n+ PowerShell 7 or higher\r\n+ Windows, macOS or Linux\r\n\r\nYou need to sign-up OpenAI account and generates API key for authentication.  \r\nhttps://platform.openai.com/api-keys\r\n\r\n----\r\n## Installation\r\n\r\nYou can install PSOpenAI from [PowerShell Gallery](https://www.powershellgallery.com/packages/PSOpenAI/).\r\n```Powershell\r\nInstall-Module -Name PSOpenAI\r\n```\r\n\r\n----\r\n## Functions\r\n\r\n\u003cdetails\u003e\r\n\u003csummary\u003eThe full list of functions\u003c/summary\u003e\r\n\r\n### Common\r\n+ [ConvertFrom-Token](/Docs/ConvertFrom-Token.md)\r\n+ [ConvertTo-Token](/Docs/ConvertTo-Token.md)\r\n+ [Get-CosineSimilarity](/Docs/Get-CosineSimilarity.md)\r\n+ [Get-OpenAIContext](/Docs/Get-OpenAIContext.md)\r\n+ [Set-OpenAIContext](/Docs/Set-OpenAIContext.md)\r\n+ [Clear-OpenAIContext](/Docs/Clear-OpenAIContext.md)\r\n\r\n### OpenAI\r\n#### Chat\r\nGuide: [How to use Chat](/Guides/How_to_use_Chat.md)\r\n\r\n+ [Enter-ChatGPT](/Docs/Enter-ChatGPT.md)\r\n+ [Request-ChatCompletion](/Docs/Request-ChatCompletion.md)\r\n+ [Get-ChatCompletion](/Docs/Get-ChatCompletion.md)\r\n+ [Set-ChatCompletion](/Docs/Set-ChatCompletion.md)\r\n+ [Remove-ChatCompletion](/Docs/Remove-ChatCompletion.md)\r\n+ [New-ChatCompletionFunction](/Docs/New-ChatCompletionFunction.md)\r\n\r\n#### Responses\r\nGuide: [Migrate ChatCompletion to Response](/Guides/Migrate_ChatCompletion_to_Response.md)  \r\n\r\n+ [Request-Response](/Docs/Request-Response.md)\r\n+ [Get-Response](/Docs/Get-Response.md)\r\n+ [Remove-Response](/Docs/Remove-Response.md)\r\n+ [Get-ResponseInputItem](/Docs/Get-ResponseInputItem.md)\r\n+ [Request-ResponseCompaction](/Docs/Request-ResponseCompaction.md)\r\n\r\n#### Conversations\r\n+ [New-Conversation](/Docs/New-Conversation.md)\r\n+ [Get-Conversation](/Docs/Get-Conversation.md)\r\n+ [Set-Conversation](/Docs/Set-Conversation.md)\r\n+ [Remove-Conversation](/Docs/Remove-Conversation.md)\r\n+ [Add-ConversationItem](/Docs/Add-ConversationItem.md)\r\n+ [Get-ConversationItem](/Docs/Get-ConversationItem.md)\r\n+ [Remove-ConversationItem](/Docs/Remove-ConversationItem.md)\r\n\r\n#### Assistants\r\nGuide: [How to use Assistants](/Guides/How_to_use_Assistants.md)  \r\nGuide: [How to use File search with Assistants and Vector Store](/Guides/How_to_use_FileSearch_with_VectorStore.md)\r\n\r\n+ [Get-Assistant](/Docs/Get-Assistant.md)\r\n+ [New-Assistant](/Docs/New-Assistant.md)\r\n+ [Set-Assistant](/Docs/Set-Assistant.md)\r\n+ [Remove-Assistant](/Docs/Remove-Assistant.md)\r\n+ [Get-Thread](/Docs/Get-Thread.md)\r\n+ [New-Thread](/Docs/New-Thread.md)\r\n+ [Set-Thread](/Docs/Set-Thread.md)\r\n+ [Remove-Thread](/Docs/Remove-Thread.md)\r\n+ [Get-ThreadMessage](/Docs/Get-ThreadMessage.md)\r\n+ [Add-ThreadMessage](/Docs/Add-ThreadMessage.md)\r\n+ [Remove-ThreadMessage](/Docs/Remove-ThreadMessage.md)\r\n+ [Get-ThreadRun](/Docs/Get-ThreadRun.md)\r\n+ [Start-ThreadRun](/Docs/Start-ThreadRun.md)\r\n+ [Stop-ThreadRun](/Docs/Stop-ThreadRun.md)\r\n+ [Wait-ThreadRun](/Docs/Wait-ThreadRun.md)\r\n+ [Receive-ThreadRun](/Docs/Receive-ThreadRun.md)\r\n+ [Get-ThreadRunStep](/Docs/Get-ThreadRunStep.md)\r\n+ [Get-VectorStore](/Docs/Get-VectorStore.md)\r\n+ [New-VectorStore](/Docs/New-VectorStore.md)\r\n+ [Set-VectorStore](/Docs/Set-VectorStore.md)\r\n+ [Remove-VectorStore](/Docs/Remove-VectorStore.md)\r\n+ [Add-VectorStoreFile](/Docs/Add-VectorStoreFile.md)\r\n+ [Get-VectorStoreFile](/Docs/Get-VectorStoreFile.md)\r\n+ [Remove-VectorStoreFile](/Docs/Remove-VectorStoreFile.md)\r\n+ [Start-VectorStoreFileBatch](/Docs/Start-VectorStoreFileBatch.md)\r\n+ [Get-VectorStoreFileBatch](/Docs/Get-VectorStoreFileBatch.md)\r\n+ [Stop-VectorStoreFileBatch](/Docs/Stop-VectorStoreFileBatch.md)\r\n+ [Wait-VectorStoreFileBatch](/Docs/Wait-VectorStoreFileBatch.md)\r\n+ [Get-VectorStoreFileInBatch](/Docs/Get-VectorStoreFileInBatch.md)\r\n\r\n#### Realtime\r\nGuide: [How to use Realtime API](/Guides/How_to_use_Realtime_API.md)  \r\n\r\n+ [Connect-RealtimeSession](/Docs/Connect-RealtimeSession.md)\r\n+ [Connect-RealtimeTranscriptionSession](/Docs/Connect-RealtimeTranscriptionSession.md)\r\n+ [Disconnect-RealtimeSession](/Docs/Disconnect-RealtimeSession.md)\r\n+ [Set-RealtimeSessionConfiguration](/Docs/Set-RealtimeSessionConfiguration.md)\r\n+ [Set-RealtimeTranscriptionSessionConfiguration](/Docs/Set-RealtimeTranscriptionSessionConfiguration.md)\r\n+ [Send-RealtimeSessionEvent](/Docs/Send-RealtimeSessionEvent.md)\r\n+ [Add-RealtimeSessionItem](/Docs/Add-RealtimeSessionItem.md)\r\n+ [Remove-RealtimeSessionItem](/Docs/Remove-RealtimeSessionItem.md)\r\n+ [Request-RealtimeSessionResponse](/Docs/Request-RealtimeSessionResponse.md)\r\n+ [Stop-RealtimeSessionResponse](/Docs/Stop-RealtimeSessionResponse.md)\r\n+ [Start-RealtimeSessionAudioInput](/Docs/Start-RealtimeSessionAudioInput.md) *\r\n+ [Stop-RealtimeSessionAudioInput](/Docs/Stop-RealtimeSessionAudioInput.md) *\r\n+ [Start-RealtimeSessionAudioOutput](/Docs/Start-RealtimeSessionAudioInput.md) *\r\n+ [Stop-RealtimeSessionAudioOutput](/Docs/Stop-RealtimeSessionAudioInput.md) *\r\n\r\n\u003e [*] Works on Windows with PowerShell 7.4+ only.\r\n\r\n#### Images\r\n+ [Request-ImageEdit](/Docs/Request-ImageEdit.md)\r\n+ [Request-ImageGeneration](/Docs/Request-ImageGeneration.md)\r\n+ [Request-ImageVariation](/Docs/Request-ImageVariation.md)\r\n\r\n#### Audio\r\n+ [Request-AudioSpeech](/Docs/Request-AudioSpeech.md)\r\n+ [Request-AudioTranscription](/Docs/Request-AudioTranscription.md)\r\n+ [Request-AudioTranslation](/Docs/Request-AudioTranslation.md)\r\n\r\n#### Videos\r\nGuide: [How to use Video generation](/Guides/How_to_use_Video_generation.md)\r\n\r\n+ [New-Video](/Docs/New-Video.md)\r\n+ [New-VideoRemix](/Docs/New-VideoRemix.md)\r\n+ [Get-Video](/Docs/Get-Video.md)\r\n+ [Get-VideoContent](/Docs/Get-VideoContent.md)\r\n+ [Remove-Video](/Docs/Remove-Video.md)\r\n\r\n#### Files\r\n+ [Get-OpenAIFile](/Docs/Get-OpenAIFile.md)\r\n+ [Add-OpenAIFile](/Docs/Add-OpenAIFile.md)\r\n+ [Remove-OpenAIFile](/Docs/Remove-OpenAIFile.md)\r\n+ [Get-OpenAIFileContent](/Docs/Get-OpenAIFileContent.md)\r\n\r\n#### Batch\r\nGuide: [How to use Batch](/Guides/How_to_use_Batch.md)\r\n\r\n+ [Start-Batch](/Docs/Start-Batch.md)\r\n+ [Get-Batch](/Docs/Get-Batch.md)\r\n+ [Wait-Batch](/Docs/Wait-Batch.md)\r\n+ [Stop-Batch](/Docs/Stop-Batch.md)\r\n+ [Get-BatchOutput](/Docs/Get-BatchOutput.md)\r\n\r\n### Containers\r\n+ [New-Container](/Docs/New-Container.md)\r\n+ [Get-Container](/Docs/Get-Container.md)\r\n+ [Remove-Container](/Docs/Remove-Container.md)\r\n+ [Add-ContainerFile](/Docs/Add-ContainerFile.md)\r\n+ [Get-ContainerFile](/Docs/Get-ContainerFile.md)\r\n+ [Remove-ContainerFile](/Docs/Remove-ContainerFile.md)\r\n+ [Get-ContainerFileContent](/Docs/Get-ContainerFileContent.md)\r\n\r\n### Others\r\n+ [Get-OpenAIModels](/Docs/Get-OpenAIModels.md)\r\n+ [Request-Embeddings](/Docs/Request-Embeddings.md)\r\n+ [Request-Moderation](/Docs/Request-Moderation.md)\r\n+ [Request-TextCompletion](/Docs/Request-TextCompletion.md)\r\n\r\n### Azure OpenAI Service\r\n+ [Guide: How to use with Azure OpenAI Service](Guides/How_to_use_with_Azure_OpenAI_Service.md)\r\n\r\n\u003c/details\u003e\r\n\r\n----\r\n## Usage\r\n\r\nSee [Docs](/Docs) and [Guides](/Guides) for more detailed and complex scenario descriptions.\r\n\r\n### Responses\r\n\r\nThe primary method for interacting with OpenAI models. You can generate text from the model with the code below.\r\n\r\n```PowerShell\r\n$env:OPENAI_API_KEY = '\u003cPut your API key here.\u003e'\r\n$Response = Request-Response -Model 'gpt-4o' -Message 'Explain quantum physics in simple terms.'\r\nWrite-Output $Response.output_text\r\n```\r\n\r\nThis code outputs answer from model like this.\r\n\r\n```\r\nQuantum physics is a branch of science that deals with the behavior of ...\r\n```\r\n\r\n### Chat Completions\r\n\r\nThe previous standard for generating text is the Chat Completions API. You can use that API to generate text from the model with the code below.  \r\n\r\nChat Completions API is compatible with other AI services besides OpenAI, such as GitHub Models and Google Gemini. You can also use self-hosted local AI models with LM Studio or Ollama. That is explained in the Advanced section.\r\n\r\n```PowerShell\r\n$env:OPENAI_API_KEY = '\u003cPut your API key here.\u003e'\r\n$Completion = Request-ChatCompletion -Model 'gpt-4o' -Message 'Give me a recipe for chocolate cake.'\r\nWrite-Output $Completion.Answer[0]\r\n```\r\n\r\n### Audio Speech (Text-to-Speech)\r\n\r\nGenerates audio from the input text.\r\n\r\n```PowerShell\r\n$env:OPENAI_API_KEY = '\u003cPut your API key here.\u003e'\r\nRequest-AudioSpeech -Model 'gpt-4o-mini-tts' -Text 'Hello, My name is shimmer.' -OutFile 'C:\\Output\\text2speech.mp3' -Voice shimmer\r\n```\r\n\r\n### Audio transcription (Speech-to-Text)\r\n\r\nTranscribes audio into the input language.\r\n\r\n```PowerShell\r\n$global:OPENAI_API_KEY = '\u003cPut your API key here.\u003e'\r\nRequest-AudioTranscription -Model 'gpt-4o-transcribe' -File 'C:\\SampleData\\audio.mp3'\r\n```\r\n\r\n### Image generation\r\n\r\nCreating images from scratch based on a text prompt.\r\n\r\n```PowerShell\r\n$global:OPENAI_API_KEY = '\u003cPut your API key here.\u003e'\r\nRequest-ImageGeneration -Model 'gpt-image-1.5' -Prompt 'A cute baby lion' -Size 1024x1024 -OutFile 'C:\\output\\babylion.png'\r\n```\r\n\r\nThis sample code saves image to `C:\\output\\babylion.png`. The saved image like this.\r\n\r\n![Generated image](/Docs/images/babylion.png)\r\n\r\n### Image edit\r\n\r\n```PowerShell\r\nRequest-ImageEdit -Model 'gpt-image-1.5' -Prompt 'A bird on the desert' -Image 'C:\\sand_with_fether.png' -OutFile 'C:\\bird_on_desert.png' -Size 1024x1024\r\n```\r\n\r\nThe edited image like this.\r\n\r\n| Original                                        | Generated                                  |\r\n| ----------------------------------------------- | ------------------------------------------ |\r\n| ![original](/Docs/images/sand_with_feather.png) | ![edited](/Docs/images/bird_on_desert.png) |\r\n\r\n### Video generation\r\nGenerate a video from a text prompt.\r\n\r\n```PowerShell\r\n$VideoJob = New-Video -Model 'sora-2' -Prompt \"A cat playing piano\" -Size 1280x720\r\n$VideoJob | Get-VideoContent -OutFile \"C:\\output\\cat_piano.mp4\" -WaitForCompletion\r\n```\r\n\r\n![video](/Docs/images/cat_piano.gif)\r\n\r\n### Moderation\r\n\r\nTest whether text complies with OpenAI's content policies.\r\n\r\n\u003e The moderation endpoint is free to use when monitoring the inputs and outputs of OpenAI APIs.\r\n\r\n```PowerShell\r\nPS C:\\\u003e $Result = Request-Moderation -Text \"I want to kill them.\"\r\nPS C:\\\u003e $Result.results.categories\r\n\r\n# True means it violates that category.\r\nsexual           : False\r\nhate             : False\r\nviolence         : True\r\nself-harm        : False\r\nsexual/minors    : False\r\nhate/threatening : False\r\nviolence/graphic : False\r\n```\r\n\r\n### List available models\r\n\r\nGet a list of available models.\r\n\r\n```PowerShell\r\n$Models = Get-OpenAIModels\r\n```\r\n\r\n### Realtime\r\n\r\nThe Realtime API enables you to communicate with AI models live, in real time experiences.\r\n\r\nHere's a basic text-based example. For more detailed usage, please refer to the guide.\r\n[Guide: How to use Realtime API](/Guides/How_to_use_Realtime_API.md)\r\n\r\n```PowerShell\r\n$env:OPENAI_API_KEY = '\u003cPut your API key here\u003e'\r\n\r\n# Subscribe to events\r\nRegister-EngineEvent -SourceIdentifier 'PSOpenAI.Realtime.ReceiveMessage' -Action {\r\n    $eventItem = $Event.SourceArgs[0]\r\n    switch ($eventItem.type) {\r\n        'response.output_text.delta' {\r\n            $eventItem.delta | Write-Host -NoNewLine -ForegroundColor Blue\r\n        }\r\n    }\r\n}\r\n\r\n# Connect to the Realtime session\r\nConnect-RealtimeSession -Model 'gpt-realtime'\r\nSet-RealtimeSessionConfiguration -OutputModalities 'text' -Instructions 'You are a science tutor.'\r\n\r\n# Send messages to the AI model\r\nAdd-RealtimeSessionItem -Message 'Why does the sun rise in the east and set in the west?' -TriggerResponse\r\n\r\n# Disconnect\r\nDisconnect-RealtimeSession\r\n```\r\n\r\n----\r\n## Advanced\r\n\r\n### Multiple conversations keeping context.\r\n\r\n`Request-Response` and `Request-ChatCompletion` accepts past dialogs from pipeline. Additional questions can be asked while maintaining context.\r\n\r\n```PowerShell\r\nPS C:\\\u003e $FirstQA = Request-ChatCompletion -Model 'gpt-4.1-nano' -Message 'What is the population of the United States?'\r\nPS C:\\\u003e Write-Output $FirstQA.Answer\r\n\r\nAs of October 2023, the estimated population of the United States is approximately 336 million people.\r\n\r\nPS C:\\\u003e $SecondQA = $FirstQA | Request-ChatCompletion -Message 'Translate the previous answer into French.'\r\nPS C:\\\u003e Write-Output $SecondQA.Answer\r\n\r\nEn octobre 2023, la population estimée des États-Unis est d'environ 336 millions de personnes.\r\n\r\nPS C:\\\u003e $ThirdQA = $SecondQA | Request-ChatCompletion -Message 'Just tell me the number.'\r\nPS C:\\\u003e Write-Output $ThirdQA.Answer\r\n\r\n336 millions\r\n```\r\n\r\n### Streaming responses\r\n\r\nBy default, results are output all at once after all responses are complete, so it may take some time before results are available. To get responses sooner, you can use the `-Stream` option for `Request-ChatCompletion` and `Request-Response`\r\n\r\n```PowerShell\r\nRequest-ChatCompletion 'Describe ChatGPT in 100 charactors.' -Stream | Write-Host -NoNewline\r\n```\r\n\r\n![Stream](/Docs/images/StreamOutput.gif)\r\n\r\n\r\n### Vision (Image input)\r\n\r\nYou can input images to the model and get answers.\r\n\r\n```PowerShell\r\n# Local file\r\n$Response = Request-Response -Model 'o4-mini' -Images 'C:\\SampleData\\donut.png' -Message 'How many donuts are there?'\r\n\r\n# Remote URL\r\n$Response = Request-Response -Model 'o4-mini' -Images 'https://upload.wikimedia.org/wikipedia/commons/5/5f/Cerro_El_%C3%81vila_desde_El_Bosque_-_Caracas.jpg' -Message 'Where is this?'\r\n```\r\n\r\n### Web Search\r\n\r\nAllow models to search the web for the latest information before generating a response.\r\n\r\n```PowerShell\r\n$Response = Request-Response -Model 'gpt-4.1' -Message 'What was a tech news in Merch 2025?' -UseWebSearch\r\n```\r\n\r\n### Azure OpenAI Service\r\n\r\nIf you want to use Azure OpenAI Service instead of OpenAI. You should create Azure OpenAI resource to your Azure tenant, and get API key and endpoint url. See guides for more details.\r\n\r\n+ [Guide: How to use with Azure OpenAI Service](Guides/How_to_use_with_Azure_OpenAI_Service.md)\r\n\r\n```powershell\r\n$global:OPENAI_API_KEY = '\u003cPut your api key here\u003e'\r\n$global:OPENAI_API_BASE  = 'https://\u003cresource-name\u003e.openai.azure.com/'\r\n\r\nRequest-ChatCompletion `\r\n  -Model 'gpt-4o' `\r\n  -Message 'Hello Azure OpenAI Service.' `\r\n  -ApiType Azure\r\n```\r\n\r\n### OpenAI Compatible Servers\r\n\r\nIf you want to use OpenAI compatible services such as GitHub Models, Google Gemini, self-hosted servers like LM Studio or Ollama.\r\n\r\n```powershell\r\n# This is an example for GitHub Models.\r\n$global:OPENAI_API_KEY = '\u003cPut your GITHUB_TOKEN\u003e'\r\n$global:OPENAI_API_BASE  = 'https://models.github.ai/inference'\r\n\r\nRequest-ChatCompletion `\r\n  -Model 'microsoft/Phi-4-reasoning' `\r\n  -Message 'What is the capital of France?' `\r\n  -ApiType OpenAI\r\n```\r\n\r\n----\r\n## About API key\r\n\r\n+ [Guide: How to handle API keys and context parameters](Guides/How_to_handle_API-keys_and_Context.md)\r\n\r\nAlmost all functions require an API key for authentication.  \r\nYou need to sign-up OpenAI account and generates API key from here.  \r\nhttps://platform.openai.com/api-keys\r\n\r\nThere are three ways to give an API key to functions.\r\n\r\n### Method 1: Set an environment variable named `OPENAI_API_KEY`. (RECOMMENDED)\r\nSet the API key to the environment variable named `OPENAI_API_KEY`.  \r\nThis method is best suited when running on a trusted host or CI/CD pipeline.\r\n\r\n```PowerShell\r\nPS C:\u003e $env:OPENAI_API_KEY = '\u003cPut your API key here.\u003e'\r\nPS C:\u003e Request-ChatCompletion -Message \"Who are you?\"\r\n```\r\n\r\n### Method 2: Set a global variable named `OPENAI_API_KEY`.\r\nSet the API key to the `$global:OPENAI_API_KEY` variable. The variable is implicitly used whenever a function is called within the session.  \r\n\r\n```PowerShell\r\nPS C:\u003e $global:OPENAI_API_KEY = '\u003cPut your API key here.\u003e'\r\nPS C:\u003e Request-ChatCompletion -Message \"Who are you?\"\r\n```\r\n\r\n### Method 3: Supply as named parameter.\r\nSpecify the API key explicitly in the `ApiKey` parameter. It must be specified each time the function is called.  \r\nThis is best used when the function is called only once or with few calls, such as when executing manually from the console.\r\n\r\n```PowerShell\r\nPS C:\u003e Request-ChatCompletion -Message \"Who are you?\" -ApiKey '\u003cPut your API key here.\u003e'\r\n```\r\n\r\n----\r\n## Changelog\r\n\r\n[CHANGELOG.md](/CHANGELOG.md)\r\n\r\n----\r\n## Plans and TODOs.\r\n\r\nIf you have a feature request or bug report, please tell us in Issue.\r\n\r\n+ More docs, samples.\r\n+ Performance improvements.\r\n+ Add a support for fine-tuning.\r\n\r\n----\r\n## License \u0026 Libraries\r\n\r\n[MIT License](/LICENSE)\r\n\r\nThis module uses these OSS libraries.\r\n\r\n- [Newtonsoft.Json](https://www.newtonsoft.com/json) by jamesnk (MIT License)\r\n- [NJsonSchema](https://github.com/RicoSuter/NJsonSchema) by rsuter (MIT License)\r\n- [Microsoft.DeepDev.TokenizerLib](https://github.com/microsoft/Tokenizer) by microsoft (MIT License)\r\n- [NAudio](https://github.com/naudio/NAudio) by Mark Heath (MIT License)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkht%2Fpsopenai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkht%2Fpsopenai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkht%2Fpsopenai/lists"}