OpenAI API beginner's guide — what it is, how it works, when to use it
With any new API, the hardest part is figuring out what it actually does and where it's useful. Let's start there.
What is OpenAI API?
The API for ChatGPT, GPT-4 and DALL-E. The world's most-used AI API.
OpenAI's API is the world's most used for building AI products. It covers GPT models for chat/text, DALL-E for images, Whisper for transcription, TTS for speech, and embeddings for semantic search. Priced per token, competitive at the high end. Hebrew quality is excellent from GPT-4 up.
Who it's for
- Any AI-embedded project
- SaaS companies
- Chatbots
- Writing tools
A first example
Here is the shortest path to seeing something work:
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "system", content: "אתה עוזר בעברית." },
{ role: "user", content: "מה מזג האוויר בתל אביב?" },
],
});
console.log(response.choices[0].message.content);When to use it, when not to
OpenAI API is a great fit for most of what it covers, but not every case. If you only need small, static data once or twice, it may be simpler to download and cache locally. For real products that need fresh data, the API is the way.