近年の言語モデルは、入力された画像を処理して内容を分析できます。この機能を画像認識 と呼びます。GPT Image モデルは、テキストや画像を入力として、新しい画像を作成したり、既存の画像を編集したりできます。
画像を分析するか生成するかに応じて、エンドポイントを選んでください。
各モデルが対応する入出力の種類については、モデル一覧 をご覧ください。
Images API でテキストから画像を生成したり、既存の画像を編集したりするには、gpt-image-2.5-sunburst を選びます。Responses API では、画像生成ツールに対応する主系列のモデルを選びます。使用する GPT Image モデルはツールが選択します。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import OpenAI from "openai";
const openai = new OpenAI();
const response = await openai.responses.create({
model: "gpt-6-astra",
input:
"Generate an image of gray tabby cat hugging an otter with an orange scarf",
tools: [{ type: "image_generation" }],
});
// Save the image to a file
const imageData = response.output
.filter((output) => output.type === "image_generation_call")
.map((output) => output.result);
if (imageData.length > 0) {
const imageBase64 = imageData[0];
const fs = await import("fs");
fs.writeFileSync("cat_and_otter.png", Buffer.from(imageBase64, "base64"));
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 from openai import OpenAI
import base64
client = OpenAI()
response = client.responses.create(
model = "gpt-6-astra" ,
input = "Generate an image of gray tabby cat hugging an otter with an orange scarf" ,
tools = [{ "type" : "image_generation" }],
)
# Save the image to a file
image_data = [
output.result
for output in response.output
if output.type == "image_generation_call"
]
if image_data:
image_base64 = image_data[ 0 ]
with open ( "cat_and_otter.png" , "wb" ) as f:
f.write(base64.b64decode(image_base64)) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 package main
import (
"context"
"encoding/base64"
"os"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-6-astra",
Input: responses.ResponseNewParamsInputUnion{
OfString: openai.String("Generate an image of a gray tabby cat hugging an otter with an orange scarf."),
},
Tools: []responses.ToolUnionParam{{
OfImageGeneration: &responses.ToolImageGenerationParam{},
}},
})
if err != nil {
panic(err)
}
for _, output := range response.Output {
if output.Type != "image_generation_call" {
continue
}
image, err := base64.StdEncoding.DecodeString(output.AsImageGenerationCall().Result)
if err != nil {
panic(err)
}
if err := os.WriteFile("cat_and_otter.png", image, 0o600); err != nil {
panic(err)
}
return
}
panic("response did not include an image generation call")
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.Tool;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-6-astra")
.input("Generate an image of a gray tabby cat hugging an otter with an orange scarf.")
.addTool(Tool.ImageGeneration.builder().build())
.build();
String imageResult =
client.responses().create(params).output().stream()
.flatMap(item -> item.imageGenerationCall().stream())
.flatMap(call -> call.result().stream())
.findFirst()
.orElseThrow(() -> new IllegalStateException("No generated image returned"));
Files.write(Path.of("cat_and_otter.png"), Base64.getDecoder().decode(imageResult)); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
CreateResponseOptions options = new()
{
Model = "gpt-6-astra",
};
options.InputItems.Add(
ResponseItem.CreateUserMessageItem(
"Generate an image of a gray tabby cat hugging an otter with an orange scarf."
)
);
options.Tools.Add(
ResponseTool.CreateImageGenerationTool(model: "gpt-image-2")
);
ResponseResult response = await client.CreateResponseAsync(options);
ImageGenerationCallResponseItem image = response
.OutputItems.OfType<ImageGenerationCallResponseItem>()
.FirstOrDefault()
?? throw new InvalidOperationException("No generated image was returned.");
await File.WriteAllBytesAsync(
"cat_and_otter.png",
image.ImageResultBytes.ToArray()
); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 require "base64"
require "openai"
client = OpenAI::Client.new
response = client.responses.create(
model: "gpt-6-astra",
input: "Generate an image of a gray tabby cat hugging an otter with an orange scarf.",
tools: [{ type: :image_generation }]
)
image_call = response.output.find do |item|
item.is_a?(OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall)
end
unless image_call.is_a?(OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall)
raise "No image generation call returned"
end
File.binwrite(
"cat_and_otter.png",
Base64.strict_decode64(image_call.result)
) 1
2
3
4
5
6
7
8 openai responses create \
--model gpt-6-astra \
--raw-output \
--transform 'output.#(type=="image_generation_call").result' <<'YAML' | base64 --decode > cat_and_otter.png
tools:
- type: image_generation
input: Generate an image of a gray tabby cat hugging an otter with an orange scarf.
YAML
GPT Image モデルは、参照画像がなくても現実世界の知識を活用できます。たとえば、半貴石を並べた飾り棚をプロンプトで指定すると、アメジスト、ローズクォーツ、ヒスイなど、それぞれの石を見分けられる画像を生成できます。
画像認識に対応したモデルを使うと、画像の内容を説明したり、画像内の文字を読み取ったり、物体、形、色、質感についての質問に答えたりできます。回答を利用する際は、モデルの制約 を考慮してください。
分析する画像は、画像の完全修飾 URL または Base64 でエンコードしたデータ URL で指定します。
content 配列に複数の画像を含めると、1 回のリクエストで複数の画像を入力できます。画像はトークンとしてカウントされ 、その数に応じて課金されます。
Passing a URL Passing a Base64 encoded image URL を渡す
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import OpenAI from "openai";
const openai = new OpenAI();
const response = await openai.chat.completions.create({
model: "gpt-6-astra",
messages: [
{
role: "user",
content: [
{ type: "text", text: "What is in this image?" },
{
type: "image_url",
image_url: {
url: "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg",
},
},
],
},
],
});
console.log(response.choices[0].message.content); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model = "gpt-6-astra" ,
messages = [
{
"role" : "user" ,
"content" : [
{ "type" : "text" , "text" : "What's in this image?" },
{
"type" : "image_url" ,
"image_url" : {
"url" : "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg" ,
},
},
],
}
],
)
print (response.choices[ 0 ].message.content) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
)
func main() {
client := openai.NewClient()
completion, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
Model: "gpt-6-astra",
Messages: []openai.ChatCompletionMessageParamUnion{
openai.UserMessage([]openai.ChatCompletionContentPartUnionParam{
openai.TextContentPart("What's in this image?"),
openai.ImageContentPart(openai.ChatCompletionContentPartImageImageURLParam{
URL: "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg",
}),
}),
},
})
if err != nil {
panic(err)
}
fmt.Println(completion.Choices[0].Message.Content)
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.chat.completions.ChatCompletionContentPart;
import com.openai.models.chat.completions.ChatCompletionContentPartImage;
import com.openai.models.chat.completions.ChatCompletionContentPartText;
import com.openai.models.chat.completions.ChatCompletionCreateParams;
import com.openai.models.chat.completions.ChatCompletionUserMessageParam;
import java.util.List;
String imageUrl =
"https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg";
ChatCompletionContentPart text =
ChatCompletionContentPart.ofText(
ChatCompletionContentPartText.builder().text("What's in this image?").build());
ChatCompletionContentPart image =
ChatCompletionContentPart.ofImageUrl(
ChatCompletionContentPartImage.builder()
.imageUrl(ChatCompletionContentPartImage.ImageUrl.builder().url(imageUrl).build())
.build());
ChatCompletionCreateParams params =
ChatCompletionCreateParams.builder()
.model("gpt-6-astra")
.addMessage(
ChatCompletionUserMessageParam.builder()
.contentOfArrayOfContentParts(List.of(text, image))
.build())
.build();
client.chat().completions().create(params).choices().stream()
.flatMap(choice -> choice.message().content().stream())
.forEach(System.out::println); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 using OpenAI.Chat;
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
string model = "gpt-6-astra";
ChatClient client = new(model, key);
Uri imageUrl = new(
"https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg"
);
UserChatMessage message = new(
[
ChatMessageContentPart.CreateTextPart("What is in this image?"),
ChatMessageContentPart.CreateImagePart(imageUrl),
]
);
ChatCompletion completion = await client.CompleteChatAsync(message);
Console.WriteLine(completion.Content[0].Text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 require "openai"
client = OpenAI::Client.new
completion = client.chat.completions.create(
model: "gpt-6-astra",
messages: [
{
role: :user,
content: [
{
type: :text,
text: "What's in this image?"
},
{
type: :image_url,
image_url: {
url: "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg"
}
}
]
}
]
)
puts(completion.choices.fetch(0).message.content) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-6-astra",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg"
}
}
]
}
],
"max_completion_tokens": 300
}' Base64 でエンコードした画像を渡す
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 import fs from "fs";
import OpenAI from "openai";
const openai = new OpenAI();
const imagePath = "fixtures/example.jpg";
const base64Image = fs.readFileSync(imagePath, "base64");
const completion = await openai.chat.completions.create({
model: "gpt-6-astra",
messages: [
{
role: "user",
content: [
{ type: "text", text: "what's in this image?" },
{
type: "image_url",
image_url: {
url: `data:image/jpeg;base64,${base64Image}`,
},
},
],
},
],
});
console.log(completion.choices[0].message.content); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 import base64
from openai import OpenAI
client = OpenAI()
# Function to encode the image
def encode_image (image_path):
with open (image_path, "rb" ) as image_file:
return base64.b64encode(image_file.read()).decode( "utf-8" )
# Path to your image
image_path = "path_to_your_image.jpg"
# Getting the Base64 string
base64_image = encode_image(image_path)
completion = client.chat.completions.create(
model = "gpt-6-astra" ,
messages = [
{
"role" : "user" ,
"content" : [
{ "type" : "text" , "text" : "what's in this image?" },
{
"type" : "image_url" ,
"image_url" : {
"url" : f "data:image/jpeg;base64, { base64_image } " ,
},
},
],
}
],
)
print (completion.choices[ 0 ].message.content) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package main
import (
"context"
"encoding/base64"
"fmt"
"os"
"github.com/openai/openai-go/v3"
)
func main() {
client := openai.NewClient()
image, err := os.ReadFile("image.png")
if err != nil {
panic(err)
}
imageURL := "data:image/png;base64," + base64.StdEncoding.EncodeToString(image)
completion, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
Model: "gpt-6-astra",
Messages: []openai.ChatCompletionMessageParamUnion{
openai.UserMessage([]openai.ChatCompletionContentPartUnionParam{
openai.TextContentPart("What's in this image?"),
openai.ImageContentPart(openai.ChatCompletionContentPartImageImageURLParam{URL: imageURL}),
}),
},
})
if err != nil {
panic(err)
}
fmt.Println(completion.Choices[0].Message.Content)
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.chat.completions.ChatCompletionContentPart;
import com.openai.models.chat.completions.ChatCompletionContentPartImage;
import com.openai.models.chat.completions.ChatCompletionContentPartText;
import com.openai.models.chat.completions.ChatCompletionCreateParams;
import com.openai.models.chat.completions.ChatCompletionUserMessageParam;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
import java.util.List;
String imageUrl =
"data:image/jpeg;base64,"
+ Base64.getEncoder()
.encodeToString(
Files.readAllBytes(Path.of(System.getenv("OPENAI_EXAMPLE_IMAGE_PATH"))));
ChatCompletionContentPart text =
ChatCompletionContentPart.ofText(
ChatCompletionContentPartText.builder().text("What's in this image?").build());
ChatCompletionContentPart image =
ChatCompletionContentPart.ofImageUrl(
ChatCompletionContentPartImage.builder()
.imageUrl(ChatCompletionContentPartImage.ImageUrl.builder().url(imageUrl).build())
.build());
ChatCompletionCreateParams params =
ChatCompletionCreateParams.builder()
.model("gpt-6-astra")
.addMessage(
ChatCompletionUserMessageParam.builder()
.contentOfArrayOfContentParts(List.of(text, image))
.build())
.build();
client.chat().completions().create(params).choices().stream()
.flatMap(choice -> choice.message().content().stream())
.forEach(System.out::println); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 using OpenAI.Chat;
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
string model = "gpt-6-astra";
ChatClient client = new(model, key);
Uri imageUrl = new(
"https://openai-documentation.vercel.app/images/cat_and_otter.png"
);
using HttpClient http = new();
BinaryData image = BinaryData.FromBytes(
await http.GetByteArrayAsync(imageUrl)
);
UserChatMessage message = new(
[
ChatMessageContentPart.CreateTextPart("What's in this image?"),
ChatMessageContentPart.CreateImagePart(image, "image/png"),
]
);
ChatCompletion completion = await client.CompleteChatAsync(message);
Console.WriteLine(completion.Content[0].Text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 require "base64"
require "openai"
client = OpenAI::Client.new
image = Base64.strict_encode64(File.binread("image.png"))
completion = client.chat.completions.create(
model: "gpt-6-astra",
messages: [
{
role: :user,
content: [
{
type: :text,
text: "What's in this image?"
},
{
type: :image_url,
image_url: { url: "data:image/png;base64,#{image}" }
}
]
}
]
)
puts(completion.choices.fetch(0).message.content) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 BASE64_IMAGE=$(base64 < path_to_your_image.jpg) && curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" -d @- <<EOF
{
"model": "gpt-6-astra",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,$BASE64_IMAGE"
}
}
]
}
],
"max_completion_tokens": 300
}
EOF
分析する画像は、次のいずれかの方法で指定できます。
画像ファイルの完全修飾 URL を渡す
画像を Base64 でエンコードしたデータ URL として渡す
ファイル ID(Files API で作成)を渡す
content 配列に複数の画像を含めると、1 回のリクエストで複数の画像を入力できます。画像はトークンとしてカウントされ 、その数に応じて課金されます。
Passing a URL Passing a Base64 encoded image Passing a file ID URL を渡す
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import OpenAI from "openai";
const openai = new OpenAI();
const response = await openai.responses.create({
model: "gpt-6-astra",
input: [
{
role: "user",
content: [
{ type: "input_text", text: "what's in this image?" },
{
type: "input_image",
image_url:
"https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg",
detail: "auto",
},
],
},
],
});
console.log(response.output_text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model = "gpt-6-astra" ,
input = [
{
"role" : "user" ,
"content" : [
{ "type" : "input_text" , "text" : "what's in this image?" },
{
"type" : "input_image" ,
"image_url" : "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg" ,
},
],
}
],
)
print (response.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 package main
import (
"context"
"fmt"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-6-astra",
Input: responses.ResponseNewParamsInputUnion{
OfInputItemList: responses.ResponseInputParam{
responses.ResponseInputItemParamOfMessage(
responses.ResponseInputMessageContentListParam{
responses.ResponseInputContentParamOfInputText("What's in this image?"),
{OfInputImage: &responses.ResponseInputImageParam{
Detail: responses.ResponseInputImageDetailAuto,
ImageURL: openai.String("https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg"),
}},
},
responses.EasyInputMessageRoleUser,
),
},
},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.ResponseInputImage;
import com.openai.models.responses.ResponseInputItem;
import java.util.List;
ResponseInputItem imageInput =
ResponseInputItem.ofMessage(
ResponseInputItem.Message.builder()
.role(ResponseInputItem.Message.Role.USER)
.addInputTextContent("What's in this image?")
.addContent(
ResponseInputImage.builder()
.detail(ResponseInputImage.Detail.AUTO)
.imageUrl(
"https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg")
.build())
.build());
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-6-astra")
.inputOfResponse(List.of(imageInput))
.build();
client.responses().create(params).output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text())); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
Uri imageUrl = new(
"https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg"
);
ResponseResult response = await client.CreateResponseAsync(
"gpt-6-astra",
[
ResponseItem.CreateUserMessageItem(
[
ResponseContentPart.CreateInputTextPart("What is in this image?"),
ResponseContentPart.CreateInputImagePart(imageUrl),
]
),
]
);
Console.WriteLine(response.GetOutputText()); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 require "openai"
client = OpenAI::Client.new
response = client.responses.create(
model: "gpt-6-astra",
input: [
{
role: :user,
content: [
{
type: :input_text,
text: "What's in this image?"
},
{
type: :input_image,
detail: :auto,
image_url: "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg"
}
]
}
]
)
puts(response.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-6-astra",
"input": [
{
"role": "user",
"content": [
{"type": "input_text", "text": "what is in this image?"},
{
"type": "input_image",
"image_url": "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg"
}
]
}
]
}' 1
2
3
4
5
6
7
8
9
10
11
12 openai responses create \
--model gpt-6-astra \
--raw-output \
--transform 'output.#(type=="message").content.0.text' <<'YAML'
input:
- role: user
content:
- type: input_text
text: What is in this image?
- type: input_image
image_url: https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg
YAML Base64 でエンコードした画像を渡す
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 import fs from "fs";
import OpenAI from "openai";
const openai = new OpenAI();
const imagePath = "fixtures/example.jpg";
const base64Image = fs.readFileSync(imagePath, "base64");
const response = await openai.responses.create({
model: "gpt-6-astra",
input: [
{
role: "user",
content: [
{ type: "input_text", text: "what's in this image?" },
{
type: "input_image",
image_url: `data:image/jpeg;base64,${base64Image}`,
detail: "auto",
},
],
},
],
});
console.log(response.output_text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 import base64
from openai import OpenAI
client = OpenAI()
# Function to encode the image
def encode_image (image_path):
with open (image_path, "rb" ) as image_file:
return base64.b64encode(image_file.read()).decode( "utf-8" )
# Path to your image
image_path = "path_to_your_image.jpg"
# Getting the Base64 string
base64_image = encode_image(image_path)
response = client.responses.create(
model = "gpt-6-astra" ,
input = [
{
"role" : "user" ,
"content" : [
{ "type" : "input_text" , "text" : "what's in this image?" },
{
"type" : "input_image" ,
"image_url" : f "data:image/jpeg;base64, { base64_image } " ,
},
],
}
],
)
print (response.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 package main
import (
"context"
"encoding/base64"
"fmt"
"os"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
image, err := os.ReadFile("image.png")
if err != nil {
panic(err)
}
imageURL := "data:image/png;base64," + base64.StdEncoding.EncodeToString(image)
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-6-astra",
Input: responses.ResponseNewParamsInputUnion{
OfInputItemList: responses.ResponseInputParam{
responses.ResponseInputItemParamOfMessage(
responses.ResponseInputMessageContentListParam{
responses.ResponseInputContentParamOfInputText("What's in this image?"),
{OfInputImage: &responses.ResponseInputImageParam{
Detail: responses.ResponseInputImageDetailAuto,
ImageURL: openai.String(imageURL),
}},
},
responses.EasyInputMessageRoleUser,
),
},
},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.ResponseInputImage;
import com.openai.models.responses.ResponseInputItem;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
import java.util.List;
String imageBase64 =
Base64.getEncoder()
.encodeToString(
Files.readAllBytes(Path.of(System.getenv("OPENAI_EXAMPLE_IMAGE_PATH"))));
ResponseInputItem imageInput =
ResponseInputItem.ofMessage(
ResponseInputItem.Message.builder()
.role(ResponseInputItem.Message.Role.USER)
.addInputTextContent("What's in this image?")
.addContent(
ResponseInputImage.builder()
.detail(ResponseInputImage.Detail.AUTO)
.imageUrl("data:image/png;base64," + imageBase64)
.build())
.build());
ResponseCreateParams params =
ResponseCreateParams.builder()
.model("gpt-6-astra")
.inputOfResponse(List.of(imageInput))
.build();
client.responses().create(params).output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text())); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
Uri imageUrl = new(
"https://openai-documentation.vercel.app/images/cat_and_otter.png"
);
using HttpClient http = new();
// Download an image as a stream.
using Stream stream = await http.GetStreamAsync(imageUrl);
BinaryData imageData = BinaryData.FromStream(stream, "image/png");
ResponseResult response1 = await client.CreateResponseAsync(
"gpt-6-astra",
[
ResponseItem.CreateUserMessageItem(
[
ResponseContentPart.CreateInputTextPart("What is in this image?"),
ResponseContentPart.CreateInputImagePart(imageData),
]
),
]
);
Console.WriteLine($"From image stream: {response1.GetOutputText()}");
// Download an image as a byte array.
byte[] bytes = await http.GetByteArrayAsync(imageUrl);
imageData = BinaryData.FromBytes(bytes, "image/png");
ResponseResult response2 = await client.CreateResponseAsync(
"gpt-6-astra",
[
ResponseItem.CreateUserMessageItem(
[
ResponseContentPart.CreateInputTextPart("What is in this image?"),
ResponseContentPart.CreateInputImagePart(imageData),
]
),
]
);
Console.WriteLine($"From byte array: {response2.GetOutputText()}"); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 require "base64"
require "openai"
client = OpenAI::Client.new
image = Base64.strict_encode64(File.binread("image.png"))
response = client.responses.create(
model: "gpt-6-astra",
input: [
{
role: :user,
content: [
{
type: :input_text,
text: "What's in this image?"
},
{
type: :input_image,
detail: :auto,
image_url: "data:image/png;base64,#{image}"
}
]
}
]
)
puts(response.output_text) ファイル ID を渡す
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 import OpenAI from "openai";
import fs from "fs";
const openai = new OpenAI();
// Function to create a file with the Files API
async function createFile(filePath) {
const fileContent = fs.createReadStream(filePath);
const result = await openai.files.create({
file: fileContent,
purpose: "vision",
});
return result.id;
}
// Getting the file ID
const fileId = await createFile("fixtures/example.jpg");
const response = await openai.responses.create({
model: "gpt-6-astra",
input: [
{
role: "user",
content: [
{ type: "input_text", text: "what's in this image?" },
{
type: "input_image",
file_id: fileId,
detail: "auto",
},
],
},
],
});
console.log(response.output_text); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 from openai import OpenAI
client = OpenAI()
# Function to create a file with the Files API
def create_file (file_path):
with open (file_path, "rb" ) as file_content:
result = client.files.create(
file = file_content,
purpose = "vision" ,
)
return result.id
# Getting the file ID
file_id = create_file( "path_to_your_image.jpg" )
response = client.responses.create(
model = "gpt-6-astra" ,
input = [
{
"role" : "user" ,
"content" : [
{ "type" : "input_text" , "text" : "what's in this image?" },
{
"type" : "input_image" ,
"file_id" : file_id,
},
],
}
],
)
print (response.output_text) 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 package main
import (
"context"
"fmt"
"os"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient()
file, err := os.Open("image.png")
if err != nil {
panic(err)
}
defer file.Close()
uploaded, err := client.Files.New(context.Background(), openai.FileNewParams{
File: file,
Purpose: openai.FilePurposeVision,
})
if err != nil {
panic(err)
}
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "gpt-6-astra",
Input: responses.ResponseNewParamsInputUnion{
OfInputItemList: responses.ResponseInputParam{
responses.ResponseInputItemParamOfMessage(
responses.ResponseInputMessageContentListParam{
responses.ResponseInputContentParamOfInputText("What's in this image?"),
{OfInputImage: &responses.ResponseInputImageParam{
Detail: responses.ResponseInputImageDetailAuto,
FileID: openai.String(uploaded.ID),
}},
},
responses.EasyInputMessageRoleUser,
),
},
},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
} 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.files.FileCreateParams;
import com.openai.models.files.FilePurpose;
import com.openai.models.responses.ResponseCreateParams;
import com.openai.models.responses.ResponseInputImage;
import com.openai.models.responses.ResponseInputItem;
import java.nio.file.Path;
import java.util.List;
var file =
client
.files()
.create(
FileCreateParams.builder()
.file(Path.of(System.getenv("OPENAI_EXAMPLE_FILE_PATH")))
.purpose(FilePurpose.VISION)
.build());
var response =
client
.responses()
.create(
ResponseCreateParams.builder()
.model("gpt-6-astra")
.inputOfResponse(
List.of(
ResponseInputItem.ofMessage(
ResponseInputItem.Message.builder()
.role(ResponseInputItem.Message.Role.USER)
.addInputTextContent("What's in this image?")
.addContent(
ResponseInputImage.builder()
.detail(ResponseInputImage.Detail.AUTO)
.fileId(file.id())
.build())
.build())))
.build());
response.output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text())); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 using OpenAI.Files;
using OpenAI.Responses;
#pragma warning disable OPENAI001
string key = Environment.GetEnvironmentVariable("OPENAI_API_KEY")!;
ResponsesClient client = new(key);
string filename = "cat_and_otter.png";
Uri imageUrl = new(
$"https://openai-documentation.vercel.app/images/{filename}"
);
using HttpClient http = new();
// Download an image as a stream.
using Stream stream = await http.GetStreamAsync(imageUrl);
OpenAIFileClient files = new(key);
OpenAIFile file = await files.UploadFileAsync(
stream,
filename,
FileUploadPurpose.Vision
);
ResponseResult response = await client.CreateResponseAsync(
"gpt-6-astra",
[
ResponseItem.CreateUserMessageItem(
[
ResponseContentPart.CreateInputTextPart("what's in this image?"),
ResponseContentPart.CreateInputImagePart(file.Id),
]
),
]
);
Console.WriteLine(response.GetOutputText()); 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 require "openai"
require "pathname"
client = OpenAI::Client.new
uploaded = client.files.create(
file: Pathname("image.png"),
purpose: :vision
)
response = client.responses.create(
model: "gpt-6-astra",
input: [
{
role: :user,
content: [
{
type: :input_text,
text: "What's in this image?"
},
{
type: :input_image,
detail: :auto,
file_id: uploaded.id
}
]
}
]
)
puts(response.output_text)
モデルが分析できる鮮明な画像を、対応するファイル形式で用意してください。
要件
対応する入力
ファイル形式
PNG(.png)、JPEG(.jpeg または .jpg)、WEBP(.webp)、静止画の GIF(.gif)
リクエストサイズ
1 リクエストあたりのペイロードの合計は最大 512 MB
画像数
1 リクエストあたり最大 1,500 枚
パッチ単位で処理する入力画像 の場合、選択したモデルと detail の設定に応じたリサイズ規則を適用した後で、API が受け付けるのは画像 1 枚あたり最大 30,000 パッチです。この上限は、対応するすべての詳細度で画像ごとに適用されます。リクエスト内のパッチ数の合計に対する上限ではありません。
モデルや詳細度に応じて、リサイズ時のパッチ数にこれより低い上限がある場合は、その上限も適用されます。処理後に 30,000 パッチを超える画像は拒否されます。この上限に収まるように自動でリサイズされることはありません。画像の縦横のサイズを小さくして、もう一度お試しください。
画像トークンとプロンプトの残りの部分を合わせて、モデルの入力上限とコンテキスト上限に収める必要もあります。トークン数の見積もりだけでは、リクエストがすべての入力上限を満たすことは保証されません。画像を使用する際は、利用ポリシー を遵守してください。
detail パラメーターは画像の前処理を制御します。指定できる値はモデルによって異なり、low、high、original、auto があります。省略すると、Responses API と Chat Completions API のどちらでも auto が適用されます。各設定の動作は、モデル別の画像サイズ調整表 で確認できます。
1
2
3
4 "image_url": {
"url": "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg",
"detail": "original"
},
1
2
3
4
5 {
"type": "input_image",
"image_url": "https://api.nga.gov/iiif/a2e6da57-3cd1-4235-b20e-95dcaefed6c8/full/!800,800/0/default.jpg",
"detail": "original"
}
次の表を参考に詳細度を選んでください。
詳細度
適した用途
low
画像の概要を把握する場合。リサイズ方法とトークン使用量はモデルによって異なり、low のトークン数が常に high より少なくなるわけではありません。
high
元画像上の正確な座標は不要で、画像の細部まで読み取る一般的な用途
original
大きな画像、情報量の多い画像、位置関係が重要な画像、コンピューターの使用で扱う画像。モデルが対応している場合に選べます。
auto
モデル別の画像サイズ調整表に示す、モデルの既定の動作を使用する場合
光学文字認識(OCR)、小さな物体の検出、コンピューターの使用など、細部の識別や正確な座標が必要なタスクでは、モデルが対応していれば "detail": "original" を使用してください。この詳細度でも、モデルの各辺のピクセル数の上限やリサイズ時のパッチ数の上限に合わせて画像が縮小されることがあります。その処理後も 30,000 パッチを超える場合、API は画像をさらに縮小せず、リクエストを拒否します。座標の精度が重要なタスクでは、これらの上限に収まるように画像をリサイズしてから送信し、返された座標を元画像の座標に変換してください。座標の扱いについては、コンピューターの使用ガイド をご覧ください。
次の表は、汎用の画像認識モデルが画像サイズをどのように調整するかをまとめたものです。他のモデルや特定の用途に特化したモデルでは、上限が異なる場合があります。どのモデルでも、リサイズ時には縦横比を維持し、小さい画像は拡大しません。
モデルファミリー 対応する詳細度 パッチ数とリサイズ規則 gpt-6-astralow、high、original、
auto
low では 512 × 512 ピクセル以内に収めます。high では最大 2,500 パッチ、各辺は最大 65,535 ピクセルです。両方の上限が適用されます。
original では元のサイズを維持しますが、いずれかの辺が 65,535 ピクセルを超える場合は、この上限に収まるように縮小します。処理後の画像に必要なパッチ数が
30,000 パッチ を超えると、API はリクエストを拒否します。このパッチ数の上限に合わせて画像をリサイズすることはありません。
auto では original と同じ規則でサイズを調整します。
gpt-5.6-sol、gpt-5.6-terra、
gpt-5.6-luna
low、high、original、
auto
low では 512 × 512 ピクセル以内に収めます。high では 2048 × 2048 ピクセル以内かつ 2,500 パッチ以内に収めます。original
では元のサイズを維持しますが、いずれかの辺が 65,535 ピクセルを超える場合は、この上限に収まるように縮小します。処理後の画像に必要なパッチ数が
30,000 パッチ を超えると、API はリクエストを拒否します。このパッチ数の上限に合わせて画像をリサイズすることはありません。
auto では original と同じ規則でサイズを調整します。
gpt-5.5low、high、original、
auto
low では 512 × 512 ピクセル以内に収めます。high では最大 2,500 パッチ、各辺は最大 2048 ピクセルです。original
では最大 10,000 パッチ、各辺は最大 6000 ピクセルです。パッチ数と各辺の長さの両方に上限が適用されます。auto で適用される規則は
original と同じです。
gpt-5.4、gpt-5.4-mini、gpt-5.4-nano
low、high、original、
auto
low では各辺の上限が 2048 ピクセル、パッチ数の上限が 6,144 なので、high より多くのトークンを使用することがあります。
high では最大 2,500 パッチ、各辺は最大 2048 ピクセルです。original では最大 10,000 パッチ、各辺は最大 6000 ピクセルです。パッチ数と各辺の長さの両方に上限が適用されます。auto では high と同じ規則でサイズを調整します。
gpt-5.2、gpt-4.1-mini
low、high、auto
どの詳細度でも上限は同じで、各辺は最大 2048 ピクセル、パッチ数は最大 6,144 です。original には対応していません。
gpt-5.1、gpt-4.1、gpt-4o、
gpt-4o-mini
low、high、auto
low ではトークン数が固定されます。high と
auto では
タイル単位のサイズ調整規則 を使用します。
画像認識モデルは、入力画像を課金対象の入力トークンに変換します。画像入力の料金計算ツール と、このセクションで説明するパッチ単位およびタイル単位の計算規則は、画像認識モデルへの入力に適用されます。GPT Image による画像の生成や編集には別の料金体系が適用されます。詳しくは「GPT Image モデルへの入力 」をご覧ください。
画像トークンは、1 分あたりのトークン数(TPM)の上限 にも算入されます。計算ツールは画像 1 枚の料金を標準の入力単価で見積もります。プロンプトの残りの部分やモデルの出力は見積もりに含まれません。
画像入力の料金計算ツール では、モデル、画像サイズ、詳細度を指定して、画像 1 枚あたりの入力トークン数と料金を見積もれます。
一部のモデルは、画像を 32 × 32 ピクセルのパッチで覆い、トークン化します。モデルと詳細度の多くの組み合わせでは、リサイズ時のパッチ数に上限があります。まず API は、選択した詳細度のピクセル数の上限に各辺が収まるように画像サイズを調整します。縦横比を維持し、各辺のピクセル数を整数に丸めます。小さい画像は拡大しません。その後、次の手順でトークン数を計算します。
A. 各辺のピクセル数の上限を適用した後の画像を覆うのに必要な 32 × 32 ピクセルのパッチ数を計算します。パッチは画像の端からはみ出してもかまいません。
patch_count = ceil(width/32)×ceil(height/32)
B. 選択したモデルと詳細度にリサイズ時のパッチ数の上限があり、画像がその上限を超える場合は、縦横比を維持したまま縮小します。それ以外の場合は、この手順を省略します。各辺のピクセル数を整数に変換し、画像を覆うパッチ数を計算したときに上限に収まるよう、縮小率を調整します。最終的な縦横のサイズを計算するまでは、値を丸めずに精度を保ちます。
shrink_factor = sqrt((32^2 * patch_budget) / (width * height))
adjusted_shrink_factor = shrink_factor * min(
floor(width * shrink_factor / 32) / (width * shrink_factor / 32),
floor(height * shrink_factor / 32) / (height * shrink_factor / 32)
)
C. 手順 B で画像をリサイズした場合は、縮小後の幅と高さの小数部分を切り捨てて整数のピクセル数にします。得られた画像を覆うのに必要なパッチ数を計算します。これがモデルの倍率を適用する前の画像トークン数です。リサイズ時のパッチ数に上限がある場合、この数はその上限に収まります。
resized_patch_count = ceil(resized_width/32)×ceil(resized_height/32)
この数が 30,000 パッチを超えると、API はリクエストを拒否します。トークンの倍率を適用する前に、この上限を確認してください。
D. パッチ数にモデルの倍率を掛け、小数部分を切り上げると、課金対象の画像入力トークン数が得られます。この数にモデルの入力単価を 1 回だけ掛けます。プロンプト内の他のトークンに倍率を適用したり、料金に再度倍率を掛けたりすることはありません。
モデル
倍率
gpt-6-astra
1.2
gpt-5.6-sol
1.2
gpt-5.6-terra
1.2
gpt-5.6-luna
1.2
gpt-5.5
1.2
gpt-5.4
1.2
gpt-5.4-mini
1.2
gpt-5.4-nano
1.2
gpt-5.2
1.2
gpt-5-mini*
1.2
gpt-5-nano*
1.5
gpt-4.1-mini
1.62
gpt-4.1-nano*(2025-04-14 のスナップショット)
2.46
o4-mini*
1.72
gpt-4.1-mini については、2025-04-14 のスナップショットにこの倍率が適用されます。
* 非推奨で、提供終了が予定されています。終了日と代替モデルについては、提供終了スケジュール をご覧ください。これらのモデルは、料金計算ツールと上記のモデル別の画像サイズ調整表には含まれていません。
gpt-6-astra で detail: high を指定した場合の画像トークン数の計算例
この組み合わせでは、各辺の上限は 65,535 ピクセル、パッチ数の上限は 2,500、倍率は 1.2 倍です。
1024 × 1024 ピクセルの画像には 32 × 32 = 1024 パッチが必要です。リサイズは不要です。課金対象の画像入力は ceil(1024 × 1.2) = 1229 トークンです。
2048 × 2048 ピクセルの画像には、縮小前のサイズで 64 × 64 = 4096 パッチが必要です。パッチ数の上限に合わせて 1600 × 1600 ピクセルに縮小すると、50 × 50 = 2500 パッチになります。見積もりは ceil(2500 × 1.2) = 3000 トークンです。
4096 × 512 ピクセルの画像は元のサイズのままで、128 × 16 = 2048 パッチ、ceil(2048 × 1.2) = 2458 トークンです。
課金時の浮動小数点数の丸めにより、最終的なトークン数が見積もりと 1 トークンずれる場合があります。
次の表のモデルでは、基本トークン数に画像のタイル分のトークン数を加算します。
モデル
基本トークン数
タイルあたりのトークン数
gpt-5.1
70
140
gpt-5*
70
140
gpt-4o、gpt-4.1
85
170
gpt-4o-mini
2833
5667
o1*、o1-pro*、o3*
75
150
* 非推奨で、提供終了が予定されています。終了日と代替モデルについては、提供終了スケジュール をご覧ください。これらのモデルは、料金計算ツールと上記のモデル別の画像サイズ調整表には含まれていません。
"detail": "low" では、画像サイズにかかわらず、画像 1 枚につきモデルの基本トークン数だけが課金されます。"detail": "high" または "detail": "auto" では、次の手順で計算します。
縦横比を維持したまま、2048 × 2048 ピクセルの正方形に収まるように縮小します。小さい画像は拡大しません。
短辺が 768 ピクセルを超える場合は、短辺が 768 ピクセルになるように縮小し、もう一方の辺のピクセル数は小数部分を切り捨てます。
画像を覆うのに必要な一辺 512 ピクセルの正方形の数を求めます。各正方形に、モデルのタイルあたりのトークン数が適用されます。
タイル分のトークン数にモデルの基本トークン数を加算します。
GPT Image モデルによる画像の生成と編集には、画像トークン専用の料金体系が適用されます。画像認識モデル向けの計算ツールでは、GPT Image モデルの入力料金や出力料金は見積もれません。現在の単価は画像生成の料金 、生成と編集の手順は画像生成ガイド をご覧ください。
gpt-image-1 は 2026 年 10 月 23 日に提供を終了しました。過去の料金との比較用に、当時の入力トークンの計算規則を以下に示します。代替モデルについては、提供終了のお知らせ をご覧ください。
過去のリクエストについて計算する場合は、タイル単位のサイズ調整規則を使用します。ただし、短辺を縮小する際の基準は 768 ピクセルから 512 ピクセルに変わります。トークン使用量は、画像の幅と高さ、および input_fidelity パラメーターの値で決まります。このパラメーターは Images API で指定します。
入力の忠実度を低く設定した場合、基本の画像トークン数は 65 で、タイルごとに 129 画像トークンがかかります。
入力の忠実度を高く設定した場合は、上記の画像トークンに加えて、画像の縦横比に応じた固定数のトークンが加算されます。
画像が正方形の場合は、入力画像トークンが 4160 トークン加算されます。
縦長または横長に近い形の場合は、6240 トークン加算されます。
当時の画像入力トークンの単価については、GPT Image 1 のモデルページ をご覧ください。
画像認識モデルは誤った回答を返すことがあります。アプリケーションの設計では、次の制約を考慮してください。
医用画像 :モデルは CT 画像などの専門的な医用画像の読影には適していません。医学的な助言には使用しないでください。
英語以外の言語 :日本語や韓国語など、ラテン文字以外の文字を含む画像では、モデルが十分な性能を発揮できない場合があります。
小さな文字 :読み取りやすくするため、画像内の文字を拡大してください。対応するモデルでは、"detail": "original" を使うと読み取り精度が向上することもあります。
回転 :回転した文字や画像、上下逆さまの文字や画像を誤って解釈する場合があります。
視覚的な表現 :色の違いや、実線、破線、点線などのスタイルの違いで情報を表すグラフやテキストは、正しく読み取れない場合があります。
空間推論 :チェス盤上の駒の配置を特定するなど、位置を正確に把握する必要があるタスクは苦手です。
正確性 :状況によっては、画像の説明やキャプションに誤りが生じる場合があります。
画像の形状 :パノラマ画像や魚眼画像の解釈は苦手です。
メタデータとリサイズ :モデルは元のファイル名やメタデータを処理しません。詳細度が original の場合も含め、分析前に画像がリサイズされることがあります。各モデルに適用される上限は、「モデル別の画像サイズ調整 」をご覧ください。
個数のカウント :画像内の物体の個数について、モデルが概数を返す場合があります。
CAPTCHA :安全上の理由から、システムは CAPTCHA の送信をブロックします。