Skip to content

OpenAI API Request Builder

Build a chat API request for OpenAI, Claude, Gemini, Groq or Ollama in cURL, Python, JS or PHP.

Language

Quick Tool Overview

The OpenAI API Request Builder writes working chat API calls for OpenAI, Anthropic Claude, Gemini, Mistral, Groq, DeepSeek, OpenRouter, Ollama and any OpenAI-compatible server, in cURL, Python, JavaScript or PHP, with provider differences handled.

What it does
Generates LLM API request code
You give it
A provider, model, messages and options
You get back
Runnable code in cURL, Python, JavaScript or PHP
Best for
First API calls, debugging and quick scripts
AI Tools Free, unlimited use No sign-up Runs in your browser

About the OpenAI API Request Builder

The first working API call is often the slowest one: which endpoint, which header carries the key, whether the limit is max_tokens or max_completion_tokens, where the system prompt goes, and why a perfectly reasonable temperature returns an error. This builder writes a correct request for you.

Choose a provider — OpenAI, Anthropic, Google Gemini through its OpenAI-compatible endpoint, Mistral, Groq, DeepSeek, OpenRouter, a local Ollama server or any OpenAI-compatible endpoint — and a language: cURL, Python with requests, JavaScript with fetch, or PHP with cURL. Set the model, system prompt, user message, output limit, temperature, streaming and JSON mode, and the code updates as you type.

Provider differences are handled rather than left for you to discover: the Anthropic request uses x-api-key, anthropic-version and a top-level system field and reads only the text blocks of the response; sampling settings are left out for models that reject them; and JSON mode warns when the messages never mention JSON. Keys are always read from environment variables, never written into the code.

Key features of the OpenAI API Request Builder

Nine providers

OpenAI, Anthropic, Gemini, Mistral, Groq, DeepSeek, OpenRouter, Ollama and custom endpoints.

Four languages

cURL, Python with requests, JavaScript with fetch and PHP with cURL.

Provider quirks handled

Anthropic headers and system field, max_completion_tokens for OpenAI, text-only response parsing.

Invalid parameters avoided

Temperature is left out for models that reject it, with the reason shown.

Keys stay out of code

Every snippet reads the API key from an environment variable.

How to use the OpenAI API Request Builder

  1. 1

    Choose a provider and model

    The endpoint and a sensible default model fill in. Both stay editable.

  2. 2

    Pick a language

    cURL for the terminal, Python, JavaScript for Node, or PHP.

  3. 3

    Write the messages

    A system prompt and a user message, plus the output limit and options.

  4. 4

    Set the key and run

    Export the named environment variable with your API key, then run the code.

Frequently asked questions

Send a POST request to https://api.openai.com/v1/chat/completions with an Authorization: Bearer header containing your key and a JSON body with the model and a messages array. The cURL tab writes the full command.

Reviews of the OpenAI API Request Builder

What people who use the OpenAI API Request Builder think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the OpenAI API Request Builder. It takes half a minute and no account.

Write the first review

More AI tools