L'API MiniToolAI fournit une interface simple aux modèles d'IA de pointe pour le traitement du langage naturel, la génération d'images et la synthèse vocale. Suivez ce guide pour apprendre à générer des réponses humaines (ChatGPT), à générer des images à partir de descriptions textuelles.
Le coût des requêtes API sera déduit de votre solde de crédit.
RechargerLa clé API doit être incluse dans l'en-tête de chaque requête API.
Header: "Authorization: Bearer API_key"
Crée une réponse du modèle pour la conversation donnée.
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-5.4-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
}
# For reasoning models, use 'reasoning_effort' in the request data.
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-5.4-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
];
// For reasoning models, use 'reasoning_effort' in the request data.
$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, gpt-5-nano, ...
"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, gpt-5-nano, ...
"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 tableau Obligatoire
Une liste de messages constituant la conversation jusqu'à présent.
model chaîne Obligatoire
ID du modèle à utiliser
Modèles disponibles: "gpt-4o", "gpt-4o-mini", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano", "gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-5.1", "gpt-5.2", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "gpt-5.5", "gpt-5.3-codex", "gpt-5.1-codex-mini"
temperature nombre ou null Optionnel
Par défaut à 1
Température d'échantillonnage à utiliser, entre 0.0 et 2.0. Des valeurs plus élevées comme 0.8 rendent la sortie plus créative, tandis que des valeurs plus basses comme 0.2 la rendent plus ciblée et déterministe.
max_completion_tokens entier ou null Optionnel
Par défaut à 1000
Une limite supérieure du nombre de tokens pouvant être générés pour une complétion
reasoning_effort "none", "minimal", "low", "medium", "high" Optionnel
Par défaut à "minimal" / "none"
Ajustez le niveau de raisonnement du modèle. Cette fonctionnalité est uniquement prise en charge pour les modèles GPT-5 et supérieurs. GPT-5 prend en charge "minimal", "low", "medium" et "high", tandis que GPT-5.1 et les versions ultérieures prennent en charge "none", "low", "medium" et "high".
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]
Crée une image à partir d'une invite.
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}
*/
?>
Récupérer le statut et le résultat du travail
curl -X POST https://minitoolai.com/api/texttoimage/jobs/ \
-H "Content-Type: application/json" \
-d '{
"jobid": "12345678",
"signature": "abcxyz123"
}'
Réponse
{
"status": "success",
"image_url": "https://...",
"message": "success"
}
model chaîne Obligatoire
ID du modèle à utiliser
Modèles disponibles: "realvision", "juggernaut", "autismmix", "dreamshaper", "valhalla", "mixrealistic", "campursari", "reality", "extrarealistic", "realism", "realgirls", "realityreborn", "amigo", "simplemix", "beautifulrealistic"
prompt chaîne Obligatoire
Description de l'image
negativePrompt chaîne ou null Optionnel
Description de ce que vous souhaitez exclure de l'image générée
scheduler chaîne ou null Optionnel
Contrôle comment le bruit est supprimé lors du processus de génération d'image.
Par défaut à "DPM++ SDE"
Les valeurs possibles sont: "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 entier ou null Optionnel
Le nombre d'étapes du processus de génération d'image, entre 1 et 8.
Par défaut à 4
cfgScale nombre ou null Optionnel
cfgScale Contrôle dans quelle mesure le modèle doit respecter l'invite textuelle donnée. Il équilibre entre créativité et précision, entre 1 et 7.
Par défaut à 2
cfgScale < 4 → images plus créatives, cfgScale > 4 → plus fidèle à l'invite, moins créatif
width/height entier ou null Optionnel
La taille de l'image générée, entre 256 et 1344.
Par défaut à 1024
Prix par 1M de tokens
| Modèle | Entrée | Sortie |
|---|---|---|
| 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 |
| gpt-5 | $1.25 | $10.00 |
| gpt-5-mini | $0.25 | $2.00 |
| gpt-5-nano | $0.05 | $0.40 |
| gpt-5.1 | $1.25 | $10.00 |
| gpt-5.2 | $1.75 | $14.00 |
| gpt-5.4 | $2.50 | $15.00 |
| gpt-5.4-mini | $0.75 | $4.50 |
| gpt-5.4-nano | $0.20 | $1.25 |
| gpt-5.5 | $5.00 | $30.00 |
| gpt-5.3-codex | $1.75 | $14.00 |
| gpt-5.1-codex-mini | $0.25 | $2.00 |
| Modèle | Prix par image |
|---|---|
| Tous les modèles | $0.0015 |