### Install Dependencies and Run Web Demo Source: https://developers.openai.com/cookbook/examples/building_w_rt_mini/building_w_rt_mini Installs necessary dependencies and starts the Realtime Agents Next.js web demo. ```bash npm install @openai/agents zod@3 pnpm examples:realtime-next ``` -------------------------------- ### Install and Start Supabase Local Backend Source: https://developers.openai.com/cookbook/examples/voice_solutions/running_realtime_api_speech_on_esp32_arduino_edge_runtime_elatoai Installs the Supabase CLI and starts a local Supabase server with default migrations and seed data. ```bash brew install supabase/tap/supabase supabase start # Starts your local Supabase server with the default migrations and seed data. ``` -------------------------------- ### windowsSandbox/setupStart Source: https://developers.openai.com/codex/app-server Start Windows sandbox setup for `elevated` or `unelevated` mode; returns quickly and later emits `windowsSandbox/setupCompleted`. ```APIDOC ## windowsSandbox/setupStart ### Description Start Windows sandbox setup for `elevated` or `unelevated` mode. ### Request Body - **mode** (string) - Required - The setup mode: `"elevated"` or `"unelevated"`. ``` -------------------------------- ### Example Output of SDK Installation Source: https://developers.openai.com/cookbook/examples/gpt-5/gpt-5_new_params_and_tools Shows the expected output after successfully installing or upgrading the OpenAI and Pandas libraries. Verify these versions or newer for compatibility. ```text openai 1.99.2 pandas 2.3.1 ``` -------------------------------- ### Install Dependencies and Run Next.js Development Server Source: https://developers.openai.com/cookbook/examples/voice_solutions/running_realtime_api_speech_on_esp32_arduino_edge_runtime_elatoai Navigates to the frontend directory, installs npm dependencies, and starts the Next.js development server. ```bash cd frontend-nextjs npm install # Run the development server npm run dev ``` -------------------------------- ### Install or Upgrade Dependencies Source: https://developers.openai.com/cookbook/examples/context_summarization_with_realtime_api Installs or upgrades the necessary Python packages for the Realtime API example. Run this once to ensure all dependencies are met. ```python # Run once to install or upgrade dependencies (comment out if already installed) # !pip install --upgrade openai websockets sounddevice simpleaudio ``` -------------------------------- ### Example Goal: Prototype Creation Source: https://developers.openai.com/codex/use-cases/follow-goals An example of using `/goal` to guide Codex in creating a prototype based on a `PLAN.md` file, with testing and verification. ```CLI /goal Implement PLAN.md, creating tests for each milestone and verifying the output with playwright interactive. [include reference screens as needed] ``` -------------------------------- ### Start React Chat UI Development Server Source: https://developers.openai.com/cookbook/examples/mcp/databricks_mcp_cookbook Instructions to navigate to the UI directory, install dependencies, and start the development server for the React chat application. ```bash cd ui npm install npm run dev ``` -------------------------------- ### Install dependencies and tools with setup scripts Source: https://developers.openai.com/codex/cloud/environments Use setup scripts to install specific tools like type checkers and to manage project dependencies using package managers like poetry, pnpm, or pip. Ensure environment variables are configured in settings or ~/.bashrc to persist across agent phases. ```bash # Install type checker pip install pyright # Install dependencies poetry install --with test pnpm install ``` -------------------------------- ### Form Upload and Server Start Output Source: https://developers.openai.com/cookbook/examples/agents_sdk/computer_use_with_daytona/computer_use_with_daytona Example output confirming the successful upload of the form and the start of the HTTP server within the sandbox. ```text Form uploaded to /home/daytona/form/index.html HTTP server started on port 8080 ``` -------------------------------- ### Install Dependencies and Build TypeScript Project Source: https://developers.openai.com/codex/app/local-environments Use this setup script to install dependencies and perform an initial build for a TypeScript project when a new worktree is created. ```bash npm install npm run build ``` -------------------------------- ### Install Required Python Packages Source: https://developers.openai.com/cookbook/examples/fine-tuned_qa/reinforcement_finetuning_healthbench Install the necessary Python libraries, including `openai`, `evals`, `matplotlib`, `tqdm`, and `rich`, for running the fine-tuning example. ```python %pip install openai evals matplotlib tqdm rich --upgrade --quiet ``` -------------------------------- ### JavaScript Repo Example Execution Command Source: https://developers.openai.com/blog/skills-agents-sdk This command is used in the JavaScript repository to start all examples in auto mode, supporting per-example logging and rerun functionality. ```bash pnpm examples:start-all ``` -------------------------------- ### Clone OpenAI Agents JS Repository Source: https://developers.openai.com/cookbook/examples/building_w_rt_mini/building_w_rt_mini Clones the `openai-agents-js` repository to get started with the example application. ```bash git clone https://github.com/openai/openai-agents-js/tree/main ``` -------------------------------- ### Run LiveKit Realtime Translation Demo Source: https://developers.openai.com/cookbook/examples/voice_solutions/realtime_translation_guide Commands to navigate to the demo project, install dependencies, and start the development server for the LiveKit real-time translation example. ```Shell cd examples/voice_solutions/realtime_translation_guide/livekit-translation-demo pnpm install pnpm dev ``` -------------------------------- ### Get OpenAI SDK File Path in Python Source: https://developers.openai.com/cookbook/examples/evaluation/use-cases/responses-evaluation Retrieves the file path of the installed OpenAI SDK using the `os` module, useful for locating example code or internal files within the SDK. ```python openai_sdk_file_path = os.path.dirname(openai.__file__) ``` -------------------------------- ### Setup Paths and Directories Source: https://developers.openai.com/cookbook/examples/codex/build_iterative_repair_loops_with_codex Configures necessary paths for example directories and temporary run outputs. It also includes error handling for missing data directories and ensures the runs directory is created. ```python import concurrent.futures import json import os import shlex import shutil import subprocess import tempfile from pathlib import Path from typing import Any CANDIDATE_EXAMPLE_DIRS = [Path("."), Path("examples/codex")] EXAMPLE_DIR = next((base for base in CANDIDATE_EXAMPLE_DIRS if (base / "data" / "docs").exists()), None) if EXAMPLE_DIR is None: raise RuntimeError( "This notebook needs its companion sample notebooks. " "Download the data folder that ships with this example and place it next to " "this notebook as ./data/docs, or run from a checkout where examples/codex/data/docs exists." ) DATA_DIR = EXAMPLE_DIR / "data" / "docs" DEFAULT_RUNS_DIR = Path(tempfile.gettempdir()) / "codex_iterative_repair_loop_outputs" RUNS_DIR = Path(os.getenv("CODEX_REPAIR_RUNS_DIR", str(DEFAULT_RUNS_DIR))).expanduser() RUNS_DIR.mkdir(parents=True, exist_ok=True) ``` -------------------------------- ### windowsSandbox/setupStart Source: https://developers.openai.com/codex/app-server Triggers the asynchronous setup process for the Windows sandbox, allowing custom clients to avoid blocking on startup checks. ```APIDOC ## windowsSandbox/setupStart ### Description Triggers the asynchronous setup process for the Windows sandbox, allowing custom clients to avoid blocking on startup checks. ### Method windowsSandbox/setupStart ### Parameters #### Request Body - **mode** (string) - Required - The setup mode to run. Can be `elevated` (run elevated setup path) or `unelevated` (run legacy setup/preflight path). ### Request Example { "method": "windowsSandbox/setupStart", "id": 53, "params": { "mode": "elevated" } } ### Response #### Success Response (200) - **started** (boolean) - Indicates if the setup process has successfully started. #### Response Example { "id": 53, "result": { "started": true } } ``` -------------------------------- ### Example: Add Context7 MCP Server via CLI Source: https://developers.openai.com/codex/mcp This example demonstrates adding the Context7 MCP server, a free server for developer documentation, using `npx`. ```bash codex mcp add context7 -- npx -y @upstash/context7-mcp ``` -------------------------------- ### Install Python Dependencies Source: https://developers.openai.com/cookbook/examples/agents_sdk/agent_improvement_loop Installs the necessary Python packages for the agent improvement loop example. Ensure you have Node.js and npx installed for Promptfoo. ```bash python -m venv .venv source .venv/bin/activate pip install openai openai-agents halo-engine ``` -------------------------------- ### Example Output: Vector Store Creation and Upload Start Source: https://developers.openai.com/cookbook/examples/file_search_responses Shows the console output after successfully creating a vector store and before the parallel PDF upload process begins, including the store ID and initial file count. ```text Vector store created: {'id': 'vs_67d06b9b9a9c8191bafd456cf2364ce3', 'name': 'openai_blog_store', 'created_at': 1741712283, 'file_count': 0} 21 PDF files to process. Uploading in parallel... ``` -------------------------------- ### Install Python Dependencies Source: https://developers.openai.com/cookbook/examples/agents_sdk/computer_use_with_daytona/computer_use_with_daytona Install the required Python packages listed in the requirements.txt file for this example using pip. ```bash %pip install -r requirements.txt --quiet ``` -------------------------------- ### Install Required Python Dependencies Source: https://developers.openai.com/cookbook/examples/multimodal/document_and_multimodal_understanding_tips Installs or upgrades the `openai` and `pillow` Python packages, necessary for running the notebook examples. ```bash pip install --upgrade openai pillow ``` -------------------------------- ### Setup and Configuration Source: https://developers.openai.com/cookbook/examples/agents_sdk/agent_improvement_loop Initializes the OpenAI client, sets up artifact directories, and defines model configurations. Ensures API keys and necessary tools are available. ```python from __future__ import annotations import asyncio import hashlib import json import os import re import shutil import subprocess import sys import tempfile import time import textwrap import threading from contextlib import contextmanager from dataclasses import asdict, dataclass, field from datetime import datetime, timezone from importlib.metadata import version from pathlib import Path from typing import Any, Iterable, Iterator, Mapping from IPython.display import Markdown, display from openai import OpenAI def find_project_root(start: Path | None = None) -> Path: current = (start or Path.cwd()).resolve() for candidate in [current, *current.parents]: if (candidate / "registry.yaml").exists(): return candidate return current PROJECT_ROOT = find_project_root() if not os.getenv("OPENAI_API_KEY"): raise RuntimeError("Set OPENAI_API_KEY before running this live notebook.") if shutil.which("npx") is None: raise RuntimeError("Install Node.js with npx before running the Promptfoo eval gate.") # Edit these in one place if you want to use lower-cost models for part of the loop. AGENT_MODEL = os.getenv("OPENAI_AGENT_MODEL", "gpt-5.5") ANALYSIS_MODEL = os.getenv("OPENAI_ANALYSIS_MODEL", "gpt-5.5") EVAL_GENERATION_MODEL = os.getenv("OPENAI_EVAL_GENERATION_MODEL", ANALYSIS_MODEL) JUDGE_MODEL = os.getenv("OPENAI_JUDGE_MODEL", ANALYSIS_MODEL) HALO_MODEL = os.getenv("OPENAI_HALO_MODEL", ANALYSIS_MODEL) PROMPTFOO_VERSION = os.getenv("PROMPTFOO_VERSION", "0.121.9") client = OpenAI() def format_duration(seconds: float) -> str: minutes, remainder = divmod(int(round(seconds)), 60) return f"{minutes}m {remainder:02d}s" if minutes else f"{remainder}s" ARTIFACT_DIR = PROJECT_ROOT / "examples" / "agents_sdk" / "agent_improvement_loop_artifacts" TRACE_DIR = ARTIFACT_DIR / "traces" HALO_TRACE_PATH = ARTIFACT_DIR / "halo_traces" / "traces.jsonl" if ARTIFACT_DIR.exists(): shutil.rmtree(ARTIFACT_DIR) ARTIFACT_DIR.mkdir(exist_ok=True) TRACE_DIR.mkdir(exist_ok=True) HALO_TRACE_PATH.parent.mkdir(exist_ok=True) print("Project root detected.") print("Models:", { "agent": AGENT_MODEL, "analysis": ANALYSIS_MODEL, "eval_generation": EVAL_GENERATION_MODEL, "judge": JUDGE_MODEL, "halo": HALO_MODEL, "promptfoo": PROMPTFOO_VERSION, }) ``` ```text Project root detected. Models: {'agent': 'gpt-5.5', 'analysis': 'gpt-5.5', 'eval_generation': 'gpt-5.5', 'judge': 'gpt-5.5', 'halo': 'gpt-5.5', 'promptfoo': '0.121.9'} ``` -------------------------------- ### Install OpenAI Library and Initialize Client Source: https://developers.openai.com/cookbook/examples/structured_outputs_intro Install the necessary Python library and set up the OpenAI client with the specified model for API calls. ```bash %pip install openai -U ``` ```python import json from textwrap import dedent from openai import OpenAI client = OpenAI() ``` ```python MODEL = "gpt-4o-2024-08-06" ``` -------------------------------- ### Install or Update Codex using Homebrew Source: https://developers.openai.com/cookbook/examples/codex/using_goals_in_codex Use these commands to install or update the Codex CLI via Homebrew and verify the installed version. Goals are available starting in Codex 0.128.0. ```bash brew update brew upgrade --cask codex codex --version ``` -------------------------------- ### Initiate Windows Sandbox Setup with windowsSandbox/setupStart (JSON-RPC) Source: https://developers.openai.com/codex/app-server Asynchronously trigger the Windows sandbox setup process, specifying the desired mode. A "windowsSandbox/setupCompleted" notification will be emitted upon completion. ```json { "method": "windowsSandbox/setupStart", "id": 53, "params": { "mode": "elevated" } } { "id": 53, "result": { "started": true } } ``` ```json { "method": "windowsSandbox/setupCompleted", "params": { "mode": "elevated", "success": true, "error": null } } ``` -------------------------------- ### Install or Update Codex using npm Source: https://developers.openai.com/cookbook/examples/codex/using_goals_in_codex Use these commands to install or update the Codex CLI globally via npm and verify the installed version. Goals are available starting in Codex 0.128.0. ```bash npm install -g @openai/codex@latest codex --version ``` -------------------------------- ### Example `evals/setup-demo-app.prompts.csv` for Skill Evaluation Source: https://developers.openai.com/blog/eval-skills This CSV defines a small set of prompts for evaluating the `setup-demo-app` skill, including cases for explicit, implicit, contextual invocation, and a negative control to catch false positives. ```csv id,should_trigger,prompt test-01,true,"Create a demo app named `devday-demo` using the $setup-demo-app skill" test-02,true,"Set up a minimal React demo app with Tailwind for quick UI experiments" test-03,true,"Create a small demo app to showcase the Responses API" test-04,false,"Add Tailwind styling to my existing React app" ``` -------------------------------- ### Set up working directory and API key Source: https://developers.openai.com/codex/guides/agents-sdk Create a new project directory and securely store your OpenAI API key in a `.env` file for local development. ```bash mkdir codex-workflows cd codex-workflows printf "OPENAI_API_KEY=sk-..." > .env ``` -------------------------------- ### Prompt Guidelines and Examples for Reservation Tool Source: https://developers.openai.com/cookbook/examples/gpt-5/gpt-5-1_prompting_guide This snippet provides prompt instructions for using the `create_reservation` tool, including when to call it, how to handle missing information, and example interactions demonstrating tool calls and assistant responses. ```text - When the user asks to book, reserve, or schedule a table, you MUST call `create_reservation`. - Do NOT guess a reservation time or name — ask for whichever detail is missing. - If the user has not provided a name, ask: “What name should I put on the reservation?” - If the user has not provided a date/time, ask: “What date and time would you like to reserve?” - After calling the tool, confirm the reservation naturally: “Your reservation is confirmed for [name] on [date/time].” *Example 1:* User: “Book a table for Sarah tomorrow at 7pm.” Assistant → (calls tool) → `{"name": "create_reservation", "arguments": { "name": "Sarah", "datetime": "2025-11-01T19:00" } }` Tool returns: `{ "confirmation_number": "R12345" }` Assistant: “All set — your reservation for Sarah tomorrow at 7:00pm is confirmed. Your confirmation number is R12345.” **Example 2:** User: “I want to make a reservation.” Assistant: “Sure! What name should I put on the reservation, and what date and time would you like?” *Example 3:* User: “Reserve a table under Daniel at 6 tonight.” Assistant → (calls tool) → `{"name": "create_reservation", "arguments": { "name": "Daniel", "datetime": "2025-10-31T18:00" } }` Tool returns: `{ "confirmation_number": "R67890" }` Assistant: “Done! Your reservation for Daniel at 6:00pm tonight is confirmed. The confirmation number is R67890.” ``` -------------------------------- ### Install Required Python Packages Source: https://developers.openai.com/cookbook/examples/vector_databases/tair/getting_started_with_tair_and_openai Install the necessary Python libraries, including openai, redis, tair, pandas, and wget, to run the examples in this notebook. ```bash ! pip install openai redis tair pandas wget ``` -------------------------------- ### Install Python Libraries for Speech Transcription Source: https://developers.openai.com/cookbook/examples/speech_transcription_methods Installs required packages like `openai`, `websockets`, and audio processing tools to run the speech-to-text examples. ```bash !pip install --upgrade -q openai openai-agents websockets sounddevice pyaudio nest_asyncio resampy httpx websocket-client ``` -------------------------------- ### Initialize shadcn/ui Project Source: https://developers.openai.com/cookbook/examples/build_a_coding_agent_with_gpt-5.1 Initializes shadcn/ui in the current project, setting up configuration files. ```bash npx shadcn@latest init ``` -------------------------------- ### Install Node SDK and MCP Apps Helpers Source: https://developers.openai.com/apps-sdk/quickstart Use this command to install the necessary Node SDK, MCP Apps helpers, and Zod for building an MCP server. ```bash npm install @modelcontextprotocol/sdk @modelcontextprotocol/ext-apps zod ```