Lesson 4 / 27
Anthropic and OpenAI Side by Side
Learn the main differences so you can read either provider's docs.
Same ideas, different spellings
Both APIs take a model name, a list of role-tagged messages and settings; both return a reply, a reason the generation stopped and token usage. Typical differences: authentication header (x-api-key plus anthropic-version for Anthropic; Authorization: Bearer for OpenAI); system prompt (a separate top-level system field for Anthropic; a message with role system, or instructions in the newer Responses API, for OpenAI); max_tokens (required for Anthropic Messages; optional for Chat Completions); reply location (content[0].text versus choices[0].message.content); stop reason names (end_turn, max_tokens, tool_use versus stop, length, tool_calls); and tool formats (input_schema versus a function with parameters). Model names and features change often, so read the current official docs and keep the model name in configuration.
A comparison table
Field names as of the SDK versions used for this course; check the docs for your version.
Anthropic (Messages) OpenAI (Chat Completions)
endpoint /v1/messages /v1/chat/completions (newer: /v1/responses)
auth x-api-key + anthropic-version Authorization: Bearer <key>
system prompt top-level "system" message with role "system"
max_tokens required optional
reply content[0].text choices[0].message.content
stop reasons end_turn / max_tokens / tool_use stop / length / tool_calls
usage input_tokens, output_tokens prompt_tokens, completion_tokens, total_tokens
tool schema input_schema function.parametersKeep a thin adapter
Wrap provider calls in one small module of your own so switching providers or upgrading an SDK touches one file.
Quick check: Where does Anthropic's Messages API put the system prompt?
- In the URL
- In a separate top-level system field
- In the API key
- Nowhere; it is not supported
Answer
In a separate top-level system field — Anthropic separates the system prompt from the messages list.