Rawswitch
  • Routing
  • Docs
ENKOJAZH
ContactGet API key

Browse

  • All models
  • Image
  • Video

Routes

  • Direct supplier API
  • Partner gateway
  • Self-hosted NPU
Featured
Product attributes on our own NPU

Product

  • Routing API
  • Models
  • Playground
  • Beyond shared routes

Models

  • Image
  • Video
  • Nano Banana 2.1
  • GPT Image 2.6
  • Kling 4.0
  • Product Attributes
  • All models

Routes

  • Direct supplier API
  • Partner gateway
  • Self-hosted NPU
  • Bring your own key

Developers

  • API reference
  • Agent prompts
  • llms.txt
  • Webhooks

Resources

  • Docs
  • Request lifecycle
  • Files

Company

  • Contact
  • Get an API key
One keyEvery model
Queue firstNo dropped requests
Same-model failoverNo silent swaps
Visible routingserved_by + attempts
Signed webhooksStandard Webhooks
Cost per requestLogged
© 2026 Rawswitch
TermsPrivacy
Preview build

GPT Image 2.6

OpenAIText to ImageLive
SchemaAPI docs
openai/gpt-image-2.6
Text to imageImage editing
$31.50 / 1M tokens · ≈$0.045644 / image · 1024² medium
Commercial useSupplier terms
PlaygroundAPI

1. Calling the API

  • Get an API key
  • Submit a request

2. Authentication

  • API key

3. Queue

  • Request lifecycle
  • Fetch request status
  • Stream status
  • Get the result
  • Cancel a request

4. Files

  • Uploading files

5. Webhooks

  • Signed webhooks

6. Schema

  • Input
  • Output

7. Agents

  • Agent prompt

About

High-fidelity image generation with careful prompt adherence.

1. Calling the API

Get an API key#

Keys start with rsw_ and are shown once when created. Keep the key on your server and expose it to your code as RAWSWITCH_API_KEY.

export RAWSWITCH_API_KEY="rsw_live_…"

Submit a request#

Every model answers the same endpoint. The body is an envelope: model picks the model, input carries the model's own fields, and webhook, route and tags are optional.

curl -X POST https://rawswitch.ai/v1/requests \
  -H "Authorization: Bearer $RAWSWITCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-image-2.6",
    "input": {
      "prompt": "A flat-lay of a folded navy jacket on light grey paper, even light",
      "size": "1024x1024",
      "quality": "medium",
      "num_images": 1
    }
  }'

The request is accepted and queued. You get an id and the URLs to follow it.

{
  "id": "req_01JDF3K8Q2",
  "status": "queued",
  "urls": {
    "self": "https://rawswitch.ai/v1/requests/req_01JDF3K8Q2",
    "events": "https://rawswitch.ai/v1/requests/req_01JDF3K8Q2/events",
    "cancel": "https://rawswitch.ai/v1/requests/req_01JDF3K8Q2/cancel"
  }
}

2. Authentication

API key#

Send the key in the Authorization header as a bearer token. Calls without a valid key fail with error.type = "authentication_error".

Authorization: Bearer $RAWSWITCH_API_KEY
Never call the API from a browser with your key. Put a small server route in front of it.

3. Queue

Request lifecycle#

A request moves through queued → running → succeeded, failed or canceled. For short jobs you can ask the submit call to wait: it returns whatever state the request reached within the limit.

curl -X POST "https://rawswitch.ai/v1/requests?wait=60" \
  -H "Authorization: Bearer $RAWSWITCH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6b1f0c1e-2f0a-4c57-9a55-1d2f6f0b7c11" \
  -d @body.json
Send an Idempotency-Key with every submit and reuse it when you retry. Without it, a retry can run and bill twice.

Fetch request status#

One call returns the status and, once finished, the output.

curl https://rawswitch.ai/v1/requests/req_01JDF3K8Q2 \
  -H "Authorization: Bearer $RAWSWITCH_API_KEY"

Stream status#

Follow a request live over server-sent events instead of polling.

curl -N https://rawswitch.ai/v1/requests/req_01JDF3K8Q2/events \
  -H "Authorization: Bearer $RAWSWITCH_API_KEY"

event: status
data: {"status":"running"}

event: status
data: {"status":"succeeded"}

Get the result#

served_by names the path that produced the output and attempts lists everything that was tried. Nothing about routing is hidden.

{
  "id": "req_01JDF3K8Q2",
  "model": "openai/gpt-image-2.6",
  "status": "succeeded",
  "output": {
    "images": [
      {
        "url": "https://files.rawswitch.example/req_01JDF3/gpt-image-2.6-0.png",
        "width": 1024,
        "height": 1024,
        "content_type": "image/png"
      }
    ]
  },
  "served_by": "openai/direct",
  "attempts": [
    {
      "route": "openai/direct",
      "status": "succeeded"
    }
  ],
  "usage": {
    "unit": "image",
    "quantity": 1
  },
  "timings": {
    "queued_ms": 38,
    "running_ms": 4120
  }
}

Cancel a request#

curl -X POST https://rawswitch.ai/v1/requests/req_01JDF3K8Q2/cancel \
  -H "Authorization: Bearer $RAWSWITCH_API_KEY"

4. Files

Uploading files#

