[metadata]
astro-view-transitions-enabled: true
astro-view-transitions-fallback: swap
description: Learn how to use the OpenAI API to generate human-like responses to natural language prompts, analyze images with computer vision, use powerful built-in tools, and more.
generator: Astro v6.0.4
og:description: Learn how to use the OpenAI API to generate human-like responses to natural language prompts, analyze images with computer vision, use powerful built-in tools, and more.
og:image: https://developers.openai.com/og/api/docs/quickstart.png
og:image:alt: Developer quickstart | OpenAI API
og:image:height: 630
og:image:width: 1200
og:site_name: OpenAI Developers
og:title: Developer quickstart | OpenAI API
og:type: website
og:url: https://developers.openai.com/api/docs/quickstart
title: Developer quickstart | OpenAI API
twitter:card: summary_large_image
twitter:description: Learn how to use the OpenAI API to generate human-like responses to natural language prompts, analyze images with computer vision, use powerful built-in tools, and more.
twitter:image: https://developers.openai.com/og/api/docs/quickstart.png
twitter:image:alt: Developer quickstart | OpenAI API
twitter:image:height: 630
twitter:image:width: 1200
twitter:site: @OpenAIDevs
twitter:title: Developer quickstart | OpenAI API
twitter:url: https://developers.openai.com/api/docs/quickstart
viewport: width=device-width,initial-scale=1

[canonical-links]
https://developers.openai.com/api/docs/quickstart

