This page covers the main ways to build with the OpenAI API: official SDKs for application code, the OpenAI CLI for shell-native workflows, the Agents SDK for orchestration, or your own preferred HTTP client.
Create and export 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
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"