Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

foundry-api-wrapper

Very small Python CLI wrapper around Azure Foundry chat completions.

Install (editable)

pip install -e .

After install, the command is available from your PATH:

foundry-api -p "What is the capital of France?"

Environment variables

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-NAME

Notes:

  • The wrapper accepts FOUNDRY_BASE_URL in 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.

Usage

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.txt

JSON output only:

foundry-api -p "Return a JSON object with keys city and country" --json

In --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-deployment

Print the full API response:

foundry-api -p "Hello" --raw

You can also execute the script file directly:

python foundry-api.py -p "Hello"

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages