Simple command-line tools for Azure OpenAI in both Python and JavaScript/Deno.
.
├── .env # Shared Azure OpenAI credentials
├── python/ # Python implementation
│ ├── ask.py # One-shot query tool
│ └── chat.py # Interactive chat
└── js/ # JavaScript/Deno implementation
├── ask.js # One-shot query tool
└── chat.js # Interactive chat
- Python version: Python >= 3.13 with
uv
installed - Deno version: Deno >= 1.40
- Azure OpenAI resource with a deployed model
Create a .env
file in the root directory with your Azure OpenAI credentials:
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_BASE_URL=https://your-resource.cognitiveservices.azure.com/
AZURE_OPENAI_DEPLOYMENT=your-deployment-name
The Python scripts use inline dependencies (PEP 723) and run with uv run
:
cd python
uv run ask.py "What is the capital of France?"
cd python
uv run chat.py
The JavaScript scripts can be run directly with Deno or made executable:
cd js
deno run --allow-env --allow-read --allow-net ask.js "What is the capital of France?"
# Or if made executable:
./ask.js "What is the capital of France?"
cd js
deno run --allow-env --allow-read --allow-net chat.js
# Or if made executable:
./chat.js
Both implementations provide:
- One-shot queries: Quick questions with immediate responses
- Interactive chat: Multi-turn conversations with context retention
- Streaming responses: Real-time output as the AI generates text
- Error handling: Clear error messages for configuration issues
- No virtual environment needed: Python uses
uv run
, Deno runs directly
- Python: Uses the
openai
package withAzureOpenAI
class - JavaScript/Deno: Uses the same
openai
npm package via Deno's npm: specifier - Permissions: Deno requires explicit permissions (--allow-env, --allow-read, --allow-net)
- Modern JavaScript: Uses ES modules and async/await
If you get a "DeploymentNotFound" error:
- Log into Azure Portal
- Navigate to your Azure OpenAI resource
- Go to "Model deployments"
- Copy the exact deployment name
- Update
AZURE_OPENAI_DEPLOYMENT
in your.env
file