Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use OpenAI’s vision-capable APIs when you want a model to understand a screenshot and return text; use the Images API when the main result should be a generated or edited image. For new image work, OpenAI’s current prompting guide documents GPT Image 2. This guide shows how to choose the right route, make requests from Python or JavaScript, save the returned image, and check the result.

Choose the API for the job

“Screenshot API” can mean two different things: capturing a website as an image, or sending an existing screenshot to a model for analysis. OpenAI’s image and vision APIs handle the latter and can also generate or edit images; they do not, by themselves, navigate to a website and capture its page. For a website capture, see the separate ScreenshotNeo website screenshot API section below.

What you need Use Typical result
Describe or inspect a screenshot Responses API with image input, or Chat Completions for an image-analysis request whose output should be text Text, such as a visual summary, extracted details, or answers to questions about the image
Generate an image from a prompt Images API, such as client.images.generate Image data to decode and save
Edit an existing image Images API, such as client.images.edit, or the image-generation tool through Responses A new image based on instructions and an input image
Capture a live webpage A website screenshot service or browser-based capture workflow A screenshot of the rendered page, not an AI-generated illustration

For the image-generation tool, Responses can combine image creation with a larger model interaction; the Images API is a direct choice when image output is the primary result. For analysis, choose an API surface that returns the text answer your application needs. OpenAI’s image-generation guide and images and vision guide describe these paths.

Prepare an API key and SDK

Create an OpenAI API key, keep it on a trusted server or local development environment, and expose it to the official SDK as OPENAI_API_KEY. Do not put a secret key in browser JavaScript, a public repository, or a mobile app bundle. A client-side application should call your server, which can authenticate with OpenAI without revealing the key.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Python

  1. Install the official package: pip install openai.
  2. Set the key in your shell before running the script: export OPENAI_API_KEY="your-api-key" on macOS or Linux. In PowerShell, use $env:OPENAI_API_KEY="your-api-key" for the current session.
  3. Run the Python examples below in that environment. The SDK reads the environment variable automatically.

JavaScript

  1. Install the official package: npm install openai.
  2. Set OPENAI_API_KEY in the process environment before starting the program. On macOS or Linux, use export OPENAI_API_KEY="your-api-key"; in PowerShell, use $env:OPENAI_API_KEY="your-api-key".
  3. Run the examples from a server-side Node.js process, not a public webpage.

The official Developer quickstart covers initial SDK setup and a first request.

Generate an image with GPT Image 2

Start with a specific prompt: state the subject, composition, visual style, and constraints. The example below asks the Images API for a WebP image and writes the returned base64 data to disk. Change the prompt and output filename to suit your application.

Python: generate and save a WebP

import base64
from openai import OpenAI

client = OpenAI()

result = client.images.generate(
    model="gpt-image-2",
    prompt=(
        "A clean editorial illustration of a small greenhouse on a city rooftop, "
        "early morning light, wide composition, no text or logos."
    ),
    size="1536x1024",
    quality="high",
    output_format="webp",
)

image_bytes = base64.b64decode(result.data[0].b64_json)
with open("greenhouse.webp", "wb") as image_file:
    image_file.write(image_bytes)

JavaScript: generate and save a WebP

import OpenAI from "openai";
import { writeFile } from "node:fs/promises";

const client = new OpenAI();

const result = await client.images.generate({
  model: "gpt-image-2",
  prompt:
    "A clean editorial illustration of a small greenhouse on a city rooftop, " +
    "early morning light, wide composition, no text or logos.",
  size: "1536x1024",
  quality: "high",
  output_format: "webp",
});

const imageBytes = Buffer.from(result.data[0].b64_json, "base64");
await writeFile("greenhouse.webp", imageBytes);

These examples use SDK methods and parameters documented in OpenAI’s image prompting reference. GPT Image 2 supports flexible sizes, quality, output format, and background options. Confirm the permitted values in the current reference when adapting the request; do not assume a value accepted by an older model will remain valid for another model.

Edit an existing image

For an edit, give the model both the source image and precise instructions. Say what should change and what must stay the same—for example, “replace the sky with an overcast sky; preserve the building, perspective, and crop.” The Python pattern below reads a local image and writes the returned image bytes. Keep source files in a trusted location and use a supported image format.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
import base64
from openai import OpenAI

