### Manual Setup for Local Agent Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations/github-copilot/README.md Install dependencies, copy the .env example, set your GitHub token, and run the main Python script. The agent will start on http://localhost:8088/. ```bash pip install -r requirements.txt cp .env.example .env # skip if .env already exists # Edit .env and set GITHUB_TOKEN=github_pat_... python main.py ``` -------------------------------- ### Install Dependencies and Start Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/javascript/foundry-local/audio-transcription-example/README.md Install project dependencies and start the application using npm. ```bash npm install npm start ``` -------------------------------- ### Manual Setup and Run Agent Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/responses/notetaking-agent/README.md Provides steps for manual setup, including copying the environment file, installing dependencies, and starting the agent script. ```bash # Copy and edit environment file cp .env.example .env # skip if .env already exists # Install dependencies pip install -r requirements.txt # Start the agent python main.py ``` -------------------------------- ### Manual Setup for Local Development Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations/toolbox/README.md This sequence sets up the environment, installs dependencies, and runs the agent manually. Ensure you have Python and pip installed. The agent will start on `http://localhost:8088`. ```bash cp .env.example .env # skip if .env already exists # Edit .env and fill in your values, then: export $(grep -v '^#' .env | xargs) python -m venv .venv source .venv/bin/activate pip install -r requirements.txt python main.py ``` -------------------------------- ### Full Deployment Example Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/livekit-server/README.md A comprehensive example combining initialization, ACR configuration, environment variable setup, and deployment. Replace all placeholders with your specific Azure and LiveKit details. ```bash az account set --subscription mkdir -p ~/azd-deploys/livekit-server && cd ~/azd-deploys/livekit-server azd ai agent init \ -m /samples/python/hosted-agents/bring-your-own/invocations_ws/livekit-server/agent.manifest.yaml \ -p "/subscriptions//resourceGroups//providers/Microsoft.CognitiveServices/accounts//projects/" \ --no-prompt azd env set AZURE_CONTAINER_REGISTRY_NAME azd env set AZURE_CONTAINER_REGISTRY_ENDPOINT .azurecr.io azd env set USE_EXISTING_CONTAINER_REGISTRY true azd env set CONTAINER_REGISTRY_RESOURCE_GROUP # ...azd env set the AZURE_/LIVEKIT_ variables above... azd deploy livekit-server-azd ``` -------------------------------- ### Manual Setup and Run Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations/langgraph-chat/README.md Sets up the environment by copying the example .env file and then runs the Python script for the agent. Edit .env values as needed. ```bash cp .env.example .env # then edit values (skip if .env already exists) pip install -r requirements.txt python main.py ``` -------------------------------- ### Local Quick Start - Linux/macOS Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox/README.md Installs dependencies and starts the agent locally on Linux/macOS. Requires environment variables to be set in `.env`. ```bash # 1. Copy and fill in the environment file cp .env.example .env # skip if .env already exists # Edit .env — set FOUNDRY_PROJECT_ENDPOINT, AZURE_AI_MODEL_DEPLOYMENT_NAME, # and TOOLBOX_ENDPOINT at minimum # 2. Install dependencies pip install -r requirements.txt # 3. Start the agent python main.py # 4. Invoke curl -X POST http://localhost:8088/responses \ -H "Content-Type: application/json" \ -d '{"input": "What tools do you have?"}' ``` -------------------------------- ### Install Dependencies and Run Agent Host Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/csharp/hosted-agents/agent-framework/browser-automation/README.md Installs necessary dependencies and starts the local hosted-agent server. Ensure you are in the correct project directory. ```bash dotnet restore browser-automation.csproj npm install -g @playwright/cli@latest playwright-cli install --skills dotnet run --project browser-automation.csproj ``` -------------------------------- ### Setup Virtual Environment and Install Dependencies Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/foundry-local/verify-winml/README.md Installs the WinML SDK variant and its dependencies using pip. Ensure you are in a fresh virtual environment or have cleaned up previous installations. ```bash python -m venv .venv .venv\Scripts\Activate.ps1 pip install --upgrade -r requirements.txt ``` ```bash pip install --upgrade -r requirements.txt ``` -------------------------------- ### Manual Setup for Hosted Agent Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/responses/env-vars-agent/README.md Manually set up the hosted agent by installing dependencies, copying the environment file, and exporting necessary environment variables. Then, run the main Python script. The agent will start on `http://localhost:8088/`. ```bash pip install -r requirements.txt cp .env.example .env # then edit values — fill in any test values you like (skip if .env already exists) export FOUNDRY_PROJECT_ENDPOINT="https://your-project.services.ai.azure.com/api/projects/your-project" export AZURE_AI_MODEL_DEPLOYMENT_NAME="gpt-5.4-mini" export SECRET_API_KEY="ab12-fake-test-key" export TARGET="https://api.example.com" export SECRET_KEY="p@ssw0rd-test-value" export NON_SECRET_KEY="westus2" python main.py ``` -------------------------------- ### Manual Setup for Hosted Agent Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/responses/openai-agents-sdk/README.md Install dependencies, copy the environment file, and set necessary environment variables before running the agent script. Ensure `FOUNDRY_PROJECT_ENDPOINT` and `AZURE_AI_MODEL_DEPLOYMENT_NAME` are configured in the `.env` file. The agent will start on `http://localhost:8088/`. ```bash pip install -r requirements.txt cp .env.example .env # then set FOUNDRY_PROJECT_ENDPOINT and AZURE_AI_MODEL_DEPLOYMENT_NAME (skip if .env already exists) python main.py ``` -------------------------------- ### Start Shared Web Portal Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-ws-server/README.md Navigate to the client directory, set up a virtual environment, install dependencies, configure the local WebSocket URL in .env, and run the web portal script. ```bash cd samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-ws-server/chat_client python -m venv ../.venv # (or reuse the server's venv) source ../.venv/bin/activate pip install -r requirements.txt # Local mode — point at the server you just started echo 'PIPECAT_WEBSOCKET_LOCAL_URL=ws://localhost:8088/invocations_ws' >> .env python web_portal.py # listens on :9527 ``` -------------------------------- ### Manual Setup for Hosted Agent Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations/ag-ui/README.md Install dependencies, copy the environment file, and run the main script to set up the agent manually. The agent listens on `http://localhost:8088/`. ```bash pip install -r requirements.txt cp .env.example .env # then fill in values (skip if .env already exists) python main.py ``` -------------------------------- ### Start Chat Client Portal Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/livekit-server/README.md Installs dependencies and starts the chat client portal. It includes an option to configure it for a local LiveKit server instead of a hosted Foundry agent. ```bash cd chat_client pip install -r requirements.txt cp .env.example .env # To use this LOCAL livekit-server instead of the hosted Foundry agent, uncomment in chat_client/.env: # LIVEKIT_LOCAL_URL=ws://localhost:8088/invocations_ws python web_portal.py ``` -------------------------------- ### Local Quick Start - Windows PowerShell Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox/README.md Installs dependencies and starts the agent locally on Windows using PowerShell. Requires environment variables to be set in `.env`. ```powershell # 1. Copy and fill in the environment file Copy-Item .env.example .env # skip if .env already exists # Edit .env — set FOUNDRY_PROJECT_ENDPOINT, AZURE_AI_MODEL_DEPLOYMENT_NAME, # and TOOLBOX_ENDPOINT at minimum # 2. Install dependencies pip install -r requirements.txt # 3. Start the agent python main.py # 4. Invoke Invoke-RestMethod -Method POST http://localhost:8088/responses ` -ContentType "application/json" ` -Body '{"input": "What tools do you have?"}' ``` -------------------------------- ### Start Pipecat WebRTC Server Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-webrtc/README.md Sets up a Python virtual environment, installs dependencies, and starts the Pipecat WebRTC server. Ensure the .env file is configured before running. ```bash cd samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-webrtc python -m venv .venv source .venv/bin/activate pip install -r requirements.txt # Make sure .env is filled in (see "Server" table above) python server.py ``` -------------------------------- ### Start Pipecat WebSocket Server Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-ws-server/README.md Navigate to the server directory, set up a virtual environment, install dependencies, and run the server script. Ensure the .env file is configured. ```bash cd samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-ws-server python -m venv .venv source .venv/bin/activate pip install -r requirements.txt # Make sure .env is filled in (see "Server" table above) python server.py ``` -------------------------------- ### Install Sample Dependencies Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/javascript/foundry-local/README.md Navigate to a specific sample directory and install its Node.js dependencies. ```bash cd native-chat-completions npm install ``` -------------------------------- ### Run the Transcription Example Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/javascript/foundry-local/live-audio-transcription/README.md Execute the main application file to start the live audio transcription. ```bash node app.js ``` -------------------------------- ### Example Script Arguments for Travel Guide Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/agent-framework/responses/07-skills/skills/travel-guide/SKILL.md Demonstrates the format and possible arguments for the `create_travel_guide.py` script. Use this to construct CLI arguments for generating a custom travel guide. ```json [ "--city", "Lisbon", "--days", "3", "--interests", "food,viewpoints,neighborhoods", "--tone", "first-time visitor" ] ``` -------------------------------- ### Install Sample Dependencies Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/foundry-local/README.md Navigate to a specific sample directory and install its Python dependencies using pip. ```bash cd native-chat-completions pip install -r requirements.txt ``` -------------------------------- ### Smaller/Cheaper Deployment Example Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/infrastructure/infrastructure-setup-bicep/16-private-network-standard-agent-apim-setup/extensions/byom-cross-region/preflight/README.md Use this example to verify a deployment with a single model on the backend and reduced capacity. ```powershell . check-region.ps1 -Subscription ` -ProjectRegion eastus -BackendRegion eastus2 ` -BackendModels 'gpt-4o@2024-11-20' ` -BackendModelCapacity 5 ``` -------------------------------- ### Manual Setup for Agent Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/csharp/hosted-agents/bring-your-own/responses/background-agent/README.md Set the `FOUNDRY_PROJECT_ENDPOINT` and `AZURE_AI_MODEL_DEPLOYMENT_NAME` environment variables, then run the agent using `dotnet run`. The agent will start on http://localhost:8088/. ```bash export FOUNDRY_PROJECT_ENDPOINT="https://your-resource.services.ai.azure.com/api/projects/your-project" export AZURE_AI_MODEL_DEPLOYMENT_NAME="gpt-5.4-mini" dotnet run ``` -------------------------------- ### Install Sample Dependencies Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/foundry-local/web-server-responses/README.md Install the necessary Python packages for the sample. This includes the Foundry Local SDK and the OpenAI client. Specific SDK versions may be installed based on the operating system. ```bash pip install -r requirements.txt ``` -------------------------------- ### Setup and Run Local Agent Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/hello-world/README.md Installs dependencies, sets up the environment, and runs the local agent using Uvicorn. Ensure to fill in your Azure Voice Live endpoint and model in the .env file. ```bash cd samples/python/hosted-agents/bring-your-own/invocations_ws/hello-world python -m venv .venv source .venv/bin/activate pip install -r requirements.txt cp .env.example .env # Fill in AZURE_VOICELIVE_ENDPOINT and AZURE_VOICELIVE_MODEL. export $(grep -v '^#' .env | xargs) python main.py # → Uvicorn running on http://0.0.0.0:8088 ``` -------------------------------- ### Client Configuration Example Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-webrtc/README.md Example environment variables for the chat client, showing how to configure it for local server connection or a Foundry-hosted agent. ```bash PROJECT_ENDPOINT=https://{account}.services.ai.azure.com/api/projects/{project} PIPECAT_WEBRTC_AGENT_NAME=pipecat-ws-webrtc # PIPECAT_WEBRTC_LOCAL_URL=ws://localhost:8089/invocations_ws ``` -------------------------------- ### Start Pipecat WebRTC Chat Client Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-webrtc/README.md Sets up the Python virtual environment, installs dependencies, and starts the web portal client. It configures the client to connect to the locally running server by setting the PIPECAT_WEBRTC_LOCAL_URL environment variable. ```bash cd samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-webrtc/chat_client python -m venv ../.venv # (or reuse the server's venv) source ../.venv/bin/activate pip install -r requirements.txt # Local mode — point at the server you just started echo 'PIPECAT_WEBRTC_LOCAL_URL=ws://localhost:8089/invocations_ws' >> .env python web_portal.py # listens on :9528 (open http://localhost:9528) ``` -------------------------------- ### Python Agent Hosting and Server Setup (main.py) Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/agent-framework/responses/09-declarative-customer-support/README.md Sets up and hosts the customer support workflow as an agent using Python. It initializes agents, registers them with a factory, loads the workflow, and starts a REST API endpoint compatible with the OpenAI Responses protocol. ```python import os from dotenv import load_dotenv from agent_framework.foundry.chat_client import FoundryChatClient from agent_framework.foundry.responses_host import ResponsesHostServer from agent_framework.foundry.workflow_factory import WorkflowFactory from .agents import TriageAgent, TechSupportAgent, BillingAgent from .responses import TriageResponse def main(): load_dotenv() # Initialize the Foundry chat client client = FoundryChatClient( api_key=os.environ.get("FOUNDRY_API_KEY") ) # Initialize agents triage_agent = TriageAgent(client=client, response_format=TriageResponse) tech_support_agent = TechSupportAgent(client=client) billing_agent = BillingAgent(client=client) # Create a workflow factory and register agents factory = WorkflowFactory() factory.register("TriageAgent", triage_agent) factory.register("TechSupportAgent", tech_support_agent) factory.register("BillingAgent", billing_agent) # Load the workflow from YAML workflow_agent = factory.load_workflow("workflow.yaml").as_agent() # Initialize and run the Responses host server server = ResponsesHostServer(agent=workflow_agent) server.run() if __name__ == "__main__": main() ``` -------------------------------- ### Install Dependencies Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/foundry-models/model-router/README.md Install project dependencies by running this command after creating a virtual environment. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies and Run Application Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/foundry-local/embeddings/README.md Installs project dependencies using pip and then runs the main application script. ```bash pip install -r requirements.txt python src/app.py ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/livekit-server/chat_client/README.md Navigate to the chat client directory, create a virtual environment, activate it, and install the required Python packages. ```bash cd samples/python/hosted-agents/bring-your-own/invocations_ws/livekit-server/chat_client python -m venv .venv && source .venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/foundry-local/live-audio-transcription/README.md Install the required Python packages for the project. `pyaudio` is optional and provides microphone capture. ```bash pip install -r requirements.txt ``` ```bash pip install pyaudio ``` -------------------------------- ### Run a Sample Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/javascript/foundry-local/README.md Execute a sample application after installing its dependencies. ```bash npm start ``` -------------------------------- ### Set up .env file with azd Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations/github-copilot/README.md Copy the example .env file and set your GitHub token. This is automatically loaded when running locally with `azd`. ```bash cp .env.example .env # skip if .env already exists # Edit .env and set GITHUB_TOKEN=github_pat_... ``` -------------------------------- ### Manual Agent Setup and Run Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/csharp/hosted-agents/bring-your-own/invocations/notetaking-agent/README.md Build the project, copy and edit the environment file, set necessary environment variables for project endpoint and model deployment, and then run the application. ```bash dotnet build cp .env.example .env # then edit values (skip if .env already exists) export FOUNDRY_PROJECT_ENDPOINT="https://your-project.services.ai.azure.com/api/projects/your-project" export AZURE_AI_MODEL_DEPLOYMENT_NAME="gpt-5.4-mini" dotnet run ``` -------------------------------- ### Deploy Dynamic Discovery APIM Connection using Azure CLI Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/infrastructure/infrastructure-setup-bicep/01-connections/apim/README.md Deploys an APIM connection with dynamic model discovery. This requires prior configuration of list and get endpoints in APIM as per the setup guide. Edit the parameters file with your resource IDs before deployment. The API key is automatically retrieved from the APIM service. ```bash az deployment group create \ --resource-group \ --template-file connection-apim.bicep \ --parameters @samples/parameters-dynamic-discovery.json ``` -------------------------------- ### Start LangGraph Agent (Linux/macOS) Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox-user-identity/README.md Starts the LangGraph agent on Linux or macOS. Ensure environment variables in .env are set and dependencies are installed. ```bash # 1. Copy and fill in the environment file cp .env.example .env # skip if .env already exists # Edit .env — set FOUNDRY_PROJECT_ENDPOINT, MODEL_DEPLOYMENT_NAME, # and TOOLBOX_ENDPOINT at minimum # 2. Install dependencies pip install -r requirements.txt # 3. Start the agent python main.py # 4. Invoke curl -X POST http://localhost:8088/responses \ -H "Content-Type: application/json" \ -d '{"input": "What tools do you have?"}' ``` -------------------------------- ### Start LangGraph Agent (Windows PowerShell) Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/responses/langgraph-toolbox-user-identity/README.md Starts the LangGraph agent on Windows using PowerShell. Ensure environment variables in .env are set and dependencies are installed. ```powershell # 1. Copy and fill in the environment file Copy-Item .env.example .env # skip if .env already exists # Edit .env — set FOUNDRY_PROJECT_ENDPOINT, MODEL_DEPLOYMENT_NAME, # and TOOLBOX_ENDPOINT at minimum # 2. Install dependencies pip install -r requirements.txt # 3. Start the agent python main.py # 4. Invoke Invoke-RestMethod -Method POST http://localhost:8088/responses ` -ContentType "application/json" ` -Body '{"input": "What tools do you have?"}' ``` -------------------------------- ### Run a Sample Application Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/foundry-local/README.md Execute a Python sample application after installing its dependencies. ```bash python src/app.py ``` -------------------------------- ### Start Web Portal Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/pipecat-ws-server/README.md Navigate to the chat_client directory and run the web portal script to connect to the agent. ```bash cd chat_client && python web_portal.py ``` -------------------------------- ### Start Azure Function Locally Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/infrastructure/infrastructure-setup-bicep/19-private-network-agent-tools/azure-function-server/README.md Navigates to the function server directory, installs Python dependencies, and starts the Azure Functions host locally. This allows for local testing and debugging. ```bash cd azure-function-server pip install -r requirements.txt func start ``` -------------------------------- ### Manual Setup for Claude Agent Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations/claude-agent-sdk/README.md Install dependencies, copy the environment file, and run the main Python script to set up the Claude agent manually. Ensure you have Python 3.10+ installed. ```bash pip install -r requirements.txt cp .env.example .env # skip if .env already exists python main.py ``` -------------------------------- ### Setup Local Diagnostic Agent Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations/diagnostic-agent/README.md Set up a Python virtual environment, install dependencies, and run the agent locally. The agent will listen on http://localhost:8088/. ```bash python -m venv .venv source .venv/bin/activate pip install -r requirements.txt python main.py ``` -------------------------------- ### Run the Sample Application Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/foundry-local/web-server-responses/README.md Execute the main Python script to start the local web service, send API requests, and process the responses. This command assumes you are in the sample's root directory. ```bash python -m venv .venv . .venv\Scripts\activate pip install -r requirements.txt python src\app.py ``` -------------------------------- ### Run Main Sample (Maven) Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/java/enterprise-agent-tutorial/1-idea-to-prototype/README.md Executes the main Modern Workplace Assistant application using Maven. This starts the agent. ```bash mvn exec:java -Dexec.mainClass="com.microsoft.azure.samples.ModernWorkplaceAssistant" ``` -------------------------------- ### Set up local environment variables Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/voicelive/foreground-background-agents-responses-voicelive/README.md Copy the example environment file and edit it with your specific values. Then, source the file to load the variables into your current shell session. ```bash cp .env.example .env # Edit .env with your values source .env ``` -------------------------------- ### Audio Playback Setup Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/csharp/hosted-agents/bring-your-own/invocations_ws/HelloWorld/chat_client/index.html Initializes or reinitializes the AudioContext for playback, ensuring the correct sample rate. Schedules audio playback to start at a specific time to manage timing. ```javascript function ensurePlayCtx(sampleRate) { if (!playCtx || playCtx.sampleRate !== sampleRate) { if (playCtx) try { playCtx.close(); } catch {} playCtx = new (window.AudioContext || window.webkitAudioContext)({ sampleRate }); playTime = playCtx.currentTime; } } function playPcm(uint8, sampleRate, channels) { ensurePlayCtx(sampleRate); const i16 = new Int16Array(uint8.buffer, uint8.byteOffset, uint8.byteLength / 2); const frames = i16.length / channels; const buf = playCtx.createBuffer(channels, frames, sampleRate); for (let c = 0; c < channels; c++) { const ch = buf.getChannelData(c); for (let i = 0; i < frames; i++) ch[i] = i16[i * channels + c] / 32768; } const src = playCtx.createBufferSource(); src.buffer = buf; src.connect(playCtx.destination); const now = playCtx.currentTime; if (playTime < now) playTime = now; src.start(playTime); playTime += buf.duration; playSources.push(src); src.onended = () => { const i = playSources.indexOf(src); if (i >= 0) playSources.splice(i, 1); }; } // Stop and drop all queued playback (e.g. when user interrupts the bot). function cancelPlayback() { for (const s of playSources) { try { s.stop(); } catch {} } playSources = []; if (playCtx) playTime = playCtx.currentTime; } ``` -------------------------------- ### Set up Environment Variables Locally Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/responses/hello-world/README.md Copy the example environment file and edit it with your specific values. Source the file to load the variables into your current shell session. This is for local development when not using `azd ai agent run`. ```bash cp .env.example .env # skip if .env already exists # Edit .env with your values source .env ``` -------------------------------- ### Test Hosted Agent Responses with curl (Streaming) Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/responses/langgraph-chat/README.md Send a POST request to the agent's endpoint to get a response. This example demonstrates streaming responses and chaining conversations using `previous_response_id`. ```bash # Turn 1 — ask for the time (triggers tool call) curl -N -X POST http://localhost:8088/responses \ -H "Content-Type: application/json" \ -d '{"model": "chat", "input": "What time is it right now?", "stream": true}' # Turn 2 — chain via previous_response_id curl -N -X POST http://localhost:8088/responses \ -H "Content-Type: application/json" \ -d '{"model": "chat", "input": "What is 42 * 17?", "previous_response_id": "", "stream": true}' # Turn 3 — context recall curl -N -X POST http://localhost:8088/responses \ -H "Content-Type: application/json" \ -d '{"model": "chat", "input": "Add 100 to that result", "previous_response_id": "", "stream": true}' ``` -------------------------------- ### Run Live Audio Transcription Example Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/rust/foundry-local/live-audio-transcription/README.md Navigate to the example directory and run the transcription. Use Ctrl+C to stop the live process. Alternatively, run with the --synth flag to generate synthetic audio if no microphone is available. ```bash cd samples/rust/live-audio-transcription-example # Live microphone (press Ctrl+C to stop) cargo run # Synthetic 440Hz sine wave (no microphone needed) cargo run -- --synth ``` -------------------------------- ### Setup and Run Duplex Live Agent Locally Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations_ws/duplex-live-agent/README.md Installs dependencies, sets up environment variables, and runs the agent locally. Ensure to fill in your Azure Voice Live endpoint and model in the .env file. ```bash cd duplex-live-agent python -m venv .venv source .venv/bin/activate pip install -r requirements.txt websockets cp .env.example .env # Fill in AZURE_VOICELIVE_ENDPOINT and AZURE_VOICELIVE_MODEL. export $(grep -v '^#' .env | xargs) python main.py # → Uvicorn running on http://0.0.0.0:8088 ``` -------------------------------- ### Manual Agent Setup Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/invocations/human-in-the-loop/README.md Manually set up and run the agent by installing dependencies, configuring environment variables, and executing the main Python script. Ensure you edit the .env file with your specific Azure OpenAI details. ```bash pip install -r requirements.txt cp .env.example .env # then edit values (skip if .env already exists) export FOUNDRY_PROJECT_ENDPOINT="https://your-project.services.ai.azure.com/api/projects/your-project" export AZURE_AI_MODEL_DEPLOYMENT_NAME="gpt-5.4-mini" python main.py ``` -------------------------------- ### Install Dependencies Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/typescript/enterprise-agent-tutorial/1-idea-to-prototype/README.md Installs project dependencies using npm. Ensure Node.js 20.0.0 or later is installed. ```bash npm install ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/infrastructure/infrastructure-setup-bicep/19-private-network-agent-tools/tests/TESTING-GUIDE.md Installs the required Python packages for running agent tests. Ensure you have Python and pip installed. ```bash pip install azure-ai-projects azure-identity openai ``` -------------------------------- ### Navigate to Sample Directory Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/csharp/hosted-agents/agent-framework/README.md Navigate to the specific sample directory you want to explore. ```bash cd hello-world ``` -------------------------------- ### Install Foundry CLI Extension Bundle Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/agent-framework/responses/04-foundry-toolbox/README.md Installs the unified Foundry CLI extension bundle. Uninstall individual extensions if previously installed. ```bash # If you previously installed individual extensions, uninstall them first: # azd ext uninstall azure.ai.agents # azd ext uninstall azure.ai.toolboxes azd ext install microsoft.foundry ``` -------------------------------- ### Install Dependencies Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/javascript/foundry-local/live-audio-transcription/README.md Install the necessary Node.js packages for the project. ```bash npm install ``` -------------------------------- ### Install Unified Foundry CLI Extension Bundle Source: https://github.com/microsoft-foundry/foundry-samples/blob/main/samples/python/hosted-agents/bring-your-own/responses/bring-your-own-toolbox/README.md Install the unified Foundry CLI extension bundle using `azd ext install`. This bundle includes `azd ai agent`, `connection`, `inspector`, `project`, `routine`, `skill`, and `toolbox`. Uninstall individual extensions first if they were previously installed. ```bash # If you previously installed individual extensions, uninstall them first: # azd ext uninstall azure.ai.agents # azd ext uninstall azure.ai.toolboxes # Install the unified bundle (provides azd ai agent, connection, inspector, # project, routine, skill, and toolbox). azd ext install microsoft.foundry ```