はじめに

イントロダクション

MiniToolAI APIは、自然言語処理、画像生成、テキスト読み上げのための最先端AIモデルを簡単に利用できるインターフェースを提供します。本ガイドを参考に、人間らしい応答(ChatGPT)を生成したり、テキストの説明から画像を作成したりする方法を学びましょう。

APIキーを作成

sk-*************   APIキーを生成するにはログインしてください

チャージ

APIリクエストの費用は、クレジット残高から差し引かれます。

チャージする

認証

すべてのAPIリクエストのヘッダーにAPIキーを含める必要があります。

Header: "Authorization: Bearer API_key"

 

 

 

 

ChatGPT API

指定されたチャットの会話に対してモデルの応答を生成します。

Python PHP
import requests
import json
API_Url = "https://minitoolai.com/api/chat-completions/"
API_Key = "MiniToolAI_API_Key"
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {API_Key}"
}
data = {
    "model": "gpt-4o-mini", #gpt-4o, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano
    "messages": [
		{"role": "developer", "content": "You are a helpful assistant."},
		{"role": "user", "content": "Hello"},
		{"role": "assistant", "content": "How can I help you today?"},
		{"role": "user", "content": "What's the largest U.S. state by area?"}
    ],
	"temperature": 1.0,
	"max_completion_tokens": 1000
}

response = requests.post(API_Url, headers=headers, json=data, stream=True)

#single result
print(response.text) 

#streamed
for line in response.iter_lines():
    if line:
        decode_line = line.decode('utf-8')
        print(decode_line)
<?php

$api_url = "https://minitoolai.com/api/chat-completions/";
$api_key = "MiniToolAI_API_Key"; 

$data = [
    "model" => "gpt-4o-mini", //gpt-4o, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano
    "messages" => [
        ["role" => "developer", "content" => "You are a helpful assistant."],
        ["role" => "user", "content" => "Hello"],
        ["role" => "assistant", "content" => "How can I help you today?"],
        ["role" => "user", "content" => "What's the largest U.S. state by area?"],
    ],
    "temperature" => 1.0,
    "max_completion_tokens" => 1000
];

$headers = [
    "Content-Type: application/json",
    "Authorization: Bearer $api_key"
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); 
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

// streamed
curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($ch, $data) {
    echo $data;
    ob_flush(); 
    flush();     
    return strlen($data); 
});

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo "cURL error: " . curl_error($ch);
} 

curl_close($ch);

?>
#data with image input
data = {
    "model": "gpt-4o-mini", #gpt-4o
    "messages": [
        {"role": "developer", "content": "You are a helpful assistant."},
        {
            "role": "user", 
            "content": [
                {"type": "text", "text": "What's in this image?"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://example.com/image.jpg", #jpg, jpeg, png, webp or gif
                        "detail": "auto" #auto, high or low
                    }
                }
            ]
        }

    ],
    "temperature": 0.7,
    "max_completion_tokens": 300
}
//data with image input
$data = [
    "model" => "gpt-4o-mini", // gpt-4o
    "messages" => [
        ["role" => "developer", "content" => "You are a helpful assistant."],
        [
            "role" => "user",
            "content" => [
                [
                    "type" => "text",
                    "text" => "What's in this image?"
                ],
                [
                    "type" => "image_url",
                    "image_url" => [
                        "url" => "https://example.com/image.jpg", // jpg, jpeg, png, webp or gif
                        "detail" => "auto" // auto, high or low
                    ]
                ]
            ]
        ]
    ],
    "temperature" => 0.7,
    "max_completion_tokens" => 300
];

リクエストボディ

messages 配列 必須

これまでの会話を構成するメッセージのリスト。

  • Developer message: 開発者が提供する指示で、ユーザーが送信するメッセージに関係なくモデルが従うべきもの。
  • User message: エンドユーザーが送信するメッセージ。プロンプトや追加のコンテキスト情報を含みます。
  • Assistant message: モデルがユーザーのメッセージに応じて送信するメッセージ。

model 文字列 必須

使用するモデルのID

利用可能なモデル: gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano

temperature 数値またはnull オプション

デフォルトは 1

使用するサンプリング温度(0.0から2.0の範囲)。値が高い(例: 0.8)ほどクリエイティブになり、低い(例: 0.2)ほどフォーカスされ決定論的になります。

max_completion_tokens 整数またはnull オプション

デフォルトは 1000

生成可能なトークン数の上限。

レスポンス

