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.
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.
- Endpoint and method. OpenAI and OpenAI-compatible providers use
POST {base_url}/chat/completions. Anthropic usesPOST /v1/messages. Gemini puts the model in the path —/v1beta/models/{model}:generateContent, swapping to:streamGenerateContentwhen streaming is on. - Authentication. OpenAI sends
Authorization: Bearer. Anthropic usesx-api-keyplus a requiredanthropic-version: 2023-06-01header. Gemini usesx-goog-api-key. The key itself is always an environment-variable placeholder, never a literal. - Message shaping. OpenAI keeps the system and user turns inside one
messagesarray. Anthropic pulls the system prompt out to a top-levelsystemstring (it is not a message role) and requiresmax_tokens. Gemini nests text undercontents[].parts[].textand a separatesystem_instruction. - Parameters.Temperature and token limits map to each API's field name —
max_tokensfor OpenAI and Anthropic,maxOutputTokensundergenerationConfigfor Gemini. JSON mode becomesresponse_format(OpenAI) orresponse_mime_type(Gemini), and is omitted for Anthropic, which has no such flag. - 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
- OpenAI — Chat Completions API reference
- Anthropic — Messages API reference
- Google — Gemini generateContent API reference
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.