近年の言語モデルは、画像入力を処理して分析できます。この機能は 視覚認識 と呼ばれます。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 回のリクエストで複数の画像を入力できます。ただし、画像はトークンとしてカウントされ 、その数に応じて課金される点に注意してください。
URL を渡す Base64 エンコードされた画像を渡す 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 回のリクエストで複数の画像を入力できます。ただし、画像はトークンとしてカウントされ 、その数に応じて課金される点に注意してください。
URL を渡す Base64 エンコードされた画像を渡す ファイル 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) リクエストサイズ リクエストあたりの合計ペイロードは最大 512 MB 画像数 リクエストあたり最大 1,500 枚
パッチベースの画像入力 では、選択したモデルと detail レベルのリサイズルールを適用した後、API は画像 1 枚あたり最大 30,000 パッチをサポートします。この上限は、サポートされるすべての詳細度に共通で、各画像に個別に適用されます。リクエスト全体の合計パッチ数に対する上限ではありません。
モデルや詳細度ごとに設定された、より低いリサイズ時の上限も引き続き適用されます。処理後に 30,000 パッチの上限を超える画像は拒否され、この上限に収まるように自動でリサイズされることはありません。画像の寸法を小さくして、もう一度お試しください。
画像トークンとプロンプトの残りの部分も、モデルの入力上限とコンテキスト上限に収まる必要があります。トークン数の推定だけでは、リクエストがすべての入力上限を満たしているとは保証できません。画像の使用にあたっては、OpenAI の使用ポリシー を遵守する必要があります。
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" を使用してください。詳細度を original にしても、モデルのピクセル寸法の上限やリサイズ時のパッチ数上限に収まるよう、画像がリサイズされる場合があります。ただし、別途設けられた、リクエストを拒否する基準となる 30,000 パッチの上限に収めるためのリサイズは行われません。座標の正確さが重要なタスクでは、送信前にこれらの上限に収まるよう画像をリサイズし、返された座標を元画像の座標に変換してください。座標の扱いについては、コンピューターの使用ガイド を参照してください。
以下の表は、汎用ビジョンモデルのサイズ調整の動作をまとめたものです。その他のモデルや特化型の派生モデルでは、異なる制限が適用される場合があります。サイズ調整では常にアスペクト比が維持され、小さい画像が拡大されることはありません。
モデルファミリー
サポートされる詳細度
パッチとリサイズの動作 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 枚の入力トークン数とコストを見積もれます。
一部のモデルでは、画像を 32px x 32px のパッチで覆うことでトークン化します。多くのモデルと詳細度の組み合わせでは、リサイズ時のパッチ数上限が定められています。まず API は、選択された詳細度のピクセル寸法の上限に画像を収めます。その際、アスペクト比を維持し、ピクセル数を整数に丸めます。小さい画像を拡大することはありません。その後、トークンのコストを次のように算出します。
A. ピクセル寸法の上限を適用した後の画像を覆うために必要な、32px x 32px のパッチ数を計算します。パッチは画像の境界をはみ出してもかまいません。
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-astra1.2 gpt-5.6-sol1.2 gpt-5.6-terra1.2 gpt-5.6-luna1.2 gpt-5.51.2 gpt-5.41.2 gpt-5.4-mini1.2 gpt-5.4-nano1.2 gpt-5.21.2 gpt-5-mini*1.2 gpt-5-nano*1.5 gpt-4.1-mini1.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.170 140 gpt-5*70 140 gpt-4o、gpt-4.185 170 gpt-4o-mini2833 5667 o1*、o1-pro*、o3*75 150
* 非推奨となり、提供終了が予定されています。日程と代替モデルについては、廃止スケジュール を参照してください。これらのモデルは、計算ツールや上記のモデル別サイズ調整の表には含まれていません。
"detail": "low" の場合、画像のサイズにかかわらず、モデルの基本トークン数のみが課金対象になります。"detail": "high" または "detail": "auto" の場合は、次のように計算します。
アスペクト比を維持しながら、2048px x 2048px の正方形に収まるように縮小します。それより小さい画像は拡大しません。
短辺が 768px を超える場合は、短辺を 768px に縮小し、もう一方の辺のサイズは小数点以下を切り捨てます。
画像全体を覆うのに必要な一辺 512px の正方形の数を数えます。正方形ごとに、そのモデルのタイルあたりのトークン数を使用します。
タイル分のトークン数にモデルの基本トークン数を加算します。
GPT Image モデルでは、画像の生成と編集に専用の画像トークン料金が適用されます。ビジョン用の計算ツールでは、これらのモデルの入力コストや出力コストは推定できません。現在の料金は画像生成の料金 を、生成と編集のワークフローは画像生成ガイド を参照してください。
gpt-image-1 には、次の入力トークンのルールが適用されます。タイルベースの画像サイズ調整を使用しますが、短辺は 768px ではなく 512px に縮小します。トークン使用量は、画像のサイズと Images API の input_fidelity パラメーターによって決まります。
入力忠実度を low に設定した場合、基本コストは 65 画像トークンで、各タイルのコストは 129 画像トークンです。
入力忠実度を high に設定した場合は、上記の画像トークンに加えて、画像のアスペクト比に応じた所定のトークン数が加算されます。
画像が正方形の場合、入力画像トークンが 4160 トークン追加されます。
縦長または横長に近い画像の場合、6240 トークンが追加されます。
画像入力トークンの料金については、画像料金のセクション を参照してください。
ビジョンモデルは誤ることがあります。アプリケーションを設計する際は、次の制限事項を考慮してください。
医療画像 :モデルは CT スキャンなどの専門的な医療画像の解釈には適しておらず、医学的な助言に使用すべきではありません。
英語以外の言語 :日本語や韓国語など、ラテン文字以外の文字を含む画像を扱う場合、モデルが十分な性能を発揮できないことがあります。
小さな文字 :読み取りやすくするために、画像内の文字を拡大してください。利用可能な場合は、"detail": "original" を使用することでも性能が向上する可能性があります。
回転 :モデルは、回転した文字や画像、上下が逆さまの文字や画像を誤って解釈することがあります。
視覚要素 :モデルは、色やスタイル(実線、破線、点線など)が混在するグラフやテキストの理解が難しい場合があります。
空間推論 :モデルは、チェスの駒の配置の識別など、空間内の位置を正確に特定する必要があるタスクを苦手とします。
正確性 :状況によっては、モデルが誤った説明やキャプションを生成することがあります。
画像の形状 :モデルは、パノラマ画像や魚眼画像を苦手とします。
メタデータとサイズ調整 :モデルは元のファイル名やメタデータを処理しません。詳細レベルを original に設定した場合でも、分析前に画像のサイズが調整されることがあります。各モデルに適用される制限については、モデル別のサイズ調整 を参照してください。
個数のカウント :モデルが示す画像内の物体の個数は、おおよその値になる場合があります。
CAPTCHA :安全上の理由から、システムは CAPTCHA の送信をブロックします。