Skip to content
induwara.lk
induwara.lkDevelopers · AI APIs

AI API Request Builder, OpenAI, Anthropic & Gemini curl

Fill one form and copy a ready-to-run request for any major LLM chat endpoint, as a curl command plus equivalent Python and Node.js snippets. Runs entirely in your browser; no API key is ever requested. Sources cited below.

By Induwara AshinsanaUpdated Jul 9, 2026
Build an LLM API requestcurl · Python · Node.js
Provider

Editable, pick a suggestion or type any model ID.

Optional. Sets the assistant's behaviour.

Required, the prompt you want a reply to.

Higher = more random. 0 = deterministic.

Upper bound on the reply length.

OpenAI: Bearer token in the Authorization header; system and user turns both go inside the messages array.

Output
cURL command · request.sh
# OpenAI Chat Completions API, https://platform.openai.com/docs/api-reference/chat/create
curl https://api.openai.com/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "temperature": 1,
  "max_tokens": 1024
}'

Request shapes follow the official OpenAI, Anthropic and Google Gemini API references (cited below the tool). Your key is never entered, snippets read it from an environment variable. Text is JSON-escaped so quotes and newlines stay valid.

How it works

This is a deterministic string-construction tool, not an inference engine. It never calls the providers. For each provider it maps your form onto that API's documented request contract, so the command you copy matches the official reference field-for-field. Three things change between providers: the endpoint, the authentication header, and how the system and user messages are shaped.

  1. Endpoint and method. OpenAI and OpenAI-compatible providers use POST {base_url}/chat/completions. Anthropic uses POST /v1/messages. Gemini puts the model in the path, /v1beta/models/{model}:generateContent, swapping to :streamGenerateContent when streaming is on.
  2. Authentication. OpenAI sends Authorization: Bearer. Anthropic uses x-api-key plus a required anthropic-version: 2023-06-01 header. Gemini uses x-goog-api-key. The key itself is always an environment-variable placeholder, never a literal.
  3. Message shaping. OpenAI keeps the system and user turns inside one messages array. Anthropic pulls the system prompt out to a top-level system string (it is not a message role) and requires max_tokens. Gemini nests text under contents[].parts[].text and a separate system_instruction.
  4. Parameters.Temperature and token limits map to each API's field name, max_tokens for OpenAI and Anthropic, maxOutputTokens under generationConfig for Gemini. JSON mode becomes response_format (OpenAI) or response_mime_type (Gemini), and is omitted for Anthropic, which has no such flag.
  5. Escaping. Your system and user text is JSON-string-escaped, so quotes and newlines never break the body. curl bodies use a single-quoted JSON payload, with any literal single quote escaped for the shell, the copied command runs as-is.

The Python and Node.js tabs each give two variants: a dependency-free raw call (requests /fetch) and the provider's official SDK (openai, anthropic, google-genai). Every snippet carries a comment linking to the exact reference it was built from, and each field maps one-to-one to that reference, so you can trust the copied request without cross-checking three docs sites.

Worked examples

Example 1, OpenAI, gpt-4o

  • Provider: OpenAI · Model: gpt-4o
  • User message: “Hello!” · no system prompt
  • Temperature: 0.7 · Max tokens: 256 · no stream
# OpenAI Chat Completions API, https://platform.openai.com/docs/api-reference/chat/create
curl https://api.openai.com/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "temperature": 0.7,
  "max_tokens": 256
}'

Bearer auth, a single user turn in the messages array, and both params in the top-level body, the plain OpenAI Chat Completions shape.

Example 2, Anthropic, claude-sonnet-5, streaming

  • Provider: Anthropic · Model: claude-sonnet-5
  • System: “You are terse.” · User: “Hi”
  • Temperature: 0.5 · Max tokens: 512 · stream on
# Anthropic Messages API, https://docs.anthropic.com/en/api/messages
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "claude-sonnet-5",
  "max_tokens": 512,
  "temperature": 0.5,
  "stream": true,
  "system": "You are terse.",
  "messages": [
    {
      "role": "user",
      "content": "Hi"
    }
  ]
}'

Note the x-api-key and anthropic-version headers, the top-level system string (not a message), required max_tokens, and stream: true.

Both blocks are produced by the same function the tool uses, and are checked byte-for-byte against hand-reconciled output in the module's verifyWorkedExamples() cross-check. Switch to the Python or Node.js tab in the tool above to see the equivalent SDK code for either example.

Frequently asked questions

Sources & references

Endpoint shapes, headers and body fields on this page were last cross-checked against the official references on 2026-07-09. Provider APIs are versioned; the page is reviewed when a referenced endpoint or required header changes.

Related tools

Comments & feedback

Spotted a bug or want an improvement? Tell us, our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, a stale endpoint, or want another provider added?

Email me at [email protected] , most fixes ship within 24 hours.