Very small Python CLI wrapper around Azure Foundry chat completions.
pip install -e .After install, the command is available from your PATH:
foundry-api -p "What is the capital of France?"You can export these variables or define them in a local .env file:
export FOUNDRY_BASE_URL=https://YOUR-RESOURCE-NAME.openai.azure.com/openai/deployments/
export FOUNDRY_API_KEY=YOUR-AZURE-API-KEY
export FOUNDRY_MODEL=YOUR-DEPLOYMENT-NAMENotes:
- The wrapper accepts
FOUNDRY_BASE_URLin either style:https://<resource>.openai.azure.com/openai/v1/https://<resource>.openai.azure.com/openai/deployments/
- If the
deployments/style is provided, it is normalized automatically to.../openai/v1/for the OpenAI client.
Prompt:
foundry-api -p "Explain zero trust in one sentence"If your prompt contains quotes, JSON, or multiple lines, pass it through stdin or a file instead of escaping it in the shell:
@'
Return a JSON object with keys "city" and "country".
Include the raw JSON schema below:
{"type":"object","properties":{"city":{"type":"string"}}}
'@ | foundry-api -p -Or use a file:
foundry-api --prompt-file .\prompt.txtJSON output only:
foundry-api -p "Return a JSON object with keys city and country" --jsonIn --json mode, the wrapper asks the model to return valid JSON only and prints the raw JSON response directly, without any extra wrapper object.
Override the deployment for one call:
foundry-api -p "Hello" --model my-other-deploymentPrint the full API response:
foundry-api -p "Hello" --rawYou can also execute the script file directly:
python foundry-api.py -p "Hello"