Claude Opus 5.5 is live on SeedRouter

GPT Image 2 API key: how to get access and make a first request

Get a GPT Image 2 API key, store it safely, add credits, and make a first request with curl, Python or JavaScript, plus the errors a new key most often hits.

Read as Markdown

Yes, GPT Image 2 has an API, and on SeedRouter one API key gives you access to it. Sign in, create a key on the API keys page, add credits on the billing page, and send the key in an Authorization: Bearer header to https://api.seedrouter.ai/v1/images/generations. The key is shown in full only once, when you create it, so copy it straight into your server's environment.

The steps below take you from no account to a finished image, and cover the four errors that stop most first requests.

How do you get a GPT Image 2 API key?

  1. Sign in to SeedRouter with your Google account.
  2. Open API keys and create a key. Give it a name that says where it will run, such as production-server.
  3. Copy the key immediately. After this screen you only see a masked version, and a lost key cannot be recovered. Revoke it and create a new one instead.
  4. Add credits on the billing page. A key works as soon as it exists, but a request needs credits to run.

One key reaches every model on SeedRouter, so you do not need a separate key for GPT Image 2 and GPT Image 2.5. Create separate keys per environment instead. Revoking the staging key then cannot break production.

Where should the API key live?

On your server, in an environment variable, and nowhere else:

export SEEDROUTER_API_KEY="your-key"

Never put the key in browser JavaScript, a mobile app bundle, or a public repository. Anyone who reads it can spend your credits. If your product has a front end, have it call your own back end, and let the back end call the API with the key.

If a key does leak, revoke it on the API keys page right away. A revoked key stops working, and requests that use it are rejected.

How do you make a first request with the key?

Send the key as a bearer token. The response is a task reference, not the image:

curl https://api.seedrouter.ai/v1/images/generations \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "An amber glass bottle on a cream background, studio lighting",
    "size": "1024x1024",
    "quality": "low"
  }'

Save the id from the response and poll GET https://api.seedrouter.ai/v1/tasks/{id} with the same header until status is completed. The finished task lists the image URLs. For a complete loop in code, see the GPT Image 2 API in Python.

Two model IDs serve GPT Image 2 with the same fields: gpt-image-2 charges one flat price per delivered image, and gpt-image-2-official bills the tokens each render reports. The key works with both. Current prices are on the model page.

Which errors does a new API key usually hit?

Error codeHTTPWhat it meansWhat to do
10001401The key is missing, mistyped or revokedSend the full key in the Authorization header
20002400The model value is not a served IDUse gpt-image-2 or gpt-image-2-official exactly
20001400A field is wrong; the message names it when it canFix that field before retrying
30001402The account has no credits leftAdd credits, then resend

Two slips cause most first-request failures. One is a key pasted with a missing character or a stray space, which returns 10001. The other is copying the model name from a headline, such as gpt-image-2.0 or GPT Image 2, instead of the model ID, which returns 20002. Both are rejected before any work starts, so nothing is charged.

Is there a free GPT Image 2 API key?

No. A key is free to create, but requests are paid from prepaid credits. What you do not pay for is failure: a task that ends failed, or returns no image, costs nothing. Credits are bought as one-time top-ups, never expire, and carry no subscription, so a small first top-up is enough to test an integration properly.

Can one key be used from Python and JavaScript?

Yes. The key is a string in an HTTP header, so any language that can send an HTTP request can use it. Read it from the environment in each runtime: os.environ["SEEDROUTER_API_KEY"] in Python and process.env.SEEDROUTER_API_KEY in Node.js. Keep the JavaScript on the server side; the same key in browser code is exposed to every visitor.

Frequently asked questions

Do I need an OpenAI API key to use GPT Image 2 here?

No. Your SeedRouter key is the only credential you send. You do not create or manage a separate account elsewhere to call GPT Image 2 through this API.

How many API keys can I create?

Enough for one per server or service; the per-account limit sits far above what an integration needs. Each key can be revoked on its own.

Where do I see what a key has spent?

In usage history. Each request lists its model and charge, which makes it easy to check a new integration against your estimate.

Keep the key on the server and ship

Create a key per environment, store it in an environment variable, and send it as a bearer token from your back end only. When the first request returns a task id, the access part is done; everything after that is the GPT Image 2 API reference.

Related guides