[document-links]
.zshrc file: https://www.freecodecamp.org/news/how-do-zsh-configuration-files-work/
AGENTS.md: /codex/agent-configuration/agents-md
API Dashboard: https://platform.openai.com/login
API Partner Setup: /ads/api-partner-setup
API reference: /api/reference/overview
API: /api/docs
API: /blog/topic/api
AWS: /api/docs/guides/workload-identity-federation/aws
Access tokens: /codex/enterprise/access-tokens
Accuracy optimization: /api/docs/guides/optimizing-llm-accuracy
Actions: /api/docs/guides/chatkit-actions
Ad Account: /ads/api-reference/ad-account
Ad Groups: /ads/api-reference/ad-groups
Add UI to your MCP server (optional): /plugins/build/chatgpt-ui
Admin APIs: /api/docs/guides/admin-apis
Admin rollout guide: /codex/enterprise/admin-setup
Ads Overview: /ads
Ads Publish and measure ads in ChatGPT: /ads
Ads: /ads/api-reference/ads
Advanced Config: /codex/config-file/config-advanced
Advanced integrations: /api/docs/guides/custom-chatkit
Agent approvals & security: /codex/agent-approvals-security
Agent definitions: /api/docs/guides/agents/define-agents
Agents SDK: /api/docs/guides/agents
Agents: /api/docs/guides/agents
Agents: /cookbook/topic/agents
Agents: /learn/agents
All posts: /blog
Amazon Bedrock: /api/docs/guides/amazon-bedrock
Amazon Bedrock: /codex/amazon-bedrock
Analytics API: /codex/enterprise/analytics-api
App Server: /codex/app-server
Apply Patch: /api/docs/guides/tools-apply-patch
Apps SDK: /blog/topic/apps-sdk
Appshots: /codex/appshots
Audio & Voice: /learn/audio
Audio and speech: /api/docs/guides/audio
Audio: /blog/topic/audio
Authenticate users: /plugins/build/auth
Authenticate with Workspace Agent access tokens: /workspace-agents/authentication
Authentication overview: /codex/auth
Authentication: /ads/api-reference/authentication
Auto-review: /codex/sandboxing/auto-review
Background mode: /api/docs/guides/background
Batch: /api/docs/guides/batch
Best practices: /api/docs/guides/evaluation-best-practices
Best practices: /api/docs/guides/fine-tuning-best-practices
Best practices: /commerce/guides/best-practices
Blog Learnings and experiences from developers: /blog
Brainstorm use cases: /plugins/plan/use-case
Browser: /codex/browser
Build agents Use the Agents SDK to build, run, and observe agent workflows.: /api/docs/guides/agents
Build agents that can take action Learn how to use the OpenAI platform to build powerful, capable AI agents.: /api/docs/guides/agents
Build an MCP server: /plugins/build/mcp-server
Build plugins: /codex/build-plugins
Build skills: /codex/build-skills
Build skills: /plugins/build/skills
Bulk API: /ads/bulk-api
CLI customization: /codex/cli-customization
Campaign Targeting: /ads/campaign-targeting
Campaigns: /ads/api-reference/campaigns
Changelog: /api/docs/changelog
Changelog: /codex/changelog
Changelog: /codex/security/plugin/changelog
Changelog: /plugins/changelog
Chat Playground Build & test conversational prompts and embed them in your app.: https://platform.openai.com/chat
ChatGPT Work admin FAQ: /codex/enterprise/work-admin-faq
ChatGPT desktop app: /codex/app
ChatGPT on the web: /codex/web
ChatGPT: /
ChatGPT: /chatgpt
ChatGPT: /cookbook/topic/chatgpt
Checkout API reference: /plugins/build/monetization
Chrome extension: /codex/chrome-extension
Chronicle: /codex/customization/chronicle
Citation formatting: /api/docs/guides/citation-formatting
Cloud environment: /codex/environments/cloud-environment
Code generation: /api/docs/guides/code-generation
Code interpreter: /api/docs/guides/tools-code-interpreter
Code review: /codex/code-review
Codex Ambassadors: /community/codex-ambassadors
Codex Ambassadors: https://developers.openai.com/community/codex-ambassadors
Codex CLI: /codex/cli
Codex IDE extension: /codex/ide
Codex Micro: /codex/features/codex-micro
Codex SDK: /codex/codex-sdk
Codex cloud: /codex/cloud
Codex for Open Source: /community/codex-for-oss
Codex for Open Source: https://developers.openai.com/community/codex-for-oss
Codex for Students: /community/students
Codex for Students: https://developers.openai.com/community/students
Codex: /blog/topic/codex
Codex: /cookbook/topic/codex
Codex: /learn/codex
Codex: https://learn.chatgpt.com/docs
Collections: /codex/use-cases/collections
Commands: /codex/reference/commands
Commerce Build commerce flows in ChatGPT: /commerce
Community Programs, meetups, and support for builders: /community
Community: /community
Compaction: /api/docs/guides/compaction
Company blog: https://openai.com/news/
Compliance API and audit events: /codex/enterprise/compliance-api
Computer Use: /learn/cua
Computer use: /api/docs/guides/tools-computer-use
Computer use: /codex/computer-use
Config Basics: /codex/config-file/config-basic
Config Reference: /codex/config-file/config-reference
Connect and test your plugin: /plugins/deploy/connect-chatgpt
Content provenance: /api/docs/guides/content-provenance
Conversation state: /api/docs/guides/conversation-state
Conversion Setup: /ads/api-reference/conversion-setup
Conversion-Optimized Campaigns: /ads/conversion-optimized-campaigns
Conversions API: /ads/conversions-api
Cookbook Notebook examples for building with OpenAI models: /cookbook
Cookbook on GitHub: https://github.com/openai/openai-cookbook
Cost optimization: /api/docs/guides/cost-optimization
Counting tokens: /api/docs/guides/token-counting
Create an API Key: https://platform.openai.com/api-keys
Custom Code Review rules for Codex: /blog/custom-code-review-rules-for-codex
Customize: /api/docs/guides/chatkit-themes
Cyber Safety: /codex/cyber-safety
Cybersecurity checks: /api/docs/guides/safety-checks/cybersecurity
Deep dive: /api/docs/assistants/deep-dive
Deep research: /api/docs/guides/deep-research
Define tools: /plugins/plan/tools
Demo apps: /learn/code
Deployment checklist: /api/docs/guides/deployment-checklist
Deprecations: /api/docs/deprecations
Designing delightful frontends with GPT-5.4: /blog/designing-delightful-frontends-with-gpt-5-4
Desktop app: /codex/windows/windows-app
Developer Forum: https://community.openai.com/
Developer blog: https://developers.openai.com/blog
Developer commands: /codex/developer-commands
Developer settings: /codex/developer-settings
Direct preference optimization: /api/docs/guides/direct-preference-optimization
Discord: https://discord.com/invite/openai
Docs Guides, concepts, and product docs for Codex: https://learn.chatgpt.com/docs
Docs MCP: /learn/docs-mcp
Docs: /codex
Docs: https://learn.chatgpt.com/docs
Embeddings: /api/docs/guides/embeddings
Environment Variables: /codex/config-file/environment-variables
Error codes: /api/docs/guides/error-codes
Evals: /cookbook/topic/evals
Evals: /learn/evals
Evaluate agent workflows: /api/docs/guides/agent-evals
Examples: /plugins/build/examples
Explore use cases: /codex/use-cases
Export and track findings: /codex/security/plugin/export-findings
External models: /api/docs/guides/external-models
FAQ: /codex/security/cli/faq
FAQ: /codex/security/faq
Fast mode: /api/docs/guides/fast-mode
Feature Maturity: /codex/feature-maturity
Feeds: /commerce/specs/api/feeds
File inputs guide Learn to use file inputs to the model and extract meaning from documents.: /api/docs/guides/file-inputs
File inputs: /api/docs/guides/file-inputs
File search: /api/docs/guides/tools-file-search
File transcription: /api/docs/guides/speech-to-text
Files: /ads/api-reference/files
Fine-tuning: /learn/fine-tuning
Fix findings: /codex/security/plugin/fix-findings
Flex processing: /api/docs/guides/flex-processing
Frontend prompting: /api/docs/guides/frontend-prompt
Function calling guide Learn to enable the model to call your own custom code.: /api/docs/guides/function-calling
Function calling: /api/docs/guides/function-calling
General: /blog/topic/general
Get Quote spec: /plugins/guides/local-services-request-quote-conversion-spec
Get started with Work: /codex/get-started-with-work
Get started with the Realtime API Use WebRTC or WebSockets for super fast speech-to-speech AI apps.: /api/docs/guides/realtime
Get started: /commerce/guides/get-started
Getting started: /api/docs/guides/evaluation-getting-started
Git worktrees: /codex/environments/git-worktrees
GitHub Action: /codex/github-action
GitHub Actions: /api/docs/guides/workload-identity-federation/github-actions
GitHub: /codex/third-party/github
Glossary: /codex/glossary
Go to billing: https://platform.openai.com/account/billing/overview
Google Cloud: /api/docs/guides/workload-identity-federation/google-cloud
Governance: /codex/enterprise/governance
Graders: /api/docs/guides/graders
Groups and provisioning: /codex/enterprise/groups-and-provisioning
Guardrails: /api/docs/guides/agents/guardrails-approvals
Guardrails: /cookbook/topic/guardrails
HIPAA configuration: /codex/hipaa-configuration
Home: /
Home: /api/docs
Home: /codex
Home: /codex/resources
Home: /commerce
Home: /cookbook
Home: /learn
Home: /plugins
Home: /workspace-agents
Hooks: /codex/hooks
How Perplexity Brought Voice Search to Millions Using the Realtime API: /blog/realtime-perplexity-computer
IP egress ranges: /api/docs/guides/ip-addresses
Image Tag: /ads/image-tag
Image generation: /api/docs/guides/image-generation
Image generation: /api/docs/guides/tools-image-generation
Image generation: /codex/image-generation
Image generation: /learn/imagegen
Image inputs guide Learn to use image inputs to the model and extract meaning from images.: /api/docs/guides/images
Image inputs: /codex/image-inputs
Images and vision: /api/docs/guides/images-vision
Import and reconciliation: /api/docs/guides/terraform/import-and-reconcile
Import from another agent: /codex/import
Improving the threat model: /codex/security/threat-model
Insights: /ads/api-reference/insights
Install the plugin: /learn/developers-codex-plugin
Integrated terminal: /codex/integrated-terminal
Integrations and observability: /api/docs/guides/agents/integrations-observability
Internet access: /codex/cloud/internet-access
Key concepts: /api/docs/concepts
Kubernetes: /api/docs/guides/workload-identity-federation/kubernetes
Latency optimization: /api/docs/guides/latency-optimization
Learn Docs, videos, and demo apps for building with OpenAI: /learn
Learn more on GitHub Discover more SDK capabilities and options on the library’s GitHub README.: https://github.com/openai/openai-go
Learn more on GitHub Discover more SDK capabilities and options on the library’s GitHub README.: https://github.com/openai/openai-java
Learn more on GitHub Discover more SDK capabilities and options on the library’s GitHub README.: https://github.com/openai/openai-node
Learn more on GitHub Discover more SDK capabilities and options on the library’s GitHub README.: https://github.com/openai/openai-python
Learn more on GitHub Discover more SDK capabilities and options on the library’s GitHub README.: https://github.com/openai/openai-ruby
Linear: /codex/third-party/linear
Live translation: /api/docs/guides/realtime-translation
Local environments: /codex/environments/local-environment
Local shell: /api/docs/guides/tools-local-shell
Long-running work: /codex/long-running-work
MCP Server: /codex/mcp-server
MCP and Connectors: /api/docs/guides/tools-connectors-mcp
MCP server review requirements: /plugins/deploy/app-review
MCP server: /plugins/concepts/mcp-server
MCP: /codex/extend/mcp
Making private MCP servers reachable without making them public: /blog/connect-private-mcp-servers-to-openai-products
Manage app updates: /codex/enterprise/manage-app-updates
Managed configuration: /codex/enterprise/managed-configuration
Managing conversations: /api/docs/guides/realtime-conversations
Managing costs: /api/docs/guides/realtime-costs
Mastering remote engineering work from your phone: /blog/mastering-codex-remote-for-engineering
Measurement Pixel: /ads/measurement-pixel
Meetups: /community/meetups
Meetups: https://developers.openai.com/community/meetups
Memories: /codex/customization/memories
Microsoft Azure: /api/docs/guides/workload-identity-federation/microsoft-azure
Migration guide: /api/docs/assistants/migration
Migration guide: /api/docs/guides/agent-builder/migrate-from-agent-builder
Migration guide: /api/docs/guides/prompting/migrate-from-prompt-object
Model catalog: /api/docs/models
Model selection: /api/docs/guides/model-selection
Model, tool, and data controls: /api/docs/guides/terraform/project-controls
Models and providers: /api/docs/guides/agents/models
Models: /api/docs/models
Models: /codex/models
Moderation: /api/docs/guides/moderation
Modes: /codex/environments/modes
Multi-agent: /api/docs/guides/responses-multi-agent
Multimodal: /cookbook/topic/multimodal
Multiple Pixels (Advanced): /ads/multiple-pixels
Next Using GPT-5.6: /api/docs/guides/latest-model
Node reference: /api/docs/guides/node-reference
Non-interactive mode: /codex/non-interactive-mode
Notifications: /codex/notifications
NuGet: https://www.nuget.org/
Online trainings: https://academy.openai.com/home/events
Open Source: /codex/open-source
OpenAI Academy: https://openai.com/academy/
OpenAI CLI: /api/docs/libraries/openai-cli
OpenAI Crawlers: /api/docs/bots
OpenAI Developers plugin: /learn/developers-codex-plugin
OpenAI SDK for Python: https://github.com/openai/openai-python
OpenAI SDK for Ruby: https://github.com/openai/openai-ruby
OpenAI SDK for TypeScript and JavaScript: https://github.com/openai/openai-node
OpenAI SDK: /api/docs/libraries
OpenAI for Startups: https://openai.com/business/why-openai/startups/
Optimization cycle: /api/docs/guides/model-optimization
Optimization: /cookbook/topic/optimization
Optimize Metadata: /plugins/guides/optimize-metadata
Oracle Cloud Infrastructure: /api/docs/guides/workload-identity-federation/oracle-cloud
Orchestration: /api/docs/guides/agents/orchestration
Overview: /ads/api-overview
Overview: /api/docs
Overview: /api/docs/guides/agent-builder
Overview: /api/docs/guides/agents
Overview: /api/docs/guides/chatkit
Overview: /api/docs/guides/prompting
Overview: /api/docs/guides/realtime
Overview: /api/docs/guides/terraform
Overview: /api/docs/guides/tools
Overview: /codex/administration
Overview: /codex/configuration
Overview: /codex/customization/overview
Overview: /codex/developers
Overview: /codex/features
Overview: /codex/security
Overview: /codex/security-administration
Overview: /commerce/specs/api/overview
Overview: /commerce/specs/file-upload/overview
Package your plugin: /plugins/build/plugins
Permissions: /api/docs/guides/rbac
Permissions: /codex/permission-modes
Personalize ChatGPT: /codex/personalize
Pets: /codex/pets
Plugin UI reference: /plugins/reference
Plugin architecture: /plugins/concepts/plugins
Plugin controls: /codex/enterprise/apps-and-connectors
Plugin guidelines: /plugins/app-guidelines
Plugins Extend ChatGPT and Codex: /plugins
Plugins: /codex/plugins
Predicted Outputs: /api/docs/guides/predicted-outputs
Pricing: /api/docs/pricing
Pricing: /codex/pricing
Prisma AIRS: /codex/enterprise/prisma-airs
Private Link: /api/docs/guides/private-link
Product Feeds: /ads/product-feeds
Product checkout spec: /plugins/guides/product-checkout-conversion-spec
Production best practices: /api/docs/guides/production-best-practices
Production: /api/docs/guides/production-best-practices
Products: /commerce/specs/api/products
Products: /commerce/specs/file-upload/products
Profiles: /codex/permissions
Programmatic tool calling: /api/docs/guides/tools-programmatic-tool-calling
Projects and access: /api/docs/guides/terraform/projects-and-access
Projects and chats: /codex/projects
Promotions: /commerce/specs/api/promotions
Prompt caching: /api/docs/guides/prompt-caching
Prompt engineering: /api/docs/guides/prompt-engineering
Prompt generation: /api/docs/guides/prompt-generation
Prompt optimizer: /api/docs/guides/prompt-optimizer
Prompting: /codex/prompting
Propose security hardening: /codex/security/plugin/security-hardening
Quickstart: /ads/api-quickstart
Quickstart: /api/docs/guides/agents/quickstart
Quickstart: /api/docs/quickstart
Quickstart: /codex/quickstart
Quickstart: /codex/security/cli
Quickstart: /codex/security/plugin
Quickstart: /plugins/quickstart
RFT use cases: /api/docs/guides/rft-use-cases
Rate limits and spend: /api/docs/guides/terraform/rate-limits-and-spend
Rate limits: /api/docs/guides/rate-limits
Realtime API: /api/docs/guides/realtime
Realtime prompting guide: /api/docs/guides/realtime-models-prompting
Realtime transcription: /api/docs/guides/realtime-transcription
Realtime with tools: /api/docs/guides/realtime-mcp
Reasoning best practices: /api/docs/guides/reasoning-best-practices
Reasoning models: /api/docs/guides/reasoning
Record & Replay: /codex/extend/record-and-replay
Red teaming: /api/docs/guides/red-teaming
Reddit: https://www.reddit.com/r/OpenAI/
Reference: /codex/security/cli/reference
Reinforcement fine-tuning: /api/docs/guides/reinforcement-fine-tuning
Remote connections: /codex/remote-connections
Remote: /codex/remote
Resources: /codex/resources
Resources: /learn
Responses API: /api/docs/api-reference/responses
Responses API: /api/docs/guides/migrate-to-responses
Responses starter app Start building with the Responses API.: https://github.com/openai/openai-responses-starter-app
Restaurant reservation spec: /plugins/guides/restaurant-reservation-conversion-spec
Results and state: /api/docs/guides/agents/results
Retrieval: /api/docs/guides/retrieval
Review code changes: /codex/security/plugin/code-changes
Roles and workspace permissions: /codex/enterprise/roles-and-workspace-permissions
Rules: /codex/agent-configuration/rules
Run a deep scan: /codex/security/plugin/deep-scans
Run a security scan: /codex/security/plugin/scans
Run bulk scans: /codex/security/cli/bulk-scans
Run scans in CI: /codex/security/cli/ci
Running agents: /api/docs/guides/agents/running-agents
SIP: /api/docs/guides/realtime-sip
SPIFFE: /api/docs/guides/workload-identity-federation/spiffe
Safety best practices: /api/docs/guides/safety-best-practices
Safety checks: /api/docs/guides/safety-checks
Safety in building agents: /api/docs/guides/agent-builder-safety
Sample Config: /codex/config-file/config-sample
Sandbox agents: /api/docs/guides/agents/sandboxes
Sandboxing: /codex/sandboxing
Scaling: /learn/scaling
Scheduled tasks: /codex/automations
Secure MCP Tunnel: /api/docs/guides/secure-mcp-tunnels
Security & Privacy: /plugins/guides/security-privacy
Security Review: /codex/security/security-review
Service accounts: /api/docs/guides/terraform/service-accounts
Settings: /codex/reference/settings
Setup: /codex/security/setup
Shell: /api/docs/guides/tools-shell
Showcase Demo apps to get inspired: /showcase
Showcase: /showcase
Showcase: https://developers.openai.com/showcase
Sites: /codex/sites
Skill controls: /codex/enterprise/skills
Skills & Plugins: /codex/skills-and-plugins
Skills: /api/docs/guides/tools-skills
Skills: /plugins/concepts/skills
Slack: /codex/third-party/slack
Slash commands: /codex/reference/slash-commands
Speech generation: /api/docs/guides/text-to-speech
Speed: /codex/agent-configuration/speed
Spend limits: /api/docs/guides/spend-limits
Streaming: /api/docs/guides/streaming-responses
Structured output: /api/docs/guides/structured-outputs
Subagents: /codex/agent-configuration/subagents
Submission error reference: /plugins/deploy/submission-errors
Submit and publish: /plugins/deploy/submission
Supervised fine-tuning: /api/docs/guides/supervised-fine-tuning
Supported Events: /ads/supported-events
Supported countries: /api/docs/supported-countries
Terms and policies: https://openai.com/policies
Terraform provider: /api/docs/guides/terraform
Text generation and prompting Learn more about prompting, message roles, and building conversational apps.: /api/docs/guides/text
Text generation: /api/docs/guides/text
Text: /cookbook/topic/text
Tool search: /api/docs/guides/tools-tool-search
Tools: /api/docs/assistants/tools
Tools: /api/docs/guides/tools
Tools: /learn/tools
Transcription: /api/docs/guides/transcription
Triage a backlog: /codex/security/plugin/triage-backlog
Trigger workspace agent runs: /workspace-agents/trigger-runs
Troubleshooting: /codex/reference/troubleshooting
Troubleshooting: /plugins/deploy/troubleshooting
Try ChatGPT: https://chatgpt.com/
TypeScript SDK: /codex/security/sdk
UI guidelines: /plugins/concepts/ui-guidelines
Under 18 API Guidance: /api/docs/guides/safety-checks/under-18-api-guidance
Use ChatGPT: /codex/use-chatgpt
Use built-in tools Learn about powerful built-in tools like web search and file search.: /api/docs/guides/tools
Use cases Example workflows and tasks teams can take on with ChatGPT or Codex: https://learn.chatgpt.com/use-cases
Use cases: /codex/use-cases
Use cases: https://learn.chatgpt.com/use-cases
Use streaming events Use server-sent events to stream model responses to users fast.: /api/docs/guides/streaming-responses
Use the Security workbench: /codex/security/plugin/workbench
Using GPT-5.6: /api/docs/guides/latest-model
Video generation: /api/docs/guides/video-generation
Video generation: /learn/videogen
Videos: /codex/videos
Videos: /learn/videos
Vision fine-tuning: /api/docs/guides/vision-fine-tuning
Visualizations: /codex/visualizations
Voice & Audio: /api/docs/guides/realtime
Voice activity detection: /api/docs/guides/realtime-vad
Voice agents: /api/docs/guides/voice-agents
Voice: /codex/features/voice
WSL: /codex/windows/wsl
Web search: /api/docs/guides/tools-web-search
Web search: /codex/web-search
WebRTC: /api/docs/guides/realtime-webrtc
WebSocket mode: /api/docs/guides/websocket-mode
WebSocket: /api/docs/guides/realtime-websocket
Webhooks and server-side controls: /api/docs/guides/realtime-server-controls
Webhooks: /api/docs/guides/webhooks
What's new: /codex/whats-new
Widgets: /api/docs/guides/chatkit-widgets
Windows app deployment: /codex/enterprise/windows-deployment
Windows sandbox: /codex/windows/windows-sandbox
Work with files: /codex/artifacts-viewer
Working with evals: /api/docs/guides/evals
Workload identity federation: /api/docs/guides/workload-identity-federation
Workspace Agents Trigger published ChatGPT workspace agents: /workspace-agents
Workspace analytics: /codex/enterprise/workspace-analytics
Workspace model availability: /codex/enterprise/workspace-model-availability
Write vulnerability reports: /codex/security/plugin/vulnerability-reports
X.509 certificates (beta): /api/docs/guides/workload-identity-federation/x509
X: https://x.com/OpenAIDevs
Your data: /api/docs/guides/your-data
access the API: /api/docs/api-reference/authentication
agents: /api/docs/guides/agents
controlling computers: /api/docs/guides/tools-computer-use
environment variable: https://en.wikipedia.org/wiki/Environment_variable
gpt-oss: /cookbook/topic/gpt-oss
gpt-oss: /learn/gpt-oss
llms.txt: /llms.txt
models: /api/docs/models
npm: https://www.npmjs.com/
our models: /api/docs/models
pip: https://pypi.org/project/pip/
streaming events: /api/docs/guides/streaming-responses
tools: /api/docs/guides/tools

