واجهة برمجة التطبيقات ChatGPT المجانية

المقدمة

تتيح لك MiniToolAI Free ChatGPT API استخدام واجهة برمجة تطبيقات ChatGPT مجانًا. مناسبة للاختبار أو البحث أو أغراض التعلم وليست للاستخدام التجاري.

جرب واجهة برمجة التطبيقات الرسمية الخاصة بنا: وثائق API

من يمكنه استخدام MiniTool Free ChatGPT API؟

مفتاح API الخاص بك في MiniToolAI:

sk-*************   قم بتسجيل الدخول لإنشاء مفتاح API

إنشاء إكمال محادثة

POST https://minitoolai.com/api/chatgpt/

Headers "Authorization: Bearer MINITOOLAI-API-KEY"

Body

[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello"}
]

مثال على كود Python

import requests, json

url = "https://minitoolai.com/api/chatgpt/" #ending in "/"
headers = {
    "Authorization": "Bearer MINITOOLAI-API-KEY",
    "Content-Type": "application/json"
}
data = [
    {"role": "system", "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?"}
]

response = requests.post(url, headers=headers, json=data, stream=True)
print(response.text)

'''
#Response:
data: {"reasoning_content": "..."}

data: {"content": "..."}
'''

متدفق

import json
....
for line in response.iter_lines():
    if line:
        decode_line = line.decode("utf-8")

        if decode_line.startswith("data: "):
            try:
                json_line = json.loads(decode_line[6:])

                # reasoning_content
                if "reasoning_content" in json_line:
                    reasoning = json_line["reasoning_content"]
                    print(reasoning, end="", flush=True)

                # content
                if "content" in json_line:
                    content = json_line["content"]
                    print(content, end="", flush=True)

            except json.JSONDecodeError:
                pass

نتيجة واحدة

import json
....
result = ""
reasoning_result = ""

for line in response.iter_lines():
    if line:
        decode_line = line.decode("utf-8")

        if decode_line.startswith("data: "):
            try:
                json_line = json.loads(decode_line[6:])

                # reasoning_content
                if "reasoning_content" in json_line:
                    reasoning_result += json_line["reasoning_content"]

                # content
                if "content" in json_line:
                    result += json_line["content"]

            except json.JSONDecodeError:
                pass

print("=== REASONING ===")
print(reasoning_result)

print("\n=== CONTENT ===")
print(result)			

القيود

قد ترتكب واجهة برمجة التطبيقات أخطاء، تحقق من المعلومات المهمة.

حد الطلبات: 100,000 طلب شهريًا لكل مستخدم.

حاليًا في الإصدار التجريبي، يتم تحديثه أسبوعيًا.

الوسوم: واجهة برمجة تطبيقات OpenAI المجانية، واجهة برمجة تطبيقات ChatGPT المجانية، واجهة برمجة تطبيقات GPT المجانية، GPT-4o API مجاني

free gpt 5 api