Converter tool

LLM API Request and cURL Builder

Fill in a form and get the request body plus cURL, JavaScript fetch and Python requests code for a chat completion call, with the API key left as a placeholder.

Messages

Import an OpenAI-compatible request

There is no field for a real API key on purpose. The snippets read the key from $API_KEY, process.env or os.environ. Never paste a key into a web page. Nothing here is sent anywhere: the snippets are built in this tab. Some OpenAI-compatible models want max_completion_tokens instead of max_tokens; rename it in the body if the API says so.

Preview

Output Preview

{
  "model": "my-model",
  "messages": [
    {
      "role": "system",
      "content": "Be brief"
    },
    {
      "role": "user",
      "content": "Hi"
    }
  ]
}

LLM API Request and cURL Builder

Operator: Abdulla Al Fahad. How tools are built and checked

Most chat model APIs ask for the same few things, a model name, some messages and a handful of sampling settings, but each one wraps them differently. One puts the system prompt inside the messages array, another lifts it to a top-level field, a third renames roles and nests text in parts. This builder lets you type the request once in a form and see the exact JSON body for each layout, plus ready-to-run cURL, JavaScript fetch and Python requests code.

It is meant for testing a prompt from a terminal, writing the first draft of an integration, or explaining a request to a colleague. It never sends anything: it only produces text. Use it with a key from your own environment.

Key features

  • Three layouts with the right field names, nesting and URL for each
  • System prompt, user and assistant rows, temperature, max tokens, top_p and stop sequences
  • JSON-output toggle where the layout has one
  • JSON body, cURL, JavaScript fetch and Python requests tabs, each with a copy button
  • The key is only ever $API_KEY, process.env.API_KEY or os.environ["API_KEY"]
  • Checks for a missing model, empty messages, non-integer max tokens and out-of-range sampling values
  • Import of an existing OpenAI-compatible request body to fill the form

How the three provider layouts differ

Three layouts are offered: OpenAI-compatible chat completions, Anthropic messages and Google Gemini generateContent. They are written from each provider's public documentation at the time of writing. Providers add and rename fields, so check the current reference before shipping code that relies on a specific field.

In the first layout the system prompt becomes the first message with role system, and max_tokens, temperature, top_p, stop and response_format sit beside model and messages. The form always writes max_tokens; some newer models in that family expect max_completion_tokens instead, so rename the field in the JSON body if the API rejects max_tokens. In the Anthropic layout the system prompt is a top-level system string, max_tokens is required, stop sequences are called stop_sequences, and there is no JSON-output switch here. In the Gemini layout roles are user and model, text sits in parts, system text goes in systemInstruction, and sampling settings are grouped under generationConfig; the model name goes in the URL, not the body.

Messages are limited to plain text user and assistant turns. Images, tool definitions, streaming flags and provider-specific options are outside the form, though you can edit the generated body by hand.

How it works

Each change in the form rebuilds the request in memory. Empty optional fields are left out of the body instead of being sent as null, so a blank temperature means the provider default applies.

Numbers are parsed strictly. Max tokens must be a whole number of 1 or more; "1,024" or "512 tokens" is rejected with a message instead of being guessed. Temperature is allowed from 0 to 2 in two layouts and 0 to 1 in the Anthropic layout, and top_p from 0 to 1.

The cURL tab wraps the pretty-printed body in single quotes and escapes any single quote inside your text so the shell keeps it intact. The key line keeps $API_KEY as text for the shell to fill in, so run export API_KEY=... first. The fetch tab reads process.env.API_KEY and the Python tab reads os.environ.

Import takes an OpenAI-compatible body, moves system and developer messages into the system prompt field, keeps user and assistant turns, and lists any fields the form cannot hold, such as tools.

Typical uses

  • Reproducing a failing call from the terminal to see the raw response
  • Moving a prompt from one provider's layout to another's without retyping it
  • Giving a teammate a copy-ready snippet for a prototype
  • Checking where the system prompt belongs in an unfamiliar API
  • Turning a request body copied from a log into a form you can edit

Building one

  1. Pick the layout that matches the API you are calling and, for the first layout, adjust the base URL if you use a compatible server.
  2. Enter the model name exactly as your provider lists it.
  3. Write the system prompt and the message rows. Add rows for earlier turns if you want a multi-turn request.
  4. Set temperature, max tokens, top_p and stop sequences only if you need them.
  5. Open a tab, check the code, and press its copy button. Export your key in the shell or environment before running it.

Example

System "Be brief", user "Hi", model "my-model", Anthropic layout, max tokens 256

layout: Anthropic messages
model: my-model
system: Be brief
user: Hi
max tokens: 256

JSON body

{
  "model": "my-model",
  "max_tokens": 256,
  "system": "Be brief",
  "messages": [
    {
      "role": "user",
      "content": "Hi"
    }
  ]
}

Tips for best results

  • Keep max tokens modest while testing; a long answer is slower and uses more of your quota.
  • Put a sentinel word in the system prompt when testing, so you can see in the reply whether it was applied.
  • Export the key in the same shell session you run the cURL command in.
  • Run the JSON body through a linter if you edit it by hand after copying.

Things to check before you rely on it

Never paste a real API key into a web page, this one included. The form has no key field for that reason.

A layout can be out of date. Providers revise field names and limits, so confirm against their current documentation.

The Gemini model name is in the URL. If you edit the body only, the call still goes to the model named in the URL.

Single quotes in your prompt are escaped for the shell. If you run the command in Windows cmd instead of a Unix-style shell, rewrite the quoting.

A compatible server may not support every field, such as response_format or stop.

Common errors and how to fix them

"Max tokens is required for the Anthropic layout."
That layout expects max_tokens in every request. Enter a whole number such as 1024.
"Max tokens must be a whole number of 1 or more."
Remove decimals, commas and unit words. Type 2048, not 2,048 or 2048 tokens.
"No messages array found" on import
Import reads OpenAI-compatible bodies only. Paste the JSON that contains model and messages at its top level.

Best practices

  • Store keys in environment variables or a secrets manager, never in the snippet itself.
  • Version the prompt text in your own repository; copy it from there into the form.
  • Test with one short message before building a long conversation.

Frequently asked questions

Does this call the API for me?

No. It writes the request as text. You run the cURL, fetch or Python code yourself.

Where does the API key go?

The snippets read it from $API_KEY, process.env.API_KEY or os.environ["API_KEY"]. You set that variable on your own machine.

Why is there no JSON toggle for Anthropic?

This form has no JSON-output switch for the Anthropic layout. Check the provider's current documentation for any structured-output feature, or ask for JSON in the prompt.

Is anything stored?

The form values and the generated snippets live in this tab's memory and are gone on reload. The page makes no request with them.