DevTools Logo

OpenAI-Compatible Request Builder

OpenAI-Compatible Request Builder

Author chat-completion payloads and curl commands for OpenAI, Anthropic and Ollama — sendless by default.

Runs in your browser
    Try an example

    Request form

    2 messages · 0 tools
    Messages
    Tools

    Payload & response

    openai · /v1/chat/completions
    {
      "model": "gpt-4o-mini",
      "messages": [
        {
          "role": "system",
          "content": "You are a concise assistant."
        },
        {
          "role": "user",
          "content": "Explain what a chat completions payload is in one sentence."
        }
      ],
      "temperature": 0.7,
      "top_p": 1,
      "max_tokens": 1024,
      "stream": false
    }
    Optional local fire

    Nothing is sent until you click Run. The key lives in memory only and is never stored.

    Import an existing JSON body

    Fill a model, an ordered list of messages, sampling parameters, stop sequences and optional tool schemas; the tool emits pretty JSON, a POSIX-quoted curl command and dialect-specific headers. OpenAI output includes tools/tool_choice and response_format; Anthropic hoists system messages, requires max_tokens, clamps temperature and maps parameters to input_schema; Ollama nests settings under options and targets /api/chat. Every adjustment is listed as a warning. Nothing is sent by default: an opt-in card can fire at a localhost endpoint (non-local hosts need explicit confirmation), with abort support, SSE/NDJSON streaming and a response viewer. The API key stays in memory only. Paste an existing JSON body into the import box to keep editing it.

    • First chat call: Copy the JSON body or the complete curl command with correct headers — no stale docs needed.
    • Anthropic mapping: Warnings tell you exactly which fields were mapped or dropped for the target dialect.
    • Ollama native: Switching dialect changes the default endpoint too, so the emitted body matches the path.

    Examples

    First chat call

    Input
    model gpt-4o-mini · system + user message
    Output
    Pretty JSON body plus a curl command with Content-Type and Authorization

    A correct baseline without an account, SDK or copy-paste from stale docs.

    Same prompt, Anthropic

    Input
    system: You are concise · temperature 1.4
    Output
    system field hoisted, max_tokens 1024, temperature clamped to 1

    Warnings list every adjustment so no invalid field is silently invented.

    Function calling

    Input
    tool get_weather with JSON Schema parameters
    Output
    OpenAI tools[].function / Anthropic tools[].input_schema

    Ollama omits schemas with a note instead of emitting a body its endpoint ignores.

    About this tool

    The OpenAI-Compatible Request Builder turns a form into copy-ready JSON bodies, curl commands and header blocks for three chat dialects: OpenAI chat completions, Anthropic messages and Ollama /api/chat. Message roles, sampling parameters, stop sequences and tool schemas are edited once and remapped per dialect with an explicit warnings list.

    The mappings are deliberately concrete rather than hand-wavy: Anthropic hoists system messages, requires max_tokens, clamps temperature and maps tool parameters to input_schema; Ollama nests sampling settings under options and points at its native endpoint. Per-dialect headers are emitted too, including x-api-key and browser-access headers for Anthropic.

    Nothing is sent by default. The optional local-fire card requires a URL and an explicit Run click, guards non-local hosts behind a confirmation checkbox, keeps the API key in memory only and supports abort plus streaming SSE or NDJSON parsing. Paste an existing JSON body back into the import box to continue editing it.

    What this tool does not do

    • Authoring tool only by default; it never sends a request until Run is clicked.
    • Tool schemas are emitted with basic validation, not full JSON Schema draft validation.
    • Browser fetch is subject to CORS and mixed-content rules; local servers may need explicit origin configuration.
    • No SDK code generation and no key storage.

    How to use this tool

    1. Pick a dialect

      Choose OpenAI, Anthropic or Ollama; the endpoint and mapping notes update immediately.

    2. Edit the conversation

      Add, reorder and retype messages, set sampling parameters and optionally add tool schemas with JSON Schema parameters.

    3. Copy the payload

      Switch between JSON, curl and headers, then copy or download. Warnings explain any dialect-specific adjustment.

    4. Optionally fire locally

      Point at a localhost endpoint, tick Run, watch the response and cancel if needed. No request is made without that click.

    Use cases

    Learning API anatomy

    See how messages, sampling and tools fit together before writing code.

    Cross-provider drafts

    Draft one conversation and emit equivalent payloads for three wire formats.

    Local model smoke tests

    Fire a request at your own Ollama instance and inspect the response without leaving the browser.

    Dialect mapping

    FieldEmitted form
    OpenAImodel, messages, temperature, top_p, max_tokens, tools, tool_choice
    Anthropicsystem hoisted, messages with content blocks, max_tokens, stop_sequences, input_schema
    Ollamaoptions{temperature, top_p, num_predict, stop, seed}, native /api/chat
    HeadersBearer placeholder / x-api-key + anthropic-version / Content-Type only
    StreamingSSE data: frames for OpenAI and Anthropic, NDJSON for Ollama

    The curl emitter uses POSIX single-quote escaping; a body containing an apostrophe is emitted as '\''.

    Common mistakes

    Mistake:Using the OpenAI endpoint path with an Ollama-native body.

    Fix:Switching dialect updates both the body and the default endpoint to /api/chat.

    Mistake:Copying Anthropic output with OpenAI headers.

    Fix:Headers are generated per dialect; do not replace them manually.

    Mistake:Enabling JSON mode without mentioning json in the prompt.

    Fix:The builder warns because OpenAI rejects that request with a 400.

    Mistake:Pasting a key into message text.

    Fix:A heuristic scan warns about secret-like strings; use the dedicated key field, which is memory-only.

    Frequently asked questions

    Does this tool send my prompt anywhere?

    No. By default it only authors text: pretty JSON, a curl command and headers. The optional Local fire card performs a fetch only after you enter a target URL and click Run. Non-local hosts require an extra confirmation checkbox, and the API key field is memory-only — it is never persisted or included in exports.

    How do I send the same prompt to Ollama or Claude?

    Switch dialect tabs. The builder rewrites the body and headers: Anthropic hoists system messages into a system field and requires max_tokens; Ollama nests sampling parameters under options and targets /api/chat. Warnings list fields that were clamped, mapped or omitted for each dialect.

    What fields does a chat completions request accept?

    The core is model plus an ordered messages array of system/user/assistant/tool messages. Common optional fields are temperature, top_p, max_tokens, stop, seed, stream, response_format and tools with tool_choice. The form exposes each of these with a matching dialect-specific emitter; reasoning-model token fields are noted with a warning.

    How does function calling appear in the payload?

    Add a tool with a name, description and JSON Schema parameters. OpenAI emits tools[].function plus tool_choice; Anthropic maps parameters to input_schema and uses its own tool_choice shapes. Ollama omits tool schemas with a visible note because its /api/chat body does not carry them.

    Why does my local request fail with a CORS error?

    Browser fetch is subject to CORS. For Ollama, set OLLAMA_ORIGINS (or --api-origin) to allow this page's origin and confirm the server is running. An HTTPS page cannot call a plain-HTTP LAN host because of mixed-content rules; use localhost or serve the endpoint over HTTPS. The builder shows these hints when a network error occurs.

    Can I import a payload I already wrote?

    Yes. Paste an existing OpenAI-style JSON body into the Import box in the output panel. The messages, model, sampling parameters, stop sequences and seed are parsed back into editable form fields, so you can tweak the request and re-emit it for any dialect.

    References & standards