data: {"id":"chatcmpl-B5qoZsT8kFDNJK3UyGLiJmjv6Pp90","object":"chat.completion.chunk","created":1740734359,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_06737a9306","choices":[{"index":0,"delta":{"content":"Ok"},"logprobs":null,"finish_reason":null}],"usage":null}

data: {"id":"chatcmpl-B5qoZsT8kFDNJK3UyGLiJmjv6Pp90","object":"chat.completion.chunk","created":1740734359,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_06737a9306","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null}

data: {"id":"chatcmpl-B5qoZsT8kFDNJK3UyGLiJmjv6Pp90","object":"chat.completion.chunk","created":1740734359,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_06737a9306","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null}

data: {"id":"chatcmpl-B5qoZsT8kFDNJK3UyGLiJmjv6Pp90","object":"chat.completion.chunk","created":1740734359,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_06737a9306","choices":[],"usage":{"prompt_tokens":17,"completion_tokens":3,"total_tokens":20,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}}}

data: [DONE]

 

 

 

 

テキストから画像へ

プロンプトを元に画像を作成します。

Python PHP
import requests
import json
url = "https://minitoolai.com/api/texttoimage/"
API_Key = "MiniToolAI_API_Key"
headers = {
    "Content-Type": "application/json",
    "Authorization": f"Bearer {API_Key}"
}
data = {
    "model": "realvision",
    "prompt": "Ultra realistic portrait of a 20 year old woman, wearing an elegant black gown, joyful expression, deep shadows, cinematic composition, moody lighting",
    "negativePrompt": "unrealistic eyes, malformed features, ugly drawn",
    "scheduler": "DPM++ SDE",
    "steps": 4,
    "cfgScale": 2.0,
    "width": 1152,
    "height": 768
}
response = requests.post(url, json=data, headers=headers)
print(response.text)

'''
#response
Success:
{"status":"success","jobid":12345678,"signature":"abcxyz123"}
Error:
{"status":"error","jobid":null,"signature":null}
'''
<?php
// API URL and Key
$url = "https://minitoolai.com/api/texttoimage/";
$API_Key = "MiniToolAI_API_Key";

// Headers
$headers = [
    "Content-Type: application/json",
    "Authorization: Bearer $API_Key"
];

// Data to be sent in the request
$data = [
    "model" => "realvision",
    "prompt" => "Ultra realistic portrait of a 20 year old woman, wearing an elegant black gown, joyful expression, deep shadows, cinematic composition, moody lighting",
    "negativePrompt" => "unrealistic eyes, malformed features, ugly drawn",
    "scheduler" => "DPM++ SDE",
    "steps" => 4,
    "cfgScale" => 2.0,
    "width" => 1152,
    "height" => 768
];

// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

// Execute the cURL request
$response = curl_exec($ch);

echo $response;

// Close the cURL session
curl_close($ch);

/*
Response:
Success:
{"status":"success","jobid":12345678,"signature":"abcxyz123"}
Error:
{"status":"error","jobid":null,"signature":null}
*/
?>

ジョブのステータスと結果を取得

curl -X POST https://minitoolai.com/api/texttoimage/jobs/ \
  -H "Content-Type: application/json" \
  -d '{
    "jobid": "12345678",
    "signature": "abcxyz123"
  }'

レスポンス

{
  "status": "success",
  "image_url": "https://...",
  "message": "success"
}

model 文字列 必須

使用するモデルのID

利用可能なモデル: "realvision", "juggernaut", "autismmix", "dreamshaper", "valhalla", "mixrealistic", "campursari", "reality", "extrarealistic", "realism", "realgirls", "realityreborn", "amigo", "simplemix", "beautifulrealistic"

prompt 文字列 必須

画像の説明

negativePrompt 文字列またはnull オプション

生成する画像から除外したい要素の説明

scheduler 文字列またはnull オプション

画像生成プロセス中のノイズ除去を制御します。

デフォルトは "DPM++ SDE"

可能な値は: "Euler a", "Euler", "LMS", "Heun", "DPM2", "DPM2 a", "DPM++ 2S a", "DPM++ 2M", "DPM++ SDE", "DPM++ 2M SDE", "DPM fast", "LMS Karras", "DPM2 Karras", "DPM2 a Karras", "DPM++ 2S a Karras", "DPM++ 2M Karras", "DPM++ SDE Karras", "DPM++ 2M SDE Karras"

steps 整数またはnull オプション

画像生成プロセスのステップ数(1~8の間)。

デフォルトは 4

cfgScale 数値またはnull オプション

cfgScale モデルが指定されたテキストプロンプトにどれだけ従うかを制御します。創造性とプロンプトの正確さのバランスを取り、1〜7の間で調整します。

デフォルトは 2

cfgScale < 4 → よりクリエイティブな画像, cfgScale > 4 → プロンプトに忠実で、創造性が低い

width/height 整数またはnull オプション

生成される画像のサイズ(256から1344の範囲)。

デフォルトは 1024

 

 

 

 

API価格

GPTモデル

100万トークンあたりの価格

モデル 入力 出力
gpt-4o-mini $0.15 $0.60
gpt-4o $2.50 $10.00
gpt-4.1 $2.00 $8.00
gpt-4.1-mini $0.40 $1.60
gpt-4.1-nano $0.10 $0.40

画像生成

モデル 画像ごとの価格
すべてのモデル $0.0015

 

 

 

 

API使用量

API使用量を見るにはログインしてください

テキスト生成

画像生成