OpenAI Chat Messages Builder

Build and validate OpenAI chat completion messages arrays visually.

Construct an OpenAI chat completions messages array with system, user, and assistant turns in a visual editor, validate the role sequence, and export ready-to-paste JSON for the chat completions endpoint. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How does OpenAI's format differ from Anthropic's?

OpenAI puts the system prompt inside the messages array as a message with the system role, usually first. Anthropic uses a separate top-level system field. This builder follows the OpenAI convention.

OpenAI chat messages builder

The OpenAI chat completions endpoint takes a messages array where the system prompt is itself a message with the system role, usually first, followed by user and assistant turns. Typing that JSON by hand and getting the roles right is fiddly. This visual builder assembles the array, validates the common pitfalls, and exports a clean request body.

How it works

You add turns, pick a role for each from system, user, or assistant, and type the content. As you edit, the builder validates live: it confirms there is at least one user message and warns when a system message appears anywhere other than first, since that is rarely intended. When the structure looks right, it serialises a request body with a model field and the messages array, ready to copy. Nothing is sent — you call the API yourself with your own key.

Example output

A three-turn conversation — one system prompt, one user question, one assistant reply — produces JSON like this:

{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "system",
      "content": "You are a concise technical assistant. Answer in plain English without unnecessary preamble."
    },
    {
      "role": "user",
      "content": "What is the difference between a mutex and a semaphore?"
    },
    {
      "role": "assistant",
      "content": "A mutex is a lock owned by a single thread and released only by that thread. A semaphore is a counter that can be incremented and decremented by any thread, allowing a fixed number of concurrent accesses."
    }
  ]
}

Paste this directly into a curl call or your SDK’s client.chat.completions.create() call, swapping the model name for whichever model your API key can access.

OpenAI vs Anthropic: the format difference

The two providers structure their inputs differently:

AspectOpenAIAnthropic
System prompt locationInside messages as {"role":"system","content":"..."}Separate top-level system field
Required rolesAt least one userFirst message must be user
Alternation requirementNot strictStrict — must alternate user/assistant
First rolesystem or useruser

If you work with both providers, build each format separately and compare. The Anthropic Messages Builder is the companion tool for the Anthropic API format.

When to include prior assistant turns

Adding assistant turns to the messages array lets you prime the conversation: the model continues as if those previous exchanges actually happened. This is useful for:

  • Few-shot prompting — show the model a worked example before asking your real question.
  • Continuing a conversation — replay the history so the model has context for its next response.
  • Steering the response format — include an assistant turn that begins the answer in the format you want, and the model tends to continue it.

The builder supports all three scenarios. Add as many turns as you need, then copy the complete array.

Tips and notes

  • Lead with system. Put your instructions in a single system message at the top; the builder flags system messages placed later.
  • Edit the model name. The exported body uses a placeholder model; change it to whatever your key can access (gpt-4o, gpt-4o-mini, o3, etc.).
  • Alternate for clarity. OpenAI tolerates non-alternating turns, but a clean user/assistant rhythm is easier to reason about and debug.
  • Token costs scale with history. Every prior turn is re-sent on each API call. Keep few-shot examples short to avoid unnecessary cost.
  • Pair with the Anthropic builder. If you support both providers, build each format side by side to keep your prompts in sync.