Inputs take URLs. Public URLs work as they are. For local files, ask for an upload URL, send the bytes there and pass the returned file_url.

# 1) ask for an upload URL
curl -X POST https://rawswitch.ai/v1/files \
  -H "Authorization: Bearer $RAWSWITCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"filename": "jacket-front.jpg", "content_type": "image/jpeg"}'

# 2) send the bytes to upload_url, then use file_url in your input
curl -X PUT "$UPLOAD_URL" -H "Content-Type: image/jpeg" --data-binary @jacket-front.jpg

5. Webhooks

Signed webhooks#

Add a webhook to the request and Rawswitch posts the finished request to your URL. Deliveries are signed with the Standard Webhooks scheme and retried when your endpoint fails.

{
  "model": "openai/gpt-image-2.6",
  "input": {},
  "webhook": {
    "url": "https://your-app.example/hooks/rawswitch"
  }
}

6. Schema

Input#

FieldTypeRequiredDescription
promptstringyesWhat to generate. Plain language works best.
sizeenum—Output size in pixels. One of 1024x1024, 1024x1536, 1536x1024. Default "1024x1024".
qualityenum—Higher quality takes longer and costs more. One of low, medium, high. Default "medium".
num_imagesinteger—How many images to return. Each image is billed separately. Default 1.
output_formatenum—File format of the returned images. One of png, jpeg, webp. Default "png".

Output#

Finished files are in output.images: one item per image with url, width, height and content_type.

FieldTypeDescription
imagesarrayGenerated files. Each item has url, width, height and content_type.
seedintegerSeed that was used, when the model reports one.
{
  "images": [
    {
      "url": "https://files.rawswitch.example/req_01JDF3/gpt-image-2.6-0.png",
      "width": 1024,
      "height": 1024,
      "content_type": "image/png"
    }
  ]
}

Paths behind this model:

  • openai/direct — Direct supplier API (Primary)

7. Agents

Agent prompt#

Paste this into a coding agent. It carries the endpoint, the schema and the rules for calling this model safely.

agent prompt · openai/gpt-image-2.6
You are adding the Rawswitch model `openai/gpt-image-2.6` (GPT Image 2.6 — text to image) to this codebase.

## What it does
High-fidelity image generation with careful prompt adherence.
Price: $31.50 per 1M tokens, about $0.045644 per image (1024² medium).

## API
- Base URL: https://rawswitch.ai
- Auth: header `Authorization: Bearer <key>`. Read the key from the `RAWSWITCH_API_KEY` environment variable. Never hard-code it and never send it to the browser.
- Submit: `POST /v1/requests` with JSON `{ model, input, webhook?, route?, tags? }`. The response is `{ id, status: "queued", urls }`.
- Result: `GET /v1/requests/{id}` until `status` is `succeeded`, `failed` or `canceled`. One call returns status and output together.
- Short jobs: `POST /v1/requests?wait=60` waits up to 60 seconds and returns whatever state the request reached.
- Live status: `GET /v1/requests/{id}/events` is a server-sent event stream.
- Cancel: `POST /v1/requests/{id}/cancel`.
- Files: `POST /v1/files` returns `{ upload_url, file_url }`. PUT the bytes to `upload_url`, then pass `file_url` in the input.

## Request
```json
{
  "model": "openai/gpt-image-2.6",
  "input": {
    "prompt": "A flat-lay of a folded navy jacket on light grey paper, even light",
    "size": "1024x1024",
    "quality": "medium",
    "num_images": 1
  }
}
```

## Input fields
- `prompt` (string, required): What to generate. Plain language works best.
- `size` (string, one of "1024x1024", "1024x1536", "1536x1024", default "1024x1024"): Output size in pixels.
- `quality` (string, one of "low", "medium", "high", default "medium"): Higher quality takes longer and costs more.
- `num_images` (integer, range 1–4, default 1): How many images to return. Each image is billed separately.
- `output_format` (string, one of "png", "jpeg", "webp", default "png"): File format of the returned images.

## Output
- `images` (array): Generated files. Each item has url, width, height and content_type.
- `seed` (integer): Seed that was used, when the model reports one.
```json
{
  "images": [
    {
      "url": "https://files.rawswitch.example/req_01JDF3/gpt-image-2.6-0.png",
      "width": 1024,
      "height": 1024,
      "content_type": "image/png"
    }
  ]
}
```

## Rules to follow
- Send an `Idempotency-Key` header (a UUID per logical job) on every submit, and reuse the same key when you retry. A retry without it can run and bill twice.
- Do not poll faster than once per second. Prefer `?wait=`, the event stream or a webhook over tight polling.
- On `failed`, branch on `error.type`; show `error.message` to the user. Do not switch to another model yourself: Rawswitch already retries the same model on another path, and a different model is a product decision.
- Log `id`, `served_by` and `attempts` with your own request log. They say which path served the call.
- Output file URLs are for download. Copy the files into your own storage if you need to keep them.
- If you receive webhooks, verify the Standard Webhooks signature before trusting the body.

## Paths behind this model
- `openai/direct` — Direct supplier API (primary)

Write a small typed function that submits a request, waits for the result and returns the output. Add one test that mocks the HTTP calls.

Base URL in these examples is https://rawswitch.ai, a placeholder until the domain is decided.