client = OpenAI()

with open("source.png", "rb") as image_file:
    result = client.images.edit(
        model="gpt-image-2",
        image=image_file,
        prompt=(
            "Replace only the sky with a soft overcast sky. "
            "Keep the building, perspective, colors, and crop unchanged."
        ),
        size="1536x1024",
        quality="high",
        output_format="png",
    )

image_bytes = base64.b64decode(result.data[0].b64_json)
with open("edited.png", "wb") as output_file:
    output_file.write(image_bytes)

OpenAI documents image input for generation and editing as file IDs or base64 image data in the image-generation tool; the Images API also provides an edit operation. The exact input mechanism depends on the API surface and SDK method you choose. The example uses a file object with the SDK edit method. For other accepted input forms and current options, follow the image-generation guide.

Analyze a screenshot and get a text answer

Use a vision request when the output you want is an explanation rather than a new image. A screenshot can be provided as image input, including as a data URL with base64-encoded image bytes. The following Python example reads a local screenshot and asks for a concise description. It uses the Responses API; adapt the prompt to a focused task such as identifying a visible error message or summarizing page sections.

import base64
from openai import OpenAI

client = OpenAI()

with open("page.png", "rb") as image_file:
    encoded = base64.b64encode(image_file.read()).decode("utf-8")

data_url = f"data:image/png;base64,{encoded}"

response = client.responses.create(
    model="gpt-4.1",
    input=[{
        "role": "user",
        "content": [
            {"type": "input_text", "text": "Describe the visible layout and any error message."},
            {"type": "input_image", "image_url": data_url},
        ],
    }],
)

print(response.output_text)

This is an analysis example, not an image-generation request: it sends the screenshot and asks for text. The model shown is an example of a vision-capable model; check the current images and vision documentation for supported models, image-input limits, and format details before choosing one for a production workflow. If your application already uses Chat Completions and only needs a text response from image input, that API is another documented route.

Choose output format, quality, size, and transparency

These options affect how the output fits your application. Choose them deliberately rather than requesting the largest or highest-quality output by default.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
  • Size: GPT Image 2 accepts flexible image sizes. Choose dimensions that suit the destination and verify the current accepted sizing rules in the prompting guide.
  • Quality: Select a supported quality setting based on the detail needed and your latency or cost constraints. OpenAI’s current documentation does not establish a universal best setting or a performance benchmark.
  • Output format: Choose PNG, WebP, or another format supported by the selected model and endpoint. WebP can be useful when your downstream system accepts it; PNG is a practical choice for transparency.
  • Compression: Where supported, configure compression with the output format rather than assuming every format uses the same setting.
  • Transparent background: Request background: "transparent" and use PNG or WebP. JPEG does not support transparent backgrounds.
  • Action: In the image-generation tool, action can be auto, generate, or edit. With auto, the model chooses whether the request is generation or editing.

GPT Image 2 processes image inputs at high fidelity. Do not send an input_fidelity parameter for GPT Image 2; the current prompting reference says to omit it. For transparent output, verify the saved file has a real alpha channel rather than judging transparency from a checkerboard-looking preview alone.

Save base64 output safely

Image responses contain encoded data that must be decoded before the result is a usable image file. In the SDK examples, the base64 string is in result.data[0].b64_json; Python’s base64.b64decode and Node’s Buffer.from(value, "base64") convert it to bytes. Write those bytes in binary mode. Do not save the base64 text itself with a .png or .webp extension: the resulting file will not be a valid image.

For an API response that you handle outside the SDK, first inspect the response structure and confirm the image field actually contains base64 data. Decode only that field, and use a filename extension that matches the requested output format. If you return images to a browser, prefer serving the binary file from your server or an appropriately protected URL rather than embedding secret API credentials in frontend code.

Use the CLI when a shell workflow is enough

The OpenAI CLI guide currently says image commands do not yet have native --output support. In a CLI workflow, extract the image’s data.0.b64_json value from the JSON response and pipe or pass that value through a base64 decoder to write the image file. The decoder command differs across operating systems, so check whether your shell’s decoder expects standard input or a file argument. Do not try to use --output as if it were a supported image-save option.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

