Skip to main content
POST
Generate or Edit Images

画像を生成する

テキスト プロンプトから新しい画像を生成するか、Google Gemini 2.5 Flash Image を使用して既存の画像を変換します。

エンドポイント

説明

テキストの説明から新しい画像を生成するか、既存の画像を変換します。このエンドポイントは以下をサポートします。
  • Text-to-Image: テキストの説明から画像を生成します
  • 画像から画像: 既存の画像を変換または編集します (画像ファイルをアップロードします)
すべてのプロンプトと応答は、監査ログとコンプライアンスのために SMLTP を通じて自動的に処理されます。

認証

必須: API キー

リクエスト本文

このエンドポイントは、multipart/form-data (ファイルのアップロード用) と application/json の両方の形式を受け入れます。

パラメータ

リクエストの例

テキストから画像への変換 (JSON)

画像から画像 (マルチパート フォーム データ)

JavaScript/Node.js

パイソン

応答

成功の応答 (200)

応答フィールド

画像オブジェクト

メタデータ オブジェクト

エラー応答

400 不正なリクエスト

401 不正

403 禁止

413 ペイロードが大きすぎます

500 内部サーバーエラー

503 サービスは利用できません

注意事項

  • アップロードでサポートされている画像形式: JPEG、PNG、WEBP、GIF
  • 最大ファイルサイズ: 画像あたり 10MB
  • 画像をアップロードするときに、画像を変換する方法について説明するプロンプトが表示されます
  • Gemini は通常、リクエストごとに 1 ~ 4 つのイメージを生成します
  • セキュリティとコンプライアンスのために、すべてのリクエストは SMLTP を通じて処理されます
  • URL の代わりに response_format: "b64_json" を使用して、base64 でエンコードされた画像データを受信します

承認

Authorization
string
header
必須

API key authentication using Bearer token format. Example: Authorization: Bearer sk-your-api-key-here

ボディ

prompt
string
必須

The text prompt describing the image to generate or how to transform the uploaded image

Required string length: 1 - 4000
:

"A beautiful sunset over the ocean with mountains in the background, digital art style"

image
file

Optional image file for image-to-image generation (JPEG, PNG, WEBP, or GIF, max 10MB)

smltp_policy
string
デフォルト:internal

SMLTP security policy to apply (e.g., 'internal', 'public', 'confidential', 'hipaa', 'gdpr')

:

"internal"

response_format
enum<string>
デフォルト:url

The format of the response images

利用可能なオプション:
url,
b64_json
:

"url"

size
string
デフォルト:1024x1024

The size of the generated images (for future use, currently uses default size)

:

"1024x1024"

n
integer
デフォルト:1

Number of images to generate (Gemini typically generates 1-4 images)

必須範囲: 1 <= x <= 4
:

1

レスポンス

Images generated successfully

success
boolean
:

true

id
string

Unique request identifier

:

"90d3756f-41c3-4f86-a18d-e257bfbc33a3"

object
string
:

"image.generation"

created
integer

Unix timestamp of when the images were created

:

1705312200

data
object[]

Array of generated images

metadata
object