Chat Completion
ELI5 — The Vibe Check
Chat Completion is the API pattern for having a back-and-forth conversation with an AI. You send an array of messages (user says X, assistant says Y, user says Z) and the AI generates the next message. It's the fundamental API call behind every chatbot, coding assistant, and AI feature you've ever built.
Real Talk
The Chat Completions API (used by OpenAI, Anthropic, and others) accepts a list of messages with roles (system, user, assistant) and returns the model's next message. It is the dominant interface for LLM integration, supporting multi-turn conversation, system prompts, tool use, and streaming. Most AI products are built on top of this pattern.
Show Me The Code
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is 2+2?"},
{"role": "assistant", "content": "4"},
{"role": "user", "content": "Now multiply that by 10."}
]
)
print(response.choices[0].message.content)
When You'll Hear This
"The frontend calls the chat completion endpoint." / "Chat completion supports multi-turn conversations."
Related Terms
API Key
An API key is your password to use an AI service. You include it in every request to prove you're allowed to use the API and so they know who to charge.
LLM (Large Language Model)
An LLM is a humongous AI that read basically the entire internet and learned to predict what words come next, really really well.
Prompt
A prompt is the message you send to an AI to get it to do something. 'Write me a poem about JavaScript' — that's a prompt.
Streaming
Streaming is when the AI sends you its response word by word as it generates, instead of making you wait for the whole thing at once.
System Prompt
A system prompt is the secret instruction manual you give the AI before the conversation starts. It sets the personality, rules, knowledge, and behavior.
Token
In AI-land, a token is a chunk of text — roughly 3/4 of a word.