The OpenAI API lives at https://api.openai.com/v1. Every call needs an API key. The Responses API is the current way to generate text; Chat Completions still works and is what most existing code uses.
Create a key at platform.openai.com/api-keys and send it as Authorization: Bearer <key>. In the examples it's written {{OPENAI_API_KEY}}.
Full reference: https://developers.openai.com/api/docs
One input string in, model output out. The text is in output[].content[].text.
curl https://api.openai.com/v1/responses \
-H "Authorization: Bearer {{OPENAI_API_KEY}}" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-6-sol", "input": "Write a haiku about HTTP status codes."}'
The older messages-array format. The reply is in choices[0].message.content.
curl https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer {{OPENAI_API_KEY}}" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-sol",
"messages": [
{"role": "system", "content": "You are a terse assistant."},
{"role": "user", "content": "What does HTTP 418 mean?"}
]
}'
Turns text into a vector for search and clustering. The vector is data[0].embedding.
curl https://api.openai.com/v1/embeddings \
-H "Authorization: Bearer {{OPENAI_API_KEY}}" \
-H "Content-Type: application/json" \
-d '{"model": "text-embedding-3-small", "input": "The quick brown fox"}'
Returns the image as base64 in data[0].b64_json, PNG by default.
curl https://api.openai.com/v1/images/generations \
-H "Authorization: Bearer {{OPENAI_API_KEY}}" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-image-2.5-flare", "prompt": "A taco wearing sunglasses, flat illustration"}'
Every model your key can use — a quick way to check a key works.
curl https://api.openai.com/v1/models \
-H "Authorization: Bearer {{OPENAI_API_KEY}}"