[content]
Developer quickstart | OpenAI API
For the complete documentation index, see
llms.txt
. Markdown versions of documentation pages are available by appending
.md
to the page URL.
ChatGPT
Home
API
Codex
Docs
Guides, concepts, and product docs for Codex
Use cases
Example workflows and tasks teams can take on with ChatGPT or Codex
Docs
Use cases
Resources
ChatGPT
Plugins
Extend ChatGPT and Codex
Workspace Agents
Trigger published ChatGPT workspace agents
Commerce
Build commerce flows in ChatGPT
Ads
Publish and measure ads in ChatGPT
Resources
Showcase
Demo apps to get inspired
Blog
Learnings and experiences from developers
Cookbook
Notebook examples for building with OpenAI models
Learn
Docs, videos, and demo apps for building with OpenAI
Community
Programs, meetups, and support for builders
Start searching
API Dashboard
Try ChatGPT
Overview
Models
Agents
Tools
Voice & Audio
Production
API reference
Search the API docs
Search docs
Suggested
responses create
reasoning_effort
realtime
prompt caching
Primary navigation
API
Codex
ChatGPT
Docs
Use cases
Resources
Resources
Search docs
Suggested
responses create
reasoning_effort
realtime
prompt caching
Overview
Models
Agents
Tools
Voice & Audio
Production
API reference
Overview
Models
Agents
Tools
Voice & Audio
Production
API reference
Docs section
Overview
Home
Get started
Quickstart
Using GPT-5.6
Key concepts
Core concepts
Responses API
Conversation state
Background mode
Streaming
WebSocket mode
Multi-agent
Webhooks
File inputs
Compaction
Counting tokens
SDKs and CLI
OpenAI SDK
OpenAI CLI
Resources
Changelog
Deprecations
Supported countries
OpenAI Crawlers
Terms and policies
Legacy APIs
Agent Builder
Overview
Migration guide
Node reference
Safety in building agents
Evals
Getting started
Working with evals
Prompt optimizer
External models
Best practices
Graders
Fine-tuning
Optimization cycle
Supervised fine-tuning
Vision fine-tuning
Direct preference optimization
Reinforcement fine-tuning
RFT use cases
Best practices
Assistants API
Migration guide
Deep dive
Tools
Model catalog
Choose a model
Pricing
Model selection
Text and code
Text generation
Code generation
Structured output
Prompting
Overview
Prompt engineering
Citation formatting
Migration guide
Prompt generation
Frontend prompting
Reasoning
Reasoning models
Reasoning best practices
Images and video
Images and vision
Image generation
Video generation
Realtime and audio
Audio and speech
Overview
Voice agents
Specialized models
Deep research
Embeddings
Moderation
Overview
Agents SDK
Quickstart
Agent definitions
Models and providers
Running agents
Sandbox agents
Orchestration
Guardrails
Results and state
Integrations and observability
Evaluate agent workflows
ChatKit
Overview
Customize
Widgets
Actions
Advanced integrations
Overview
Function calling
Search and retrieval
Web search
File search
Retrieval
Connect tools and data
MCP and Connectors
Secure MCP Tunnel
Build tool workflows
Skills
Tool search
Programmatic tool calling
Computer and code
Shell
Computer use
Apply Patch
Local shell
Code interpreter
Media
Image generation
Overview
Get started
Voice agents
Live translation
Realtime prompting guide
Audio
Audio and speech
Transcription
File transcription
Realtime transcription
Speech generation
Connection methods
WebRTC
WebSocket
SIP
Sessions and operations
Managing conversations
Voice activity detection
Realtime with tools
Webhooks and server-side controls
Managing costs
Go live
Production best practices
Deployment checklist
Performance and quality
Latency optimization
Predicted Outputs
Fast mode
Accuracy optimization
Cost and throughput
Cost optimization
Prompt caching
Batch
Flex processing
Safety and governance
Safety best practices
Red teaming
Safety checks
Cybersecurity checks
Under 18 API Guidance
Content provenance
Your data
Permissions
Infrastructure and access
Terraform provider
Overview
Projects and access
Service accounts
Rate limits and spend
Model, tool, and data controls
Import and reconciliation
Private Link
Workload identity federation
X.509 certificates (beta)
Kubernetes
AWS
Microsoft Azure
Google Cloud
Oracle Cloud Infrastructure
GitHub Actions
SPIFFE
IP egress ranges
Amazon Bedrock
Operations
Rate limits
Spend limits
Admin APIs
Error codes
Docs
Use cases
Docs
Use cases
Docs section
Docs
Plugins
Workspace Agents
Commerce
Ads
Plugins
Workspace Agents
Commerce
Ads
Docs section
Select...
Home
Quickstart
Core concepts
Plugin architecture
Skills
MCP server
Plan
Brainstorm use cases
Define tools
Build
Build an MCP server
Add UI to your MCP server (optional)
Authenticate users
Build skills
Package your plugin
Examples
Test and publish
Connect and test your plugin
Submit and publish
Submission error reference
Conversion specs
Restaurant reservation spec
Get Quote spec
Product checkout spec
Guides
UI guidelines
Optimize Metadata
Security & Privacy
Troubleshooting
Resources
Changelog
Plugin guidelines
MCP server review requirements
Plugin UI reference
Checkout API reference
Home
Get started
Trigger workspace agent runs
Authenticate with Workspace Agent access tokens
Home
Guides
Get started
Best practices
File Upload
Overview
Products
API
Overview
Feeds
Products
Promotions
Ads Overview
Measurement
Measurement Pixel
Multiple Pixels (Advanced)
Image Tag
Conversions API
Supported Events
Advertiser API
Overview
API Partner Setup
Quickstart
Bulk API
Product Feeds
Campaign Targeting
Conversion-Optimized Campaigns
API Reference
Authentication
Ad Account
Campaigns
Ad Groups
Ads
Insights
Files
Conversion Setup
Overview
Features
Configuration
Developers
Security
Administration
Use Cases
Resources
Overview
Features
Configuration
Developers
Security
Administration
Use Cases
Resources
Docs section
Overview
Home
Get started
Quickstart
Use ChatGPT
Get started with Work
Import from another agent
Foundations
Prompting
Personalize ChatGPT
Skills & Plugins
Permissions
Explore
What's new
Models
Pricing
Glossary
Available on
ChatGPT desktop app
Remote
ChatGPT on the web
Codex CLI
Codex IDE extension
Codex cloud
Releases
Changelog
Feature Maturity
Open Source
Overview
Workflows
Projects and chats
Sites
Visualizations
Scheduled tasks
Long-running work
Notifications
Pets
Codex Micro
Capabilities
Browser
Computer use
Voice
Plugins
Web search
Image generation
Image inputs
Appshots
Chrome extension
Work with files
Reference
Commands
Slash commands
Settings
Troubleshooting
Overview
Customization
Overview
Memories
Chronicle
Config file
Config Basics
Advanced Config
Config Reference
Environment Variables
Sample Config
Agent configuration
AGENTS.md
Subagents
Speed
Rules
Extend ChatGPT and Codex
Record & Replay
MCP
Windows
Desktop app
Windows sandbox
WSL
Overview
Development workflows
Code review
Integrated terminal
Extend and automate
Build skills
Build plugins
Hooks
Environments
Modes
Local environments
Cloud environment
Git worktrees
Build with Codex
Codex SDK
App Server
MCP Server
GitHub Action
Non-interactive mode
Third-party integrations
GitHub
Slack
Linear
Reference
CLI customization
Developer commands
Developer settings
Overview
Permissions
Profiles
Sandboxing
Auto-review
Agent approvals & security
Internet access
Codex Security
Overview
Codex Security plugin
Quickstart
Run a security scan
Run a deep scan
Review code changes
Use the Security workbench
Triage a backlog
Fix findings
Propose security hardening
Write vulnerability reports
Export and track findings
Changelog
Codex Security CLI
Quickstart
Run bulk scans
Run scans in CI
Reference
FAQ
TypeScript SDK
Codex Security cloud
Setup
Security Review
Improving the threat model
FAQ
Safety
Cyber Safety
Overview
Getting started
Admin rollout guide
ChatGPT Work admin FAQ
Identity and authentication
Authentication overview
Access tokens
Workspace access, policy, and models
Groups and provisioning
Roles and workspace permissions
Managed configuration
Prisma AIRS
HIPAA configuration
Workspace model availability
Plugin and connector controls
Plugin controls
Skill controls
Usage, governance, and compliance
Governance
Workspace analytics
Analytics API
Compliance API and audit events
Deployment and model providers
Manage app updates
Windows app deployment
Remote connections
Amazon Bedrock
Explore use cases
Collections
Home
Videos
Showcase
OpenAI Academy
Online trainings
Community
Codex Ambassadors
Codex for Students
Codex for Open Source
Meetups
Blog
Company blog
Developer blog
Explore use cases
Collections
Home
Videos
Showcase
OpenAI Academy
Online trainings
Community
Codex Ambassadors
Codex for Students
Codex for Open Source
Meetups
Blog
Company blog
Developer blog
Showcase
Blog
Cookbook
Learn
Community
Showcase
Blog
Cookbook
Learn
Community
Docs section
Select...
All posts
Recent
Custom Code Review rules for Codex
Mastering remote engineering work from your phone
Making private MCP servers reachable without making them public
How Perplexity Brought Voice Search to Millions Using the Realtime API
Designing delightful frontends with GPT-5.4
Topics
General
API
Apps SDK
Audio
Codex
Home
Topics
Agents
Evals
Multimodal
Text
Guardrails
Optimization
ChatGPT
Codex
gpt-oss
Contribute
Cookbook on GitHub
Home
OpenAI Developers plugin
Docs MCP
Categories
Demo apps
Videos
Topics
Agents
Audio & Voice
Computer Use
Codex
Evals
gpt-oss
Fine-tuning
Image generation
Scaling
Tools
Video generation
Community
Programs
Codex Ambassadors
Codex for Students
Codex for Open Source
OpenAI for Startups
Events
Meetups
Spaces
Developer Forum
Discord
Reddit
X
API Dashboard
Try ChatGPT
Home
Get started
Quickstart
Using GPT-5.6
Key concepts
Core concepts
Responses API
Conversation state
Background mode
Streaming
WebSocket mode
Multi-agent
Webhooks
File inputs
Compaction
Counting tokens
SDKs and CLI
OpenAI SDK
OpenAI CLI
Resources
Changelog
Deprecations
Supported countries
OpenAI Crawlers
Terms and policies
Legacy APIs
Agent Builder
Overview
Migration guide
Node reference
Safety in building agents
Evals
Getting started
Working with evals
Prompt optimizer
External models
Best practices
Graders
Fine-tuning
Optimization cycle
Supervised fine-tuning
Vision fine-tuning
Direct preference optimization
Reinforcement fine-tuning
RFT use cases
Best practices
Assistants API
Migration guide
Deep dive
Tools
Copy Page
Developer quickstart
Take your first steps with the OpenAI API.
Copy Page
The OpenAI API provides a consistent interface to state-of-the-art AI
models
for text generation, natural language processing, computer vision, and more. Get started by creating an API Key and running your first API call. Discover how to generate text, analyze images, build agents, and more.
Build with the OpenAI API in ChatGPT and Codex
The OpenAI Developers plugin connects ChatGPT and Codex to the OpenAI Platform, follows OpenAI API setup guidance, and creates project API keys when your application needs one.
Install the plugin
Create and export an API key
Create an API Key
Before you begin, create an API key in the dashboard, which you’ll use to securely
access the API
. Store the key in a safe location, like a
.zshrc
file
or another text file on your computer. Once you’ve generated an API key, export it as an
environment variable
in your terminal.
macOS / Linux
Windows
macOS / Linux
Export an environment variable on macOS or Linux systems
1
export
OPENAI_API_KEY
=
"your_api_key_here"
Windows
Export an environment variable in PowerShell
1
setx
OPENAI_API_KEY
"your_api_key_here"
Each OpenAI SDK automatically reads your API key from the system environment.
Install the OpenAI SDK and Run an API Call
JavaScript
Python
.NET
Java
Go
Ruby
JavaScript
To use the OpenAI API in server-side JavaScript environments like Node.js, Deno, or Bun, you can use the official
OpenAI SDK for TypeScript and JavaScript
. Get started by installing the SDK using
npm
or your preferred package manager:
Install the OpenAI SDK with npm
1
npm
install
openai
With the OpenAI SDK installed, create a file called
example.mjs
and copy the example code into it:
Test a basic API request
1
2
3
4
5
6
7
8
9
import
OpenAI
from
"openai"
;
const
client
=
new
OpenAI
();
const
response
=
await
client.responses.
create
({
model:
"gpt-5.6"
,
input:
"Write a one-sentence bedtime story about a unicorn."
,
});
console.
log
(response.output_text);
Execute the code with
node example.mjs
(or the equivalent command for Deno or Bun). In a few moments, you should see the output of your API request.
Learn more on GitHub
Discover more SDK capabilities and options on the library’s GitHub README.
Python
To use the OpenAI API in Python, you can use the official
OpenAI SDK for Python
. Get started by installing the SDK using
pip
:
Install the OpenAI SDK with pip
1
pip
install
openai
With the OpenAI SDK installed, create a file called
example.py
and copy the example code into it:
Test a basic API request
1
2
3
4
5
6
7
8
9
10
from
openai
import
OpenAI
client
=
OpenAI()
response
=
client.responses.create(
model
=
"gpt-5.6"
,
input
=
"Write a one-sentence bedtime story about a unicorn."
,
)
print
(response.output_text)
Execute the code with
python example.py
. In a few moments, you should see the output of your API request.
Learn more on GitHub
Discover more SDK capabilities and options on the library’s GitHub README.
.NET
In collaboration with Microsoft, OpenAI provides an officially supported API client for C#. You can install it with the .NET CLI from
NuGet
.
dotnet add package OpenAI
A simple API request to the
Responses API
would look like this:
Test a basic API request
1
2
3
4
5
6
7
8
9
10
11
12
using
OpenAI
.
Responses
;
#
pragma
warning
disable
OPENAI001
string
key
=
Environment.
GetEnvironmentVariable
(
"OPENAI_API_KEY"
)
!
;
ResponsesClient
client
=
new
(key);
ResponseResult
response
=
await
client.
CreateResponseAsync
(
"gpt-5.6"
,
"Say 'this is a test.'"
);
Console.
WriteLine
(
$"[ASSISTANT]:
{
response
.
GetOutputText
()}
"
);
Java
OpenAI provides an API helper for the Java programming language, currently in beta. You can include the Maven dependency using the following configuration:
<
dependency
>
<
groupId
>com.openai</
groupId
>
<
artifactId
>openai-java</
artifactId
>
<
version
>4.0.0</
version
>
</
dependency
>
A simple API request to
Responses API
would look like this:
Test a basic API request
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import
com.openai.client.OpenAIClient;
import
com.openai.client.okhttp.OpenAIOkHttpClient;
import
com.openai.models.responses.Response;
import
com.openai.models.responses.ResponseCreateParams;
public
class
Main
{
public
static
void
main
(
String
[]
args
) {
OpenAIClient client
=
OpenAIOkHttpClient.
fromEnv
();
ResponseCreateParams params
=
ResponseCreateParams.
builder
().
input
(
"Say this is a test"
).
model
(
"gpt-5.6"
).
build
();
Response response
=
client.
responses
().
create
(params);
response.
output
().
stream
()
.
flatMap
(item
->
item.
message
().
stream
())
.
flatMap
(message
->
message.
content
().
stream
())
.
flatMap
(content
->
content.
outputText
().
stream
())
.
forEach
(outputText
->
System.out.
println
(outputText.
text
()));
}
}
To learn more about using the OpenAI API in Java, check out the GitHub repo linked below!
Learn more on GitHub
Discover more SDK capabilities and options on the library’s GitHub README.
Go
OpenAI provides an API helper for the Go programming language, currently in beta. You can import the library using the code below:
1
2
3
import
(
"
github.com/openai/openai-go/v3
"
// imported as openai
)
A first API request to the
Responses API
would look like this:
Test a basic API request
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package
main
import
(
"
context
"
"
fmt
"
"
github.com/openai/openai-go/v3
"
"
github.com/openai/openai-go/v3/responses
"
)
func
main
() {
client
:=
openai.
NewClient
()
resp, err
:=
client.Responses.
New
(context.
TODO
(),
responses
.
ResponseNewParams
{
Model:
"gpt-5.6"
,
Input:
responses
.
ResponseNewParamsInputUnion
{OfString: openai.
String
(
"Say this is a test"
)},
})
if
err
!=
nil
{
panic
(err.
Error
())
}
fmt.
Println
(resp.
OutputText
())
}
To learn more about using the OpenAI API in Go, check out the GitHub repo linked below!
Learn more on GitHub
Discover more SDK capabilities and options on the library’s GitHub README.
Ruby
To use the OpenAI API in Ruby, you can use the official
OpenAI SDK for Ruby
. Get started by adding the gem to your application:
Install the OpenAI SDK with Bundler
1
gem
"openai"
With the OpenAI SDK installed, create a file called
example.rb
and copy the example code into it:
Test a basic API request
1
2
3
4
5
6
7
8
9
10
require
"openai"
openai
=
OpenAI
::
Client
.
new
response
=
openai.
responses
.
create
(
model:
"gpt-5.6"
,
input:
"Write a one-sentence bedtime story about a unicorn."
)
puts
(response.
output_text
)
Execute the code with
ruby example.rb
. In a few moments, you should see the output of your API request.
Learn more on GitHub
Discover more SDK capabilities and options on the library’s GitHub README.
Responses starter app
Start building with the Responses API.
Text generation and prompting
Learn more about prompting, message roles, and building conversational apps.
Add credits to keep building
Go to billing
Congrats on running a free test API request! Start building real applications with higher limits and use
our models
to generate text, audio, images, videos and more.
Explore tools and docs designed to help you ship faster:
Chat Playground
Build & test conversational prompts and embed them in your app.
Build agents
Use the Agents SDK to build, run, and observe agent workflows.
Analyze images and files
Send image URLs, uploaded files, or PDF documents directly to the model to extract text, classify content, or detect visual elements.
Image URL
File URL
Upload file
Image URL
Analyze the content of an image
JavaScript
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
import
OpenAI
from
"openai"
;
const
client
=
new
OpenAI
();
const
response
=
await
client.responses.
create
({
model:
"gpt-5.6"
,
input: [
{
role:
"user"
,
content: [
{
type:
"input_text"
,
text:
"What is in this image?"
,
},
{
type:
"input_image"
,
image_url:
"https://openai-documentation.vercel.app/images/cat_and_otter.png"
,
detail:
"auto"
,
},
],
},
],
});
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
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5.6",
input=[
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "What teams are playing in this image?",
},
{
"type": "input_image",
"image_url": "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg",
},
],
}
],
)
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
24
25
26
27
28
29
30
31
32
package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.6",
Input: responses.ResponseNewParamsInputUnion{OfInputItemList: responses.ResponseInputParam{
responses.ResponseInputItemParamOfMessage(
responses.ResponseInputMessageContentListParam{
responses.ResponseInputContentParamOfInputText("What is in this image?"),
{OfInputImage: &responses.ResponseInputImageParam{
Detail: responses.ResponseInputImageDetailAuto,
ImageURL: openai.String("https://openai-documentation.vercel.app/images/cat_and_otter.png"),
}},
},
responses.EasyInputMessageRoleUser,
),
}},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
}
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;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
Uri imageUrl = new(
"https://openai-documentation.vercel.app/images/cat_and_otter.png"
);
ResponseResult response = await client.CreateResponseAsync(
"gpt-5.6",
[
ResponseItem.CreateUserMessageItem(
[
ResponseContentPart.CreateInputTextPart("What is in this image?"),
ResponseContentPart.CreateInputImagePart(imageUrl),
]
),
]
);
Console.WriteLine(response.GetOutputText());
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require "openai"
openai = OpenAI::Client.new
response = openai.responses.create(
model: "gpt-5.6",
input: [
{
role: "user",
content: [
{
type: "input_text",
text: "What teams are playing in this image?"
},
{
type: "input_image",
image_url: "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg"
}
]
}
]
)
puts(response.output_text)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
curl "https://api.openai.com/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-5.6",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "What is in this image?"
},
{
"type": "input_image",
"image_url": "https://openai-documentation.vercel.app/images/cat_and_otter.png"
}
]
}
]
}'
1
2
3
4
5
6
7
8
9
10
11
12
openai responses create \
--model gpt-5.6 \
--raw-output \
--transform 'output.#(type=="message").content.0.text' <<'YAML'
input:
- role: user
content:
- type: input_text
text: What is in this image?
- type: input_image
image_url: https://openai-documentation.vercel.app/images/cat_and_otter.png
YAML
File URL
Use a file URL as input
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import
OpenAI
from
"openai"
;
const
client
=
new
OpenAI
();
const
response
=
await
client.responses.
create
({
model:
"gpt-5.6"
,
input: [
{
role:
"user"
,
content: [
{
type:
"input_text"
,
text:
"Analyze the letter and provide a summary of the key points."
,
},
{
type:
"input_file"
,
file_url:
"https://www.berkshirehathaway.com/letters/2024ltr.pdf"
,
},
],
},
],
});
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
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5.6",
input=[
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Analyze the letter and provide a summary of the key points.",
},
{
"type": "input_file",
"file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf",
},
],
},
],
)
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.6",
Input: responses.ResponseNewParamsInputUnion{
OfInputItemList: responses.ResponseInputParam{
responses.ResponseInputItemParamOfMessage(
responses.ResponseInputMessageContentListParam{
responses.ResponseInputContentParamOfInputText(
"Analyze the letter and provide a summary of the key points.",
),
{
OfInputFile: &responses.ResponseInputFileParam{
FileURL: openai.String(
"https://www.berkshirehathaway.com/letters/2024ltr.pdf",
),
},
},
},
responses.EasyInputMessageRoleUser,
),
},
},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
}
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
using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
Uri fileUrl = new(
"https://www.berkshirehathaway.com/letters/2024ltr.pdf"
);
ResponseResult response = await client.CreateResponseAsync(
"gpt-5.6",
[
ResponseItem.CreateUserMessageItem(
[
ResponseContentPart.CreateInputTextPart(
"Analyze the letter and provide a summary of the key points."
),
ResponseContentPart.CreateInputFilePart(fileUrl),
]
),
]
);
Console.WriteLine(response.GetOutputText());
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require "openai"
openai = OpenAI::Client.new
response = openai.responses.create(
model: "gpt-5.6",
input: [
{
role: "user",
content: [
{
type: "input_text",
text: "Analyze the letter and provide a summary of the key points."
},
{
type: "input_file",
file_url: "https://www.berkshirehathaway.com/letters/2024ltr.pdf"
}
]
}
]
)
puts(response.output_text)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
curl "https://api.openai.com/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-5.6",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Analyze the letter and provide a summary of the key points."
},
{
"type": "input_file",
"file_url": "https://www.berkshirehathaway.com/letters/2024ltr.pdf"
}
]
}
]
}'
Upload file
Upload a file and use it as input
JavaScript
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
29
import
fs
from
"fs"
;
import
OpenAI
from
"openai"
;
const
client
=
new
OpenAI
();
const
file
=
await
client.files.
create
({
file: fs.
createReadStream
(
"fixtures/draconomicon.pdf"
),
purpose:
"user_data"
,
});
const
response
=
await
client.responses.
create
({
model:
"gpt-5.6"
,
input: [
{
role:
"user"
,
content: [
{
type:
"input_file"
,
file_id: file.id,
},
{
type:
"input_text"
,
text:
"What is the first dragon in the book?"
,
},
],
},
],
});
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()
file = client.files.create(file=open("draconomicon.pdf", "rb"), purpose="user_data")
response = client.responses.create(
model="gpt-5.6",
input=[
{
"role": "user",
"content": [
{
"type": "input_file",
"file_id": file.id,
},
{
"type": "input_text",
"text": "What is the first dragon in the book?",
},
],
}
],
)
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"context"
"fmt"
"os"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
file, err := os.Open("draconomicon.pdf")
if err != nil {
panic(err)
}
defer file.Close()
uploadedFile, err := client.Files.New(context.Background(), openai.FileNewParams{
File: file,
Purpose: openai.FilePurposeUserData,
})
if err != nil {
panic(err)
}
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.6",
Input: responses.ResponseNewParamsInputUnion{
OfInputItemList: responses.ResponseInputParam{
responses.ResponseInputItemParamOfMessage(
responses.ResponseInputMessageContentListParam{
{
OfInputFile: &responses.ResponseInputFileParam{
FileID: openai.String(uploadedFile.ID),
},
},
responses.ResponseInputContentParamOfInputText(
"What is the first dragon in the book?",
),
},
responses.EasyInputMessageRoleUser,
),
},
},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
}
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
29
using OpenAI.Files;
using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
OpenAIFileClient files = new(key);
OpenAIFile file = await files.UploadFileAsync(
"draconomicon.pdf",
FileUploadPurpose.UserData
);
ResponseResult response = await client.CreateResponseAsync(
"gpt-5.6",
[
ResponseItem.CreateUserMessageItem(
[
ResponseContentPart.CreateInputFilePart(file.Id),
ResponseContentPart.CreateInputTextPart(
"What is the first dragon in the book?"
),
]
),
]
);
Console.WriteLine(response.GetOutputText());
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require "openai"
openai = OpenAI::Client.new
file = openai.files.create(
file: File.open("draconomicon.pdf", "rb"),
purpose: "user_data"
)
response = openai.responses.create(
model: "gpt-5.6",
input: [
{
role: "user",
content: [
{type: "input_file", file_id: file.id},
{type: "input_text", text: "What is the first dragon in the book?"}
]
}
]
)
puts(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
curl https://api.openai.com/v1/files \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F purpose="user_data" \
-F file="@draconomicon.pdf"
curl "https://api.openai.com/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-5.6",
"input": [
{
"role": "user",
"content": [
{
"type": "input_file",
"file_id": "file-6F2ksmvXxt4VdoqmHRw6kL"
},
{
"type": "input_text",
"text": "What is the first dragon in the book?"
}
]
}
]
}'
Image inputs guide
Learn to use image inputs to the model and extract meaning from images.
File inputs guide
Learn to use file inputs to the model and extract meaning from documents.
Extend the model with tools
Give the model access to external data and functions by attaching
tools
. Use built-in tools like web search or file search, or define your own for calling APIs, running code, or integrating with third-party systems.
Web search
File search
Code Interpreter
Function calling
Remote MCP
Web search
Use web search in a response
JavaScript
1
2
3
4
5
6
7
8
9
10
import
OpenAI
from
"openai"
;
const
client
=
new
OpenAI
();
const
response
=
await
client.responses.
create
({
model:
"gpt-5.6"
,
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
11
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5.6",
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
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.6",
Tools: []responses.ToolUnionParam{
responses.ToolParamOfWebSearch(responses.WebSearchToolTypeWebSearch),
},
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("What was a positive news story from today?")},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-5.6" };
options.Tools.Add(ResponseTool.CreateWebSearchTool());
options.InputItems.Add(
ResponseItem.CreateUserMessageItem("What was a positive news story from today?")
);
ResponseResult response = await client.CreateResponseAsync(options);
Console.WriteLine(response.GetOutputText());
1
2
3
4
5
6
7
8
9
10
11
require "openai"
openai = OpenAI::Client.new
response = openai.responses.create(
model: "gpt-5.6",
tools: [{type: "web_search"}],
input: "What was a positive news story from today?"
)
puts(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.6",
"tools": [{"type": "web_search"}],
"input": "what was a positive news story from today?"
}'
1
2
3
4
5
6
7
8
openai responses create \
--model gpt-5.6 \
--raw-output \
--transform 'output.#(type=="message").content.0.text' <<'YAML'
tools:
- type: web_search
input: What was a positive news story from today?
YAML
File search
Search your files in a response
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import
OpenAI
from
"openai"
;
const
openai
=
new
OpenAI
();
const
response
=
await
openai.responses.
create
({
model:
"gpt-5.6"
,
input:
"What is deep research by OpenAI?"
,
tools: [
{
type:
"file_search"
,
vector_store_ids: [
"<vector_store_id>"
],
},
],
});
console.
log
(response);
1
2
3
4
5
6
7
8
9
10
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5.6",
input="What is deep research by OpenAI?",
tools=[{"type": "file_search", "vector_store_ids": ["<vector_store_id>"]}],
)
print(response)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.6",
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("What is deep research by OpenAI?")},
Tools: []responses.ToolUnionParam{responses.ToolParamOfFileSearch([]string{"<vector_store_id>"})},
})
if err != nil {
panic(err)
}
fmt.Println(response)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-5.6" };
options.Tools.Add(
ResponseTool.CreateFileSearchTool(["<vector_store_id>"])
);
options.InputItems.Add(
ResponseItem.CreateUserMessageItem("What is deep research by OpenAI?")
);
ResponseResult response = await client.CreateResponseAsync(options);
Console.WriteLine(response.GetOutputText());
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require "openai"
openai = OpenAI::Client.new
response = openai.responses.create(
model: "gpt-5.6",
input: "What is deep research by OpenAI?",
tools: [
{
type: "file_search",
vector_store_ids: ["<vector_store_id>"]
}
]
)
puts(response)
Code Interpreter
Use Code Interpreter in a response
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import
OpenAI
from
"openai"
;
const
client
=
new
OpenAI
();
const
response
=
await
client.responses.
create
({
model:
"gpt-5.6"
,
instructions:
"You are a personal math tutor. When asked a math question, write and run code to answer the question."
,
tools: [
{
type:
"code_interpreter"
,
container: { type:
"auto"
},
},
],
input:
"I need to solve the equation 3x + 11 = 14. Can you help me?"
,
});
console.
log
(response.output_text);
1
2
3
4
5
6
7
8
9
10
11
12
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-5.6",
instructions="You are a personal math tutor. When asked a math question, write and run code to answer the question.",
tools=[{"type": "code_interpreter", "container": {"type": "auto"}}],
input="I need to solve the equation 3x + 11 = 14. Can you help 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
24
25
package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.6",
Instructions: openai.String("You are a personal math tutor. When asked a math question, write and run code to answer the question."),
Tools: []responses.ToolUnionParam{
responses.ToolParamOfCodeInterpreter(responses.ToolCodeInterpreterContainerCodeInterpreterContainerAutoParam{}),
},
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("I need to solve the equation 3x + 11 = 14. Can you help me?")},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require "openai"
openai = OpenAI::Client.new
response = openai.responses.create(
model: "gpt-5.6",
instructions: "You are a personal math tutor. When asked a math question, write and run code to answer the question.",
tools: [
{
type: "code_interpreter",
container: {type: "auto"}
}
],
input: "I need to solve the equation 3x + 11 = 14. Can you help me?"
)
puts(response.output_text)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-5.6",
"instructions": "You are a personal math tutor. When asked a math question, write and run code to answer the question.",
"tools": [
{
"type": "code_interpreter",
"container": { "type": "auto" }
}
],
"input": "I need to solve the equation 3x + 11 = 14. Can you help me?"
}'
Function calling
Call your own function
JavaScript
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
29
30
31
32
33
import
OpenAI
from
"openai"
;
const
client
=
new
OpenAI
();
/**
@type
{OpenAI.Responses.Tool[]}
*/
const
tools
=
[
{
type:
"function"
,
name:
"get_weather"
,
description:
"Get current temperature for a given location."
,
parameters: {
type:
"object"
,
properties: {
location: {
type:
"string"
,
description:
"City and country e.g. Bogotá, Colombia"
,
},
},
required: [
"location"
],
additionalProperties:
false
,
},
strict:
true
,
},
];
const
response
=
await
client.responses.
create
({
model:
"gpt-5.6"
,
input: [
{ role:
"user"
, content:
"What is the weather like in Paris today?"
},
],
tools,
});
console.
log
(response.output[
0
]);
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
29
30
31
32
33
from openai import OpenAI
client = OpenAI()
tools = [
{
"type": "function",
"name": "get_weather",
"description": "Get current temperature for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and country e.g. Bogotá, Colombia",
}
},
"required": ["location"],
"additionalProperties": False,
},
"strict": True,
},
]
response = client.responses.create(
model="gpt-5.6",
input=[
{"role": "user", "content": "What is the weather like in Paris today?"},
],
tools=tools,
)
print(response.output[0].to_json())
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
29
30
31
32
33
34
35
36
37
38
package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
parameters := map[string]any{
"type": "object",
"properties": map[string]any{
"location": map[string]any{
"type": "string",
"description": "City and country e.g. Bogotá, Colombia",
},
},
"required": []string{"location"},
"additionalProperties": false,
}
tool := responses.ToolParamOfFunction("get_weather", parameters, true)
tool.OfFunction.Description = openai.String("Get current temperature for a given location.")
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.6",
Input: responses.ResponseNewParamsInputUnion{OfInputItemList: responses.ResponseInputParam{
responses.ResponseInputItemParamOfMessage("What is the weather like in Paris today?", responses.EasyInputMessageRoleUser),
}},
Tools: []responses.ToolUnionParam{tool},
})
if err != nil {
panic(err)
}
fmt.Println(response.Output)
}
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
using OpenAI.Responses;
#pragma warning disable CA1869
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-5.6" };
options.Tools.Add(
ResponseTool.CreateFunctionTool(
functionName: "get_weather",
functionDescription: "Get current temperature for a given location.",
functionParameters: BinaryData.FromString(
"""
{
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and country e.g. Bogotá, Colombia"
}
},
"required": ["location"],
"additionalProperties": false
}
"""
),
strictModeEnabled: true
)
);
options.InputItems.Add(
ResponseItem.CreateUserMessageItem("What is the weather like in Paris today?")
);
ResponseResult response = client.CreateResponse(options);
Console.WriteLine(
JsonSerializer.Serialize(
response.OutputItems[0],
new JsonSerializerOptions
{
TypeInfoResolver = new DefaultJsonTypeInfoResolver(),
}
)
);
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
29
30
31
32
33
require "openai"
openai = OpenAI::Client.new
tools = [
{
type: "function",
name: "get_weather",
description: "Get current temperature for a given location.",
parameters: {
type: "object",
properties: {
location: {
type: "string",
description: "City and country e.g. Bogotá, Colombia"
}
},
required: ["location"],
additionalProperties: false
},
strict: true
}
]
response = openai.responses.create(
model: "gpt-5.6",
input: [
{role: "user", content: "What is the weather like in Paris today?"}
],
tools: tools
)
puts(response.output.first.to_json)
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
curl -X POST https://api.openai.com/v1/responses \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6",
"input": [
{"role": "user", "content": "What is the weather like in Paris today?"}
],
"tools": [
{
"type": "function",
"name": "get_weather",
"description": "Get current temperature for a given location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City and country e.g. Bogotá, Colombia"
}
},
"required": ["location"],
"additionalProperties": false
},
"strict": true
}
]
}'
Remote MCP
Call a remote MCP server
curl
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": "gpt-5.6",
"tools": [
{
"type": "mcp",
"server_label": "dmcp",
"server_description": "A Dungeons and Dragons MCP server to assist with dice rolling.",
"server_url": "https://dmcp-server.deno.dev/mcp",
"require_approval": "never"
}
],
"input": "Roll 2d4+1"
}'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import OpenAI from "openai";
const client = new OpenAI();
const resp = await client.responses.create({
model: "gpt-5.6",
tools: [
{
type: "mcp",
server_label: "dmcp",
server_description:
"A Dungeons and Dragons MCP server to assist with dice rolling.",
server_url: "https://dmcp-server.deno.dev/mcp",
require_approval: "never",
},
],
input: "Roll 2d4+1",
});
console.log(resp.output_text);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from openai import OpenAI
client = OpenAI()
resp = client.responses.create(
model="gpt-5.6",
tools=[
{
"type": "mcp",
"server_label": "dmcp",
"server_description": "A Dungeons and Dragons MCP server to assist with dice rolling.",
"server_url": "https://dmcp-server.deno.dev/mcp",
"require_approval": "never",
},
],
input="Roll 2d4+1",
)
print(resp.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
27
package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
tool := responses.ToolParamOfMcp("dmcp")
tool.OfMcp.ServerDescription = openai.String("A Dungeons and Dragons MCP server to assist with dice rolling.")
tool.OfMcp.ServerURL = openai.String("https://dmcp-server.deno.dev/mcp")
tool.OfMcp.RequireApproval = responses.ToolMcpRequireApprovalUnionParam{OfMcpToolApprovalSetting: openai.String("never")}
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.6",
Tools: []responses.ToolUnionParam{tool},
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("Roll 2d4+1")},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new() { Model = "gpt-5.6" };
options.Tools.Add(
ResponseTool.CreateMcpTool(
serverLabel: "dmcp",
serverUri: new Uri("https://dmcp-server.deno.dev/mcp"),
toolCallApprovalPolicy: GlobalMcpToolCallApprovalPolicy.NeverRequireApproval
)
);
options.InputItems.Add(ResponseItem.CreateUserMessageItem("Roll 2d4+1"));
ResponseResult response = await client.CreateResponseAsync(options);
Console.WriteLine(response.GetOutputText());
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require "openai"
openai = OpenAI::Client.new
response = openai.responses.create(
model: "gpt-5.6",
tools: [
{
type: "mcp",
server_label: "dmcp",
server_description: "A Dungeons and Dragons MCP server to assist with dice rolling.",
server_url: "https://dmcp-server.deno.dev/mcp",
require_approval: "never"
}
],
input: "Roll 2d4+1"
)
puts(response.output_text)
Use built-in tools
Learn about powerful built-in tools like web search and file search.
Function calling guide
Learn to enable the model to call your own custom code.
Stream responses and build real-time apps
Use server‑sent
streaming events
to show results as they’re generated, or use the
Realtime API
for interactive voice apps and apps with text, audio, and image inputs.
Stream server-sent events from the API
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import
{ OpenAI }
from
"openai"
;
const
client
=
new
OpenAI
();
const
stream
=
await
client.responses.
create
({
model:
"gpt-5.6"
,
input: [
{
role:
"user"
,
content:
"Say 'double bubble bath' ten times fast."
,
},
],
stream:
true
,
});
for
await
(
const
event
of
stream) {
console.
log
(event);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from openai import OpenAI
client = OpenAI()
stream = client.responses.create(
model="gpt-5.6",
input=[
{
"role": "user",
"content": "Say 'double bubble bath' ten times fast.",
},
],
stream=True,
)
for event in stream:
print(event)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
stream := client.Responses.NewStreaming(context.Background(), responses.ResponseNewParams{
Model: "gpt-5.6",
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("Say 'double bubble bath' ten times fast.")},
})
for stream.Next() {
fmt.Println(stream.Current().Type)
}
if err := stream.Err(); err != nil {
panic(err)
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
var responses = client.CreateResponseStreamingAsync(
"gpt-5.6",
"Say 'double bubble bath' ten times fast."
);
await foreach (StreamingResponseUpdate response in responses)
{
if (response is StreamingResponseOutputTextDeltaUpdate delta)
{
Console.Write(delta.Delta);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require "openai"
openai = OpenAI::Client.new
stream = openai.responses.stream(
model: "gpt-5.6",
input: [
{
role: "user",
content: "Say 'double bubble bath' ten times fast."
}
]
)
stream.each do |event|
puts(event)
end
Use streaming events
Use server-sent events to stream model responses to users fast.
Get started with the Realtime API
Use WebRTC or WebSockets for super fast speech-to-speech AI apps.
Build agents
Use the OpenAI platform to build
agents
capable of taking action—like
controlling computers
—on behalf of your users. Use the
Agents SDK
to create orchestration logic on your server.
Build a language triage agent
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import
{ Agent, run }
from
"@openai/agents"
;
const
spanishAgent
=
new
Agent
({
name:
"Spanish agent"
,
instructions:
"You only speak Spanish."
,
});
const
englishAgent
=
new
Agent
({
name:
"English agent"
,
instructions:
"You only speak English"
,
});
const
triageAgent
=
new
Agent
({
name:
"Triage agent"
,
instructions:
"Handoff to the appropriate agent based on the language of the request."
,
handoffs: [spanishAgent, englishAgent],
});
const
result
=
await
run
(triageAgent,
"Hola, ¿cómo estás?"
);
console.
log
(result.finalOutput);
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
from agents import Agent, Runner
import asyncio
spanish_agent = Agent(
name="Spanish agent",
instructions="You only speak Spanish.",
)
english_agent = Agent(
name="English agent",
instructions="You only speak English",
)
triage_agent = Agent(
name="Triage agent",
instructions="Handoff to the appropriate agent based on the language of the request.",
handoffs=[spanish_agent, english_agent],
)
async def main():
result = await Runner.run(triage_agent, input="Hola, ¿cómo estás?")
print(result.final_output)
if __name__ == "__main__":
asyncio.run(main())
Build agents that can take action
Learn how to use the OpenAI platform to build powerful, capable AI agents.
Next
Using GPT-5.6
Ask AI
Docs agent
Loading docs agent...
