OpenAI Compat API
The OpenAI Compat API is a drop-in replacement for OpenAI’s official Images API. Fully compatible with the officialopenai SDK (Python & Node.js) and the raw OpenAI REST interface — just change the base_url.
Why Use Compat API?
Official SDK Support
Works with OpenAI’s official
openai Python and Node.js SDKsSame API Shape
Same request/response format as
https://api.openai.com/v1/images/*Synchronous
Returns the generated image directly — no polling needed
Unified Billing
Single API key, unified usage tracking through Mountsea
Configuration
Base URL
Authentication
Use your Mountsea API key:- HTTP header:
Authorization: Bearer your-api-key - Or set via the SDK’s
api_key/apiKeyparameter
Supported Endpoints
| Endpoint | Method | Description |
|---|---|---|
/openai/v1/images/generations | POST | Text-to-image (JSON) — identical to OpenAI |
/openai/v1/images/edits | POST | Image editing (multipart/form-data) — identical to OpenAI |
Supported Model
| Model | Description |
|---|---|
gpt-image-2 | Latest OpenAI image model (default) |
Using the Official openai SDK
Installation
Python
Node.js / TypeScript
Using the REST API Directly
If you don’t want to use the SDK, you can call the endpoints directly.Text-to-Image (JSON)
Image Edit (multipart/form-data)
Inpainting (multipart/form-data)
Request Parameters
images/generations (JSON)
| Field | Type | Description |
|---|---|---|
prompt | string (required) | Prompt for image generation |
model | string | Defaults to gpt-image-2 |
size | enum | auto, 1024x1024, 1024x1536, 1536x1024 |
n | number | Currently only 1 |
quality | enum | auto, low, medium, high, standard |
background | enum | transparent, opaque, auto |
output_format | enum | png, jpeg, webp |
output_compression | number | 0-100 for JPEG/WebP |
moderation | enum | auto, low |
response_format | enum | url or b64_json (gpt-image-2 always returns b64_json) |
user | string | End-user identifier for abuse monitoring |
images/edits (multipart/form-data)
All fields above plus:
| Field | Type | Description |
|---|---|---|
image | file (required) | Source image |
mask | file | Optional mask; transparent areas will be repainted |
input_fidelity | high / low | How closely the output follows the input image |
Response Format
Identical to OpenAI’s official response:gpt-image-2 always returns the image as b64_json. The url response format is only kept for DALL·E compatibility and will be ignored for gpt-image models.Notes & Limitations
- All standard OpenAI parameters are supported; unknown parameters are ignored gracefully.
response_format=urlis accepted but gpt-image-2 will still returnb64_json.- Both
openaiSDK and raw REST calls work identically.
Explore the API Documentation
- images.generate (Compat) — OpenAI-compatible text-to-image endpoint
- images.edit (Compat) — OpenAI-compatible image editing endpoint