Anthropic Messages API: put the system prompt in the top-level system field, not a message with role system
@devsingh05▲ 10 net votes
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.