> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gptproto.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GPT-Image-2-Plus - Text To Image

> Classic text to image via gpt image 1. Reliable AI art generation for any prompt, from simple to complex.

## Authentication

1. Sign up for a GPTProto account at [https://gptproto.com](https://gptproto.com)
2. Navigate to the API Keys section in your dashboard
3. Generate a new API key (sk-xxxxx)
4. Copy and securely store your API key
   For authentication details, please refer to the [Authentication](https://docs.gptproto.com/authentication.md) section.

## Initiate Request

```bash cURL theme={null}
curl --location 'https://gptproto.com/v1/images/generations' \
--header 'Authorization: GPTPROTO_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
  "model": "gpt-image-2-plus",
  "prompt": "a cat",
  "size": "1024x1024"
}'

```

```javascript JavaScript theme={null}
const axios = require('axios');
let data = JSON.stringify({
  "model": "gpt-image-2-plus",
  "prompt": "a cat",
  "size": "1024x1024"
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://gptproto.com/v1/images/generations',
  headers: { 
    'Authorization': 'GPTPROTO_API_KEY', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});


```

```python Python theme={null}
import requests
import json

url = "https://gptproto.com/v1/images/generations"

payload = json.dumps({
  "model": "gpt-image-2-plus",
  "prompt": "a cat",
  "size": "1024x1024"
})
headers = {
  'Authorization': 'GPTPROTO_API_KEY',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)


```

```go Go theme={null}
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://gptproto.com/v1/images/generations"
  method := "POST"

  payload := strings.NewReader(`{
  "model": "gpt-image-2-plus",
  "prompt": "a cat",
  "size": "1024x1024"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "GPTPROTO_API_KEY")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

```

> [accordion] Response Example
>
> ```json theme={null}
> {
>     "data": [
>         {
>             "b64_json": "data:image/png;base64,<BASE64_DATA>"}
>     ],
>     "created": 1776841668
> }
> ```

## Parameters

> [tab] Text to Image
>
> | Parameter | Type | Required | Default | Range | Description |
> | - | - | - | - | - | - |
> | `model` | string | ✅ Yes | - | `gpt-image-1.5-plus` `gpt-image-2-plus` | The model to use for image generation. |
> | `prompt` | string | ✅ Yes | - | - | A text description of the desired image(s). The maximum length is 32000 characters. |
> | `size` | string | ❌ No | `1254x1254` | `1254x1254` `1536x1024` `1024x1536` `1672x941` `941x1672` | The size of the generated images. |

> [tab] Image Edit
>
> | Parameter | Type | Required | Default | Range | Description |
> | - | - | - | - | - | - |
> | `model` | string | ✅ Yes | - | `gpt-image-1.5-plus` `gpt-image-2-plus` | The model to use for image editing. |
> | `prompt` | string | ✅ Yes | - | 1–32000 chars | A text description of the desired image edit. |
> | `images` | file | ✅ Yes | - | max 16 images \< 50MB each | The input image(s) to edit. Each image should be a png, webp, or jpg file. You can provide up to 16 images. |
> | `size` | string | ❌ No | `1254x1254` | `1254x1254` `1536x1024` `1024x1536` `1672x941` `941x1672` | The size of the generated images. |

## Error Codes

### Common Error Codes

| Error Code | Error Name | Description |
| - | - | - |
| 401 | Unauthorized | API key is missing or invalid |
| 403 | Forbidden | Your API key doesn't have permission to access this resource, or insufficient balance for the requested operation |
| 429 | Too Many Requests | You've exceeded your rate limit |
| 500 | Internal server error | An internal server error occurred |
| 503 | Content policy violation | Content blocked due to safety concerns (actual status code is 400) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.