Create an API account
Sign up at platform.openai.com — this is separate from your ChatGPT subscription and billed by usage. Add a payment method and set a low monthly limit while you experiment.
This demo calls a model from our server so you never expose a key. In your own app, the call looks exactly like the code below.
An API account is separate from a ChatGPT Plus subscription. Sign up (or sign in) at the OpenAI platform, then add a payment method — API access is pay-as-you-go and a test prompt costs a fraction of a cent.
Open platform.openai.comYour key is sent to our server for this one request, forwarded straight to OpenAI, and never stored or logged. Token counts and cost above come back from OpenAI itself.
Sign up at platform.openai.com — this is separate from your ChatGPT subscription and billed by usage. Add a payment method and set a low monthly limit while you experiment.
In API keys, create a new secret key and copy it once — it is never shown again. Treat it like a password: one key per project, and revoke it the moment it leaks.
Never put a key in front-end code or a mobile app; anyone can read it. Store it as an environment variable and call the API from your backend, which then talks to your app.
One HTTP POST is all it takes. The messages array carries a system message (who the assistant is) and your user message (the prompt itself).
model picks capability versus cost, temperature controls how adventurous the wording is (0.2 factual, 0.8 creative), and max_tokens caps the reply length and your bill.
Expect 429 rate limits and 5xx blips: retry with a short backoff, cap the attempts, and show the real error in your UI instead of a silent empty answer.
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-4o-mini",
"temperature": 0.4,
"messages": [
{ "role": "system", "content": "You are a concise editor." },
{ "role": "user", "content": "Rewrite this in two lines: ..." }
]
}'Model
Typical call size
Per prompt
$0.00054
a page of context
Per 1,000 prompts
$0.5400
same size
Prompts for $20
37,037
in a month
That is roughly
1,234/day
every day
Tokens are chunks of text — about 4 characters, so 750 words ≈ 1,000 tokens. You pay for what goes in and what comes out, and output usually costs 4× more than input. Prices shown are OpenAI list prices for planning only; check their pricing page before you commit.
ChatGPT basics, every common error decoded (401, 429, context length) and a step-by-step rate-limit playbook.
Pick a model, a role and a prompt template, run a live example, and copy the finished server-side code.
ChatGPT's per-token cost side by side with Gemini, Claude and hosted Llama, using the same calculator numbers.