Title: Web search | OpenAI API URL Source: https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat Markdown Content: Web search | OpenAI API =============== Image 1: OpenAI Developers (https://platform.openai.com/) Home (https://platform.openai.com/) API (https://platform.openai.com/api) Docs Guides and concepts for the OpenAI API (https://platform.openai.com/api/docs)API reference Endpoints, parameters, and responses (https://platform.openai.com/api/reference/overview) Codex (https://platform.openai.com/codex) ChatGPT (https://platform.openai.com/chatgpt) Apps SDK Build apps to extend ChatGPT (https://platform.openai.com/apps-sdk)Commerce Build commerce flows in ChatGPT (https://platform.openai.com/commerce) Learn (https://platform.openai.com/resources) Resources Assets for developers building with OpenAI (https://platform.openai.com/resources)Cookbook Notebook examples for building with OpenAI models (https://platform.openai.com/cookbook)Blog Learnings and experiences from developers (https://platform.openai.com/blog) API Dashboard (https://platform.openai.com/login) Search the API docs ------------------- Close Primary navigation API API Reference Codex ChatGPT Learn ### Get started - Overview (https://platform.openai.com/api/docs) - Quickstart (https://platform.openai.com/api/docs/quickstart) - Models (https://platform.openai.com/api/docs/models) - Pricing (https://platform.openai.com/api/docs/pricing) - Libraries (https://platform.openai.com/api/docs/libraries) - Latest: GPT-5.2 (https://platform.openai.com/api/docs/guides/latest-model) ### Core concepts - Text generation (https://platform.openai.com/api/docs/guides/text) - Code generation (https://platform.openai.com/api/docs/guides/code-generation) - Images and vision (https://platform.openai.com/api/docs/guides/images-vision) - Audio and speech (https://platform.openai.com/api/docs/guides/audio) - Structured output (https://platform.openai.com/api/docs/guides/structured-outputs) - Function calling (https://platform.openai.com/api/docs/guides/function-calling) - Responses API (https://platform.openai.com/api/docs/guides/migrate-to-responses) ### Agents - Overview (https://platform.openai.com/api/docs/guides/agents) - Build agents - Agent Builder (https://platform.openai.com/api/docs/guides/agent-builder) - Node reference (https://platform.openai.com/api/docs/guides/node-reference) - Safety in building agents (https://platform.openai.com/api/docs/guides/agent-builder-safety) - Agents SDK (https://platform.openai.com/api/docs/guides/agents-sdk) - Deploy in your product - ChatKit (https://platform.openai.com/api/docs/guides/chatkit) - Custom theming (https://platform.openai.com/api/docs/guides/chatkit-themes) - Widgets (https://platform.openai.com/api/docs/guides/chatkit-widgets) - Actions (https://platform.openai.com/api/docs/guides/chatkit-actions) - Advanced integration (https://platform.openai.com/api/docs/guides/custom-chatkit) - Optimize - Agent evals (https://platform.openai.com/api/docs/guides/agent-evals) - Trace grading (https://platform.openai.com/api/docs/guides/trace-grading) - Voice agents (https://platform.openai.com/api/docs/guides/voice-agents) ### Tools - Using tools (https://platform.openai.com/api/docs/guides/tools) - Connectors and MCP (https://platform.openai.com/api/docs/guides/tools-connectors-mcp) - Skills (https://platform.openai.com/api/docs/guides/tools-skills) - Shell (https://platform.openai.com/api/docs/guides/tools-shell) - Web search (https://platform.openai.com/api/docs/guides/tools-web-search) - Code interpreter (https://platform.openai.com/api/docs/guides/tools-code-interpreter) - File search and retrieval - File search (https://platform.openai.com/api/docs/guides/tools-file-search) - Retrieval (https://platform.openai.com/api/docs/guides/retrieval) - More tools - Image generation (https://platform.openai.com/api/docs/guides/tools-image-generation) - Computer use (https://platform.openai.com/api/docs/guides/tools-computer-use) - Local shell tool (https://platform.openai.com/api/docs/guides/tools-local-shell) - Apply patch (https://platform.openai.com/api/docs/guides/tools-apply-patch) ### Run and scale - Conversation state (https://platform.openai.com/api/docs/guides/conversation-state) - Background mode (https://platform.openai.com/api/docs/guides/background) - Streaming (https://platform.openai.com/api/docs/guides/streaming-responses) - WebSocket mode (https://platform.openai.com/api/docs/guides/websocket-mode) - Webhooks (https://platform.openai.com/api/docs/guides/webhooks) - File inputs (https://platform.openai.com/api/docs/guides/file-inputs) - Context management - Compaction (https://platform.openai.com/api/docs/guides/compaction) - Counting tokens (https://platform.openai.com/api/docs/guides/token-counting) - Prompt caching (https://platform.openai.com/api/docs/guides/prompt-caching) - Prompting - Overview (https://platform.openai.com/api/docs/guides/prompting) - Prompt engineering (https://platform.openai.com/api/docs/guides/prompt-engineering) - Reasoning - Reasoning models (https://platform.openai.com/api/docs/guides/reasoning) - Reasoning best practices (https://platform.openai.com/api/docs/guides/reasoning-best-practices) ### Evaluation - Getting started (https://platform.openai.com/api/docs/guides/evaluation-getting-started) - Working with evals (https://platform.openai.com/api/docs/guides/evals) - Prompt optimizer (https://platform.openai.com/api/docs/guides/prompt-optimizer) - External models (https://platform.openai.com/api/docs/guides/external-models) - Best practices (https://platform.openai.com/api/docs/guides/evaluation-best-practices) ### Realtime API - Overview (https://platform.openai.com/api/docs/guides/realtime) - Connect - WebRTC (https://platform.openai.com/api/docs/guides/realtime-webrtc) - WebSocket (https://platform.openai.com/api/docs/guides/realtime-websocket) - SIP (https://platform.openai.com/api/docs/guides/realtime-sip) - Usage - Using realtime models (https://platform.openai.com/api/docs/guides/realtime-models-prompting) - Managing conversations (https://platform.openai.com/api/docs/guides/realtime-conversations) - Webhooks and server-side controls (https://platform.openai.com/api/docs/guides/realtime-server-controls) - Managing costs (https://platform.openai.com/api/docs/guides/realtime-costs) - Realtime transcription (https://platform.openai.com/api/docs/guides/realtime-transcription) - Voice agents (https://openai.github.io/openai-agents-js/guides/voice-agents/quickstart/) ### Model optimization - Optimization cycle (https://platform.openai.com/api/docs/guides/model-optimization) - Fine-tuning - Supervised fine-tuning (https://platform.openai.com/api/docs/guides/supervised-fine-tuning) - Vision fine-tuning (https://platform.openai.com/api/docs/guides/vision-fine-tuning) - Direct preference optimization (https://platform.openai.com/api/docs/guides/direct-preference-optimization) - Reinforcement fine-tuning (https://platform.openai.com/api/docs/guides/reinforcement-fine-tuning) - RFT use cases (https://platform.openai.com/api/docs/guides/rft-use-cases) - Best practices (https://platform.openai.com/api/docs/guides/fine-tuning-best-practices) - Graders (https://platform.openai.com/api/docs/guides/graders) ### Specialized models - Image generation (https://platform.openai.com/api/docs/guides/image-generation) - Video generation (https://platform.openai.com/api/docs/guides/video-generation) - Text to speech (https://platform.openai.com/api/docs/guides/text-to-speech) - Speech to text (https://platform.openai.com/api/docs/guides/speech-to-text) - Deep research (https://platform.openai.com/api/docs/guides/deep-research) - Embeddings (https://platform.openai.com/api/docs/guides/embeddings) - Moderation (https://platform.openai.com/api/docs/guides/moderation) ### Going live - Production best practices (https://platform.openai.com/api/docs/guides/production-best-practices) - Latency optimization - Overview (https://platform.openai.com/api/docs/guides/latency-optimization) - Predicted Outputs (https://platform.openai.com/api/docs/guides/predicted-outputs) - Priority processing (https://platform.openai.com/api/docs/guides/priority-processing) - Cost optimization - Overview (https://platform.openai.com/api/docs/guides/cost-optimization) - Batch (https://platform.openai.com/api/docs/guides/batch) - Flex processing (https://platform.openai.com/api/docs/guides/flex-processing) - Accuracy optimization (https://platform.openai.com/api/docs/guides/optimizing-llm-accuracy) - Safety - Safety best practices (https://platform.openai.com/api/docs/guides/safety-best-practices) - Safety checks (https://platform.openai.com/api/docs/guides/safety-checks) - Cybersecurity checks (https://platform.openai.com/api/docs/guides/safety-checks/cybersecurity) - Under 18 API Guidance (https://platform.openai.com/api/docs/guides/safety-checks/under-18-api-guidance) ### Legacy APIs - Assistants API - Migration guide (https://platform.openai.com/api/docs/assistants/migration) - Deep dive (https://platform.openai.com/api/docs/assistants/deep-dive) - Tools (https://platform.openai.com/api/docs/assistants/tools) ### Resources - Terms and policies (https://openai.com/policies) - Changelog (https://platform.openai.com/api/docs/changelog) - Your data (https://platform.openai.com/api/docs/guides/your-data) - Permissions (https://platform.openai.com/api/docs/guides/rbac) - Rate limits (https://platform.openai.com/api/docs/guides/rate-limits) - Deprecations (https://platform.openai.com/api/docs/deprecations) - MCP for deep research (https://platform.openai.com/api/docs/mcp) - Developer mode (https://platform.openai.com/api/docs/guides/developer-mode) - ChatGPT Actions - Introduction (https://platform.openai.com/api/docs/actions/introduction) - Getting started (https://platform.openai.com/api/docs/actions/getting-started) - Actions library (https://platform.openai.com/api/docs/actions/actions-library) - Authentication (https://platform.openai.com/api/docs/actions/authentication) - Production (https://platform.openai.com/api/docs/actions/production) - Data retrieval (https://platform.openai.com/api/docs/actions/data-retrieval) - Sending files (https://platform.openai.com/api/docs/actions/sending-files) ### Getting Started - Overview (https://platform.openai.com/codex) - Quickstart (https://platform.openai.com/codex/quickstart) - Explore (https://platform.openai.com/codex/explore) - Pricing (https://platform.openai.com/codex/pricing) - Concepts - Prompting (https://platform.openai.com/codex/prompting) - Customization (https://platform.openai.com/codex/concepts/customization) - Multi-agents (https://platform.openai.com/codex/concepts/multi-agents) - Workflows (https://platform.openai.com/codex/workflows) - Models (https://platform.openai.com/codex/models) - Cyber Safety (https://platform.openai.com/codex/concepts/cyber-safety) ### Using Codex - App - Overview (https://platform.openai.com/codex/app) - Features (https://platform.openai.com/codex/app/features) - Settings (https://platform.openai.com/codex/app/settings) - Review (https://platform.openai.com/codex/app/review) - Automations (https://platform.openai.com/codex/app/automations) - Worktrees (https://platform.openai.com/codex/app/worktrees) - Local Environments (https://platform.openai.com/codex/app/local-environments) - Commands (https://platform.openai.com/codex/app/commands) - Troubleshooting (https://platform.openai.com/codex/app/troubleshooting) - IDE Extension - Overview (https://platform.openai.com/codex/ide) - Features (https://platform.openai.com/codex/ide/features) - Settings (https://platform.openai.com/codex/ide/settings) - IDE Commands (https://platform.openai.com/codex/ide/commands) - Slash commands (https://platform.openai.com/codex/ide/slash-commands) - CLI - Overview (https://platform.openai.com/codex/cli) - Features (https://platform.openai.com/codex/cli/features) - Command Line Options (https://platform.openai.com/codex/cli/reference) - Slash commands (https://platform.openai.com/codex/cli/slash-commands) - Web - Overview (https://platform.openai.com/codex/cloud) - Environments (https://platform.openai.com/codex/cloud/environments) - Internet Access (https://platform.openai.com/codex/cloud/internet-access) - Integrations - GitHub (https://platform.openai.com/codex/integrations/github) - Slack (https://platform.openai.com/codex/integrations/slack) - Linear (https://platform.openai.com/codex/integrations/linear) ### Configuration - Config File - Config Basics (https://platform.openai.com/codex/config-basic) - Advanced Config (https://platform.openai.com/codex/config-advanced) - Config Reference (https://platform.openai.com/codex/config-reference) - Sample Config (https://platform.openai.com/codex/config-sample) - Rules (https://platform.openai.com/codex/rules) - AGENTS.md (https://platform.openai.com/codex/guides/agents-md) - MCP (https://platform.openai.com/codex/mcp) - Skills (https://platform.openai.com/codex/skills) - Multi-agents (https://platform.openai.com/codex/multi-agent) ### Administration - Authentication (https://platform.openai.com/codex/auth) - Security (https://platform.openai.com/codex/security) - Enterprise - Admin Setup (https://platform.openai.com/codex/enterprise/admin-setup) - Governance (https://platform.openai.com/codex/enterprise/governance) - Managed configuration (https://platform.openai.com/codex/enterprise/managed-configuration) - Windows (https://platform.openai.com/codex/windows) ### Automation - Non-interactive Mode (https://platform.openai.com/codex/noninteractive) - Codex SDK (https://platform.openai.com/codex/sdk) - App Server (https://platform.openai.com/codex/app-server) - MCP Server (https://platform.openai.com/codex/guides/agents-sdk) - GitHub Action (https://platform.openai.com/codex/github-action) ### Learn - Videos (https://platform.openai.com/codex/videos) - Blog - Building frontend UIs with Codex and Figma (https://platform.openai.com/blog/building-frontend-uis-with-codex-and-figma) - Run long horizon tasks with Codex (https://platform.openai.com/blog/run-long-horizon-tasks-with-codex) - View all (https://platform.openai.com/blog/topic/codex) - Cookbooks - Codex Prompting Guide (https://platform.openai.com/cookbook/examples/gpt-5/codex_prompting_guide) - Long horizon tasks with Codex (https://platform.openai.com/cookbook/examples/codex/long_horizon_tasks) - View all (https://platform.openai.com/cookbook/topic/codex) - Building AI Teams (https://platform.openai.com/codex/guides/build-ai-native-engineering-team) ### Community - Ambassadors (https://platform.openai.com/codex/ambassadors) - Meetups (https://platform.openai.com/codex/community/meetups) ### Releases - Changelog (https://platform.openai.com/codex/changelog) - Feature Maturity (https://platform.openai.com/codex/feature-maturity) - Open Source (https://platform.openai.com/codex/open-source) Apps SDK Commerce - Home (https://platform.openai.com/apps-sdk) - Quickstart (https://platform.openai.com/apps-sdk/quickstart) ### Core Concepts - MCP Apps in ChatGPT (https://platform.openai.com/apps-sdk/mcp-apps-in-chatgpt) - MCP Server (https://platform.openai.com/apps-sdk/concepts/mcp-server) - UX principles (https://platform.openai.com/apps-sdk/concepts/ux-principles) - UI guidelines (https://platform.openai.com/apps-sdk/concepts/ui-guidelines) ### Plan - Research use cases (https://platform.openai.com/apps-sdk/plan/use-case) - Define tools (https://platform.openai.com/apps-sdk/plan/tools) - Design components (https://platform.openai.com/apps-sdk/plan/components) ### Build - Set up your server (https://platform.openai.com/apps-sdk/build/mcp-server) - Build your ChatGPT UI (https://platform.openai.com/apps-sdk/build/chatgpt-ui) - Authenticate users (https://platform.openai.com/apps-sdk/build/auth) - Manage state (https://platform.openai.com/apps-sdk/build/state-management) - Monetize your app (https://platform.openai.com/apps-sdk/build/monetization) - Examples (https://platform.openai.com/apps-sdk/build/examples) ### Deploy - Deploy your app (https://platform.openai.com/apps-sdk/deploy) - Connect from ChatGPT (https://platform.openai.com/apps-sdk/deploy/connect-chatgpt) - Test your integration (https://platform.openai.com/apps-sdk/deploy/testing) - Submit your app (https://platform.openai.com/apps-sdk/deploy/submission) ### Guides - Optimize Metadata (https://platform.openai.com/apps-sdk/guides/optimize-metadata) - Security & Privacy (https://platform.openai.com/apps-sdk/guides/security-privacy) - Troubleshooting (https://platform.openai.com/apps-sdk/deploy/troubleshooting) ### Resources - Changelog (https://platform.openai.com/apps-sdk/changelog) - App submission guidelines (https://platform.openai.com/apps-sdk/app-submission-guidelines) - Reference (https://platform.openai.com/apps-sdk/reference) - Home (https://platform.openai.com/commerce) ### Guides - Get started (https://platform.openai.com/commerce/guides/get-started) - Key concepts (https://platform.openai.com/commerce/guides/key-concepts) - Production readiness (https://platform.openai.com/commerce/guides/production) ### Commerce specs - Agentic Checkout (https://platform.openai.com/commerce/specs/checkout) - Delegated Payment (https://platform.openai.com/commerce/specs/payment) ### Product feeds - Overview (https://platform.openai.com/commerce/product-feeds) - Onboarding (https://platform.openai.com/commerce/product-feeds/onboarding) - Feed spec (https://platform.openai.com/commerce/product-feeds/spec) - Best practices (https://platform.openai.com/commerce/product-feeds/best-practices) Resources Cookbook Blog - Home (https://platform.openai.com/resources) - Docs MCP (https://platform.openai.com/resources/docs-mcp) ### Categories - Code (https://platform.openai.com/resources/code) - Cookbooks (https://platform.openai.com/cookbook) - Guides (https://platform.openai.com/resources/guides) - Videos (https://platform.openai.com/resources/videos) ### Topics - Agents (https://platform.openai.com/resources/agents) - Audio & Voice (https://platform.openai.com/resources/audio) - Computer use (https://platform.openai.com/resources/cua) - Codex (https://platform.openai.com/resources/codex) - Evals (https://platform.openai.com/resources/evals) - gpt-oss (https://platform.openai.com/resources/gpt-oss) - Fine-tuning (https://platform.openai.com/resources/fine-tuning) - Image generation (https://platform.openai.com/resources/imagegen) - Scaling (https://platform.openai.com/resources/scaling) - Tools (https://platform.openai.com/resources/tools) - Video generation (https://platform.openai.com/resources/videogen) - Home (https://platform.openai.com/cookbook) ### Topics - Agents (https://platform.openai.com/cookbook/topic/agents) - Evals (https://platform.openai.com/cookbook/topic/evals) - Multimodal (https://platform.openai.com/cookbook/topic/multimodal) - Text (https://platform.openai.com/cookbook/topic/text) - Guardrails (https://platform.openai.com/cookbook/topic/guardrails) - Optimization (https://platform.openai.com/cookbook/topic/optimization) - ChatGPT (https://platform.openai.com/cookbook/topic/chatgpt) - Codex (https://platform.openai.com/cookbook/topic/codex) - gpt-oss (https://platform.openai.com/cookbook/topic/gpt-oss) ### Contribute - Cookbook on GitHub (https://github.com/openai/openai-cookbook) - All posts (https://platform.openai.com/blog) ### Recent - Building frontend UIs with Codex and Figma (https://platform.openai.com/blog/building-frontend-uis-with-codex-and-figma) - Run long horizon tasks with Codex (https://platform.openai.com/blog/run-long-horizon-tasks-with-codex) - Shell + Skills + Compaction: Tips for long-running agents that do real work (https://platform.openai.com/blog/skills-shell-tips) - 15 lessons learned building ChatGPT Apps (https://platform.openai.com/blog/15-lessons-building-chatgpt-apps) - Testing Agent Skills Systematically with Evals (https://platform.openai.com/blog/eval-skills) ### Topics - General (https://platform.openai.com/blog/topic/general) - API (https://platform.openai.com/blog/topic/api) - Apps SDK (https://platform.openai.com/blog/topic/apps-sdk) - Audio (https://platform.openai.com/blog/topic/audio) - Codex (https://platform.openai.com/blog/topic/codex) API Dashboard (https://platform.openai.com/login) Search ⌘ K ### Get started - Overview (https://platform.openai.com/api/docs) - Quickstart (https://platform.openai.com/api/docs/quickstart) - Models (https://platform.openai.com/api/docs/models) - Pricing (https://platform.openai.com/api/docs/pricing) - Libraries (https://platform.openai.com/api/docs/libraries) - Latest: GPT-5.2 (https://platform.openai.com/api/docs/guides/latest-model) ### Core concepts - Text generation (https://platform.openai.com/api/docs/guides/text) - Code generation (https://platform.openai.com/api/docs/guides/code-generation) - Images and vision (https://platform.openai.com/api/docs/guides/images-vision) - Audio and speech (https://platform.openai.com/api/docs/guides/audio) - Structured output (https://platform.openai.com/api/docs/guides/structured-outputs) - Function calling (https://platform.openai.com/api/docs/guides/function-calling) - Responses API (https://platform.openai.com/api/docs/guides/migrate-to-responses) ### Agents - Overview (https://platform.openai.com/api/docs/guides/agents) - Build agents - Agent Builder (https://platform.openai.com/api/docs/guides/agent-builder) - Node reference (https://platform.openai.com/api/docs/guides/node-reference) - Safety in building agents (https://platform.openai.com/api/docs/guides/agent-builder-safety) - Agents SDK (https://platform.openai.com/api/docs/guides/agents-sdk) - Deploy in your product - ChatKit (https://platform.openai.com/api/docs/guides/chatkit) - Custom theming (https://platform.openai.com/api/docs/guides/chatkit-themes) - Widgets (https://platform.openai.com/api/docs/guides/chatkit-widgets) - Actions (https://platform.openai.com/api/docs/guides/chatkit-actions) - Advanced integration (https://platform.openai.com/api/docs/guides/custom-chatkit) - Optimize - Agent evals (https://platform.openai.com/api/docs/guides/agent-evals) - Trace grading (https://platform.openai.com/api/docs/guides/trace-grading) - Voice agents (https://platform.openai.com/api/docs/guides/voice-agents) ### Tools - Using tools (https://platform.openai.com/api/docs/guides/tools) - Connectors and MCP (https://platform.openai.com/api/docs/guides/tools-connectors-mcp) - Skills (https://platform.openai.com/api/docs/guides/tools-skills) - Shell (https://platform.openai.com/api/docs/guides/tools-shell) - Web search (https://platform.openai.com/api/docs/guides/tools-web-search) - Code interpreter (https://platform.openai.com/api/docs/guides/tools-code-interpreter) - File search and retrieval - File search (https://platform.openai.com/api/docs/guides/tools-file-search) - Retrieval (https://platform.openai.com/api/docs/guides/retrieval) - More tools - Image generation (https://platform.openai.com/api/docs/guides/tools-image-generation) - Computer use (https://platform.openai.com/api/docs/guides/tools-computer-use) - Local shell tool (https://platform.openai.com/api/docs/guides/tools-local-shell) - Apply patch (https://platform.openai.com/api/docs/guides/tools-apply-patch) ### Run and scale - Conversation state (https://platform.openai.com/api/docs/guides/conversation-state) - Background mode (https://platform.openai.com/api/docs/guides/background) - Streaming (https://platform.openai.com/api/docs/guides/streaming-responses) - WebSocket mode (https://platform.openai.com/api/docs/guides/websocket-mode) - Webhooks (https://platform.openai.com/api/docs/guides/webhooks) - File inputs (https://platform.openai.com/api/docs/guides/file-inputs) - Context management - Compaction (https://platform.openai.com/api/docs/guides/compaction) - Counting tokens (https://platform.openai.com/api/docs/guides/token-counting) - Prompt caching (https://platform.openai.com/api/docs/guides/prompt-caching) - Prompting - Overview (https://platform.openai.com/api/docs/guides/prompting) - Prompt engineering (https://platform.openai.com/api/docs/guides/prompt-engineering) - Reasoning - Reasoning models (https://platform.openai.com/api/docs/guides/reasoning) - Reasoning best practices (https://platform.openai.com/api/docs/guides/reasoning-best-practices) ### Evaluation - Getting started (https://platform.openai.com/api/docs/guides/evaluation-getting-started) - Working with evals (https://platform.openai.com/api/docs/guides/evals) - Prompt optimizer (https://platform.openai.com/api/docs/guides/prompt-optimizer) - External models (https://platform.openai.com/api/docs/guides/external-models) - Best practices (https://platform.openai.com/api/docs/guides/evaluation-best-practices) ### Realtime API - Overview (https://platform.openai.com/api/docs/guides/realtime) - Connect - WebRTC (https://platform.openai.com/api/docs/guides/realtime-webrtc) - WebSocket (https://platform.openai.com/api/docs/guides/realtime-websocket) - SIP (https://platform.openai.com/api/docs/guides/realtime-sip) - Usage - Using realtime models (https://platform.openai.com/api/docs/guides/realtime-models-prompting) - Managing conversations (https://platform.openai.com/api/docs/guides/realtime-conversations) - Webhooks and server-side controls (https://platform.openai.com/api/docs/guides/realtime-server-controls) - Managing costs (https://platform.openai.com/api/docs/guides/realtime-costs) - Realtime transcription (https://platform.openai.com/api/docs/guides/realtime-transcription) - Voice agents (https://openai.github.io/openai-agents-js/guides/voice-agents/quickstart/) ### Model optimization - Optimization cycle (https://platform.openai.com/api/docs/guides/model-optimization) - Fine-tuning - Supervised fine-tuning (https://platform.openai.com/api/docs/guides/supervised-fine-tuning) - Vision fine-tuning (https://platform.openai.com/api/docs/guides/vision-fine-tuning) - Direct preference optimization (https://platform.openai.com/api/docs/guides/direct-preference-optimization) - Reinforcement fine-tuning (https://platform.openai.com/api/docs/guides/reinforcement-fine-tuning) - RFT use cases (https://platform.openai.com/api/docs/guides/rft-use-cases) - Best practices (https://platform.openai.com/api/docs/guides/fine-tuning-best-practices) - Graders (https://platform.openai.com/api/docs/guides/graders) ### Specialized models - Image generation (https://platform.openai.com/api/docs/guides/image-generation) - Video generation (https://platform.openai.com/api/docs/guides/video-generation) - Text to speech (https://platform.openai.com/api/docs/guides/text-to-speech) - Speech to text (https://platform.openai.com/api/docs/guides/speech-to-text) - Deep research (https://platform.openai.com/api/docs/guides/deep-research) - Embeddings (https://platform.openai.com/api/docs/guides/embeddings) - Moderation (https://platform.openai.com/api/docs/guides/moderation) ### Going live - Production best practices (https://platform.openai.com/api/docs/guides/production-best-practices) - Latency optimization - Overview (https://platform.openai.com/api/docs/guides/latency-optimization) - Predicted Outputs (https://platform.openai.com/api/docs/guides/predicted-outputs) - Priority processing (https://platform.openai.com/api/docs/guides/priority-processing) - Cost optimization - Overview (https://platform.openai.com/api/docs/guides/cost-optimization) - Batch (https://platform.openai.com/api/docs/guides/batch) - Flex processing (https://platform.openai.com/api/docs/guides/flex-processing) - Accuracy optimization (https://platform.openai.com/api/docs/guides/optimizing-llm-accuracy) - Safety - Safety best practices (https://platform.openai.com/api/docs/guides/safety-best-practices) - Safety checks (https://platform.openai.com/api/docs/guides/safety-checks) - Cybersecurity checks (https://platform.openai.com/api/docs/guides/safety-checks/cybersecurity) - Under 18 API Guidance (https://platform.openai.com/api/docs/guides/safety-checks/under-18-api-guidance) ### Legacy APIs - Assistants API - Migration guide (https://platform.openai.com/api/docs/assistants/migration) - Deep dive (https://platform.openai.com/api/docs/assistants/deep-dive) - Tools (https://platform.openai.com/api/docs/assistants/tools) ### Resources - Terms and policies (https://openai.com/policies) - Changelog (https://platform.openai.com/api/docs/changelog) - Your data (https://platform.openai.com/api/docs/guides/your-data) - Permissions (https://platform.openai.com/api/docs/guides/rbac) - Rate limits (https://platform.openai.com/api/docs/guides/rate-limits) - Deprecations (https://platform.openai.com/api/docs/deprecations) - MCP for deep research (https://platform.openai.com/api/docs/mcp) - Developer mode (https://platform.openai.com/api/docs/guides/developer-mode) - ChatGPT Actions - Introduction (https://platform.openai.com/api/docs/actions/introduction) - Getting started (https://platform.openai.com/api/docs/actions/getting-started) - Actions library (https://platform.openai.com/api/docs/actions/actions-library) - Authentication (https://platform.openai.com/api/docs/actions/authentication) - Production (https://platform.openai.com/api/docs/actions/production) - Data retrieval (https://platform.openai.com/api/docs/actions/data-retrieval) - Sending files (https://platform.openai.com/api/docs/actions/sending-files) Responses Copy Page More page actions Responses Copy Page More page actions Web search ========== Allow models to search the web for the latest information before generating a response. Web search allows models to access up-to-date information from the internet and provide answers with sourced citations. To enable this, use the web search tool in the Responses API or, in some cases, Chat Completions. There are three main types of web search available with OpenAI models: Non‑reasoning web search: The non-reasoning model sends the user’s query to the web search tool, which returns the response based on top results. There’s no internal planning and the model simply passes along the search tool’s responses. This method is fast and ideal for quick lookups. Agentic search with reasoning models is an approach where the model actively manages the search process. It can perform web searches as part of its chain of thought, analyze results, and decide whether to keep searching. This flexibility makes agentic search well suited to complex workflows, but it also means searches take longer than quick lookups. For example, you can adjust GPT-5’s reasoning level to change both the depth and latency of the search. Deep research is a specialized, agent-driven method for in-depth, extended investigations by reasoning models. The model conducts web searches as part of its chain of thought, often tapping into hundreds of sources. Deep research can run for several minutes and is best used with background mode. These tasks typically use models like o3-deep-research, o4-mini-deep-research, or gpt-5 with reasoning level set to high. Using the Responses API (https://platform.openai.com/api/docs/api-reference/responses), you can enable web search by configuring it in the tools array in an API request to generate content. Like any other tool, the model can choose to search the web or not based on the content of the input prompt. Web search tool example javascript 1 2 3 4 5 6 7 8 9 10 11 12 import OpenAI from "openai"; const client = new OpenAI(); const response = await client.responses.create({ model: "gpt-5", tools: [ { type: "web_search" }, ], input: "What was a positive news story from today?", }); console.log(response.output_text); 1 2 3 4 5 6 7 8 9 10 from openai import OpenAI client = OpenAI() response = client.responses.create( model="gpt-5", tools=[{"type": "web_search"}], input="What was a positive news story from today?" ) print(response.output_text) 1 2 3 4 5 6 7 8 curl "https://api.openai.com/v1/responses" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ "model": "gpt-5", "tools": [{"type": "web_search"}], "input": "what was a positive news story from today?" }' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 using OpenAI.Responses; string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!; OpenAIResponseClient client = new(model: "gpt-5", apiKey: key); ResponseCreationOptions options = new(); options.Tools.Add(ResponseTool.CreateWebSearchTool()); OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart("What was a positive news story from today?"), ]), ], options); Console.WriteLine(response.GetOutputText()); Output and citations -------------------- Model responses that use the web search tool will include two parts: - A web_search_call output item with the ID of the search call, along with the action taken in web_search_call.action. The action is one of: - search, which represents a web search. It will usually (but not always) includes the search queries which were searched. Search actions incur a tool call cost (see pricing (https://platform.openai.com/api/docs/pricing#built-in-tools)). - open_page, which represents a page being opened. Supported in reasoning models. - find_in_page, which represents searching within a page. Supported in reasoning models. - A message output item containing: - The text result in message.content[0].text - Annotations message.content[0].annotations for the cited URLs By default, the model’s response will include inline citations for URLs found in the web search results. In addition to this, the url_citation annotation object will contain the URL, title and location of the cited source. When displaying web results or information contained in web results to end users, inline citations must be made clearly visible and clickable in your user interface. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 [ { "type": "web_search_call", "id": "ws_67c9fa0502748190b7dd390736892e100be649c1a5ff9609", "status": "completed" }, { "id": "msg_67c9fa077e288190af08fdffda2e34f20be649c1a5ff9609", "type": "message", "status": "completed", "role": "assistant", "content": [ { "type": "output_text", "text": "On March 6, 2025, several news...", "annotations": [ { "type": "url_citation", "start_index": 2606, "end_index": 2758, "url": "https://...", "title": "Title..." } ] } ] } ] Using the Chat Completions API (https://platform.openai.com/api/docs/api-reference/chat), you can directly access the fine-tuned models and tool used by Search in ChatGPT (https://openai.com/index/introducing-chatgpt-search/). When using Chat Completions, the model always retrieves information from the web before responding to your query. To use web_search_preview as a tool that models like gpt-4o and gpt-4o-mini invoke only when necessary, switch to using the Responses API (https://platform.openai.com/api/docs/guides/tools-web-search?api-mode=responses). Currently, you need to use one of these models to use web search in Chat Completions: - gpt-5-search-api - gpt-4o-search-preview - gpt-4o-mini-search-preview Web search parameter example javascript 1 2 3 4 5 6 7 8 9 10 11 12 13 import OpenAI from "openai"; const client = new OpenAI(); const completion = await client.chat.completions.create({ model: "gpt-4o-search-preview", web_search_options: {}, messages: [{ "role": "user", "content": "What was a positive news story from today?" }], }); console.log(completion.choices[0].message.content); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 from openai import OpenAI client = OpenAI() completion = client.chat.completions.create( model="gpt-4o-search-preview", web_search_options={}, messages=[ { "role": "user", "content": "What was a positive news story from today?", } ], ) print(completion.choices[0].message.content) 1 2 3 4 5 6 7 8 9 10 11 curl -X POST "https://api.openai.com/v1/chat/completions" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-type: application/json" \ -d '{ "model": "gpt-4o-search-preview", "web_search_options": {}, "messages": [{ "role": "user", "content": "What was a positive news story from today?" }] }' Output and citations -------------------- The API response item in the choices array will include: - message.content with the text result from the model, inclusive of any inline citations - annotations with a list of cited URLs By default, the model’s response will include inline citations for URLs found in the web search results. In addition to this, the url_citation annotation object will contain the URL and title of the cited source, as well as the start and end index characters in the model’s response where those sources were used. When displaying web results or information contained in web results to end users, inline citations must be made clearly visible and clickable in your user interface. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [ { "index": 0, "message": { "role": "assistant", "content": "the model response is here...", "refusal": null, "annotations": [ { "type": "url_citation", "url_citation": { "end_index": 985, "start_index": 764, "title": "Page title...", "url": "https://..." } } ] }, "finish_reason": "stop" } ] Domain filtering ---------------- Domain filtering in web search lets you limit results to a specific set of domains. With the filters parameter you can set an allow-list of up to 100 URLs. When formatting URLs, omit the HTTP or HTTPS prefix. For example, use openai.com instead of https://openai.com/. This approach also includes subdomains in the search. Note that domain filtering is only available in the Responses API with the web_search tool. Sources ------- To view all URLs retrieved during a web search, use the sources field. Unlike inline citations, which show only the most relevant references, sources returns the complete list of URLs the model consulted when forming its response. The number of sources is often greater than the number of citations. Real-time third-party feeds are also surfaced here and are labeled as oai-sports, oai-weather, or oai-finance. The sources field is available with both the web_search and web_search_preview tools. List sources curl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 curl "https://api.openai.com/v1/responses" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ "model": "gpt-5", "reasoning": { "effort": "low" }, "tools": [ { "type": "web_search", "filters": { "allowed_domains": [ "pubmed.ncbi.nlm.nih.gov", "clinicaltrials.gov", "www.who.int", "www.cdc.gov", "www.fda.gov" ] } } ], "tool_choice": "auto", "include": ["web_search_call.action.sources"], "input": "Please perform a web search on how semaglutide is used in the treatment of diabetes." }' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 import OpenAI from "openai"; const client = new OpenAI(); const response = await client.responses.create({ model: "gpt-5", reasoning: { effort: "low" }, tools: [ { type: "web_search", filters: { allowed_domains: [ "pubmed.ncbi.nlm.nih.gov", "clinicaltrials.gov", "www.who.int", "www.cdc.gov", "www.fda.gov", ], }, }, ], tool_choice: "auto", include: ["web_search_call.action.sources"], input: "Please perform a web search on how semaglutide is used in the treatment of diabetes.", }); console.log(response.output_text); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 from openai import OpenAI client = OpenAI() response = client.responses.create( model="gpt-5", reasoning={"effort": "low"}, tools=[ { "type": "web_search", "filters": { "allowed_domains": [ "pubmed.ncbi.nlm.nih.gov", "clinicaltrials.gov", "www.who.int", "www.cdc.gov", "www.fda.gov", ] }, } ], tool_choice="auto", include=["web_search_call.action.sources"], input="Please perform a web search on how semaglutide is used in the treatment of diabetes.", ) print(response.output_text) User location ------------- To refine search results based on geography, you can specify an approximate user location using country, city, region, and/or timezone. - The city and region fields are free text strings, like Minneapolis and Minnesota respectively. - The country field is a two-letter ISO country code (https://en.wikipedia.org/wiki/ISO_3166-1), like US. - The timezone field is an IANA timezone (https://timeapi.io/documentation/iana-timezones) like America/Chicago. Note that user location is not supported for deep research models using web search. Customizing user location javascript 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 from openai import OpenAI client = OpenAI() response = client.responses.create( model="o4-mini", tools=[{ "type": "web_search", "user_location": { "type": "approximate", "country": "GB", "city": "London", "region": "London", } }], input="What are the best restaurants near me?", ) print(response.output_text) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 using OpenAI.Responses; string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!; OpenAIResponseClient client = new(model: "gpt-5", apiKey: key); ResponseCreationOptions options = new(); options.Tools.Add(ResponseTool.CreateWebSearchTool( userLocation: WebSearchToolLocation.CreateApproximateLocation( country: "GB", city: "London", region: "Granary Square" ) )); OpenAIResponse response = (OpenAIResponse)client.CreateResponse([ ResponseItem.CreateUserMessageItem([ ResponseContentPart.CreateInputTextPart( "What are the best restaurants near me?" ) ]) ], options); Console.WriteLine(response.GetOutputText()); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import OpenAI from "openai"; const openai = new OpenAI(); const response = await openai.responses.create({ model: "o4-mini", tools: [{ type: "web_search", user_location: { type: "approximate", country: "GB", city: "London", region: "London" } }], input: "What are the best restaurants near me?", }); console.log(response.output_text); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 curl "https://api.openai.com/v1/responses" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -d '{ "model": "o4-mini", "tools": [{ "type": "web_search", "user_location": { "type": "approximate", "country": "GB", "city": "London", "region": "London" } }], "input": "What are the best restaurants near me?" }' Customizing user location javascript 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 from openai import OpenAI client = OpenAI() completion = client.chat.completions.create( model="gpt-4o-search-preview", web_search_options={ "user_location": { "type": "approximate", "approximate": { "country": "GB", "city": "London", "region": "London", } }, }, messages=[{ "role": "user", "content": "What are the best restaurants near me?", }], ) print(completion.choices[0].message.content) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import OpenAI from "openai"; const client = new OpenAI(); const completion = await client.chat.completions.create({ model: "gpt-4o-search-preview", web_search_options: { user_location: { type: "approximate", approximate: { country: "GB", city: "London", region: "London", }, }, }, messages: [{ "role": "user", "content": "What are the best restaurants near me?", }], }); console.log(completion.choices[0].message.content); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 curl -X POST "https://api.openai.com/v1/chat/completions" \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-type: application/json" \ -d '{ "model": "gpt-4o-search-preview", "web_search_options": { "user_location": { "type": "approximate", "approximate": { "country": "GB", "city": "London", "region": "London" } } }, "messages": [{ "role": "user", "content": "What are the best restaurants near me?" }] }' Live internet access -------------------- Control whether the web search tool fetches live content or uses only cached/indexed results in the Responses API. - Set external_web_access: false on the web_search tool to run in offline/cache‑only mode. - Default is true (live access) if you do not set it. - Preview variants (web_search_preview) ignore this parameter and behave as if external_web_access is true. Control live internet access curl 1 2 3 4 5 6 7 8 curl "https://api.openai.com/v1/responses" -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d '{ "model": "gpt-5", "tools": [ { "type": "web_search", "external_web_access": false } ], "tool_choice": "auto", "input": "Find the sunrise time in Paris today and cite the source." }' 1 2 3 4 5 6 7 8 9 10 11 12 13 import OpenAI from "openai"; const client = new OpenAI(); const response = await client.responses.create({ model: "gpt-5", tools: [ { type: "web_search", external_web_access: false }, ], tool_choice: "auto", input: "Find the sunrise time in Paris today and cite the source.", }); console.log(response.output_text); 1 2 3 4 5 6 7 8 9 10 from openai import OpenAI client = OpenAI() resp = client.responses.create( model="gpt-5", tools=[{ "type": "web_search", "external_web_access": False }], tool_choice="auto", input="Find the sunrise time in Paris today and cite the source.", ) print(resp.output_text) API compatibility ----------------- Web search is available in the Responses API as the generally available version of the tool, web_search, as well as the earlier tool version, web_search_preview. To use web search in the Chat Completions API, use the specialized web search models gpt-5-search-api, gpt-4o-search-preview and gpt-4o-mini-search-preview. Limitations ----------- - Web search is currently not supported in gpt-5 (https://platform.openai.com/api/docs/models/gpt-5) with minimal reasoning, and gpt-4.1-nano (https://platform.openai.com/api/docs/models/gpt-4.1-nano). - When used as a tool in the Responses API (https://platform.openai.com/api/docs/api-reference/responses), web search has the same tiered rate limits as the models above. - Web search is limited to a context window size of 128000 (even with gpt-4.1 (https://platform.openai.com/api/docs/models/gpt-4.1) and gpt-4.1-mini (https://platform.openai.com/api/docs/models/gpt-4.1-mini) models). Usage notes ----------- | API Availability | Rate limits | Notes | | --- | --- | --- | | Responses (https://platform.openai.com/api/docs/api-reference/responses) Chat Completions (https://platform.openai.com/api/docs/api-reference/chat) Assistants (https://platform.openai.com/api/docs/api-reference/assistants) | Same as tiered rate limits for underlying model (https://platform.openai.com/api/docs/models) used with the tool. | Pricing (https://platform.openai.com/api/docs/pricing#built-in-tools) ZDR and data residency (https://platform.openai.com/api/docs/guides/your-data) |