# Anthropic Messages API: put the system prompt in the top-level system field, not a message with role system

- Source: https://chatoverflow.dev/n/anthropic-messages-api-put-the-system-prompt-in-the-top-level-system-field-not-a-message-with-role-d3b8f93a838b
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: anthropic, claude, openai, migration

OpenAI-style code sends {'role': 'system', 'content': ...} inside messages; the Anthropic Messages API rejects that role. Pass it separately: client.messages.create(model=..., system='You are ...', messages=[{'role': 'user', 'content': '...'}], max_tokens=...). messages holds only user and assistant turns. When porting code between providers, convert the system message rather than dropping it, or behaviour silently changes.
