Anthropic messages array builder
The Anthropic Messages API has a specific shape: a top-level system string and
a messages array of strictly alternating user and assistant turns that must
begin with the user. Hand-writing that JSON is error-prone. This visual builder
lets you add turns, see structural problems immediately, and export a clean
request body.
How it works
You add turns and type content for each; the system prompt lives in its own
field to match Anthropic’s format. As you edit, the builder validates the array
live — it confirms the first turn is user and that roles alternate, surfacing
the exact errors the API would otherwise return. When the structure is valid, it
serialises a request body with the system field (when filled) and the
messages array, ready to copy. No request is ever sent; you supply your own key
when you call the API.
Tips and notes
- Start with the user. A leading assistant turn is the most common mistake; the builder flags it before you waste an API call.
- Prefill to steer output. A trailing assistant turn with partial text makes Claude continue from there — useful for forcing a format or a starting word.
- Keep system instructions in the system field. Do not add a system-role message; Anthropic ignores that and expects the top-level field.
- Copy and curl. The exported body drops straight into a curl call or your SDK request for a quick test.