API Request Builder
Fill in the fields of a chat request and get the JSON body and a curl command, plus the parameter combinations that will get it rejected.
Prompt plus max_tokens is about 544 of your 128,000-token window.
- Messages
- 2
- Request body, characters
- 334
- Problems found
- 0
The interesting output here is not the JSON — you could type that — it is the list under it. Most rejected requests are rejected for one of a small set of reasons, and all of them are visible in the body before you send it: a temperature outside the range this particular API accepts, five stop sequences where four are allowed, JSON mode switched on without the word JSON anywhere in the prompt, or a prompt and a max_tokens that cannot both fit in the window.
max_tokens is not the context window
They are two different limits and confusing them is the most common 400 in chat APIs. The window is everything — your prompt, the tool definitions, the whole conversation so far, and the reply. max_tokens caps only the reply, and it is reserved out of the window in advance, so asking for a 4,000-token answer inside a window with 3,000 tokens left fails before a single token is generated.
Then send it somewhere else
The curl output is a working command with your key read from $API_KEY, which is both safer to paste into a terminal and the exact input the curl converter in this family turns into Python, JavaScript, Go, PHP or Ruby. Build the request here, check it, and take the command to whichever language you are actually writing in.