For the available CLI commands and current behavior, consult the official OpenAI CLI guide. If you need repeatable file handling, validation, or application logic, an SDK script is usually easier to control than manual JSON extraction.

Or skip the browser setup

If your input is a live webpage rather than an image you already have, ScreenshotNeo captures the URL directly; it is a website screenshot service, not an OpenAI image-generation endpoint. A single GET request saves a screenshot file:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. It accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents using Claude, Cursor, or another MCP client. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to capture up to 1,000 screenshots a month without a card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the result before relying on it

Generated and edited images can miss details in a prompt. OpenAI recommends reviewing results rather than assuming every constraint was followed. Build checks around the use case, especially when an image will be published or used in a workflow that depends on exact visual details.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
  • Check that any requested text is accurate and legible.
  • Confirm that identities, labels, and other details that needed to remain unchanged are intact.
  • For an edit, verify that only the requested area changed.
  • For a supposedly transparent asset, inspect whether the saved PNG or WebP contains a real alpha channel.
  • For screenshot analysis, verify important text or conclusions against the original screenshot; a model-generated description is not a substitute for checking critical data.

Common problems and fixes

Symptom Likely cause What to do
Authentication fails The key is missing from the environment, misspelled, unavailable to the process, or invalid. Set OPENAI_API_KEY in the same shell or process that runs the script. Restart the process after changing the environment, and never paste the key into client-side code.
The saved file cannot be opened The base64 string was saved as text, decoded from the wrong response field, or given an extension that does not match the output format. Decode b64_json to binary bytes, check the response contains image data, and align the filename extension with output_format.
Transparent background appears solid The output was requested as JPEG, the background option was omitted, or the viewer does not display alpha clearly. Request a transparent background with PNG or WebP and inspect the file’s alpha channel.
A text label or small detail is wrong The generated result did not preserve that requested detail. Inspect the image, sharpen the prompt with exact wording and placement constraints, then regenerate or edit and verify again. OpenAI specifically recommends checking text legibility and preserved labels.
CLI output does not create a file The image CLI command does not yet have native --output support. Handle the returned JSON, extract data.0.b64_json, and decode it using the method for your shell.
Model or parameter is rejected A parameter or model name may not be supported by the selected endpoint or current model. Compare the request with the current guide for that specific API surface. In particular, omit input_fidelity when using GPT Image 2.
The edit changes more than expected The prompt did not define the intended change and preservation constraints clearly enough, or the output did not follow them exactly. State both the target modification and the details that must stay fixed, then inspect the result before using it.

Plan for model changes and data handling

OpenAI’s current image prompting reference marks GPT Image 1.5 as deprecated with a scheduled shutdown on December 1, 2026, and GPT Image 1 as deprecated with a scheduled shutdown on October 23, 2026. For integrations on those models, evaluate GPT Image 2 and validate output differences before migrating; do not assume an older model’s behavior, accepted parameters, or results will be identical.

OpenAI states, “By default, we never train on customer API data.” The announcement also says image inputs and outputs remain subject to API usage policies. Read the announcement and applicable policy information when deciding what data your application may submit.

Manage latency, reliability, and cost

The official guidance cited here does not supply a single authoritative latency, performance, or price figure for this workflow. Image generation, image editing, and analysis are different jobs, so measure the behavior of your actual prompt, model, input size, output format, and application path before setting service expectations. For production use, handle request failures, set suitable client timeouts, and retain enough context to diagnose which request and output format failed without logging API secrets.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep outputs at the dimensions and quality your use case requires; larger or more detailed requests may have different operational costs, but the cited documentation does not establish a universal cost comparison. If output volume or latency matters, run representative requests in your own environment and consult the current API pricing and model documentation before committing to a budget. No performance benchmark is asserted here.

Frequently Asked Questions

Can the OpenAI image API take a URL and screenshot the live page?

The examples here analyze an image you provide or generate an image; they do not open a webpage URL and capture its rendered state. Use a website screenshot capture service for that separate task.

Can I use GPT Image 2 to edit an image without changing its format?

You can request an output format in the image operation, but verify the saved output and the format required by your application rather than assuming the input format is retained.

Does GPT Image 2 require the input_fidelity option?

No. OpenAI’s current prompting reference says GPT Image 2 always processes image inputs at high fidelity and instructs developers to omit that parameter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.