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

By SeedRouter · Published 2026-09-23 · Updated 2026-09-23

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](https://seedrouter.ai/apikeys) page, add credits on the [billing](https://seedrouter.ai/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](https://seedrouter.ai/apikeys) 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](https://seedrouter.ai/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:

```bash
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](https://seedrouter.ai/apikeys) 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:

```bash
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](https://seedrouter.ai/blog/gpt-image-2-api-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](https://seedrouter.ai/models/gpt-image-2#pricing).

## Which errors does a new API key usually hit?

| Error code | HTTP | What it means                                      | What to do                                          |
| ---------- | ---- | -------------------------------------------------- | --------------------------------------------------- |
| `10001`    | 401  | The key is missing, mistyped or revoked            | Send the full key in the `Authorization` header     |
| `20002`    | 400  | The `model` value is not a served ID               | Use `gpt-image-2` or `gpt-image-2-official` exactly |
| `20001`    | 400  | A field is wrong; the message names it when it can | Fix that field before retrying                      |
| `30001`    | 402  | The account has no credits left                    | [Add credits](https://seedrouter.ai/billing), 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](https://seedrouter.ai/usage). 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](https://seedrouter.ai/docs/gpt-image-2).
