> ## Documentation Index
> Fetch the complete documentation index at: https://docs.acedata.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# طلب واستخدام OpenAI Responses API

> OpenAI generation API guide - Ace Data Cloud

قدّمت OpenAI مؤخرًا واجهة لإنشاء استجابات النماذج. وفّر إدخالًا نصيًا أو صوريًا لإنشاء مخرجات نصية أو صورية. اجعل النموذج يستدعي التعليمات البرمجية المخصصة الخاصة بك أو يستخدم الأدوات المضمنة، مثل البحث على الويب أو البحث في الملفات، لاستخدام بياناتك الخاصة كمدخلات لاستجابة النموذج.

تقدّم هذه الوثيقة بشكل رئيسي عملية استخدام OpenAI Responses API، وباستخدامها يمكننا بسهولة استخدام وظيفة إنشاء استجابات النماذج الرسمية من OpenAI.

## GPT-6.1 Sol

استخدم `model: "gpt-6.1-sol"` لاختيار هذا النموذج. يدعم الإخراج المتدفق، واستدعاء الدوال، والإخراج المنظّم، وإدخال الصور. خلال الأسبوع الأول من الإتاحة، سيكون متاحًا فقط لحاملي ACE T1+ الذين تم التحقق منهم (100,000 ACE على الأقل) أو للمستخدمين المصرح لهم؛ ويُرجى الرجوع إلى تنبيه الوصول في وحدة التحكم لمعرفة وقت الإتاحة المحدد.

تدعم مستويات الاستدلال `low` و`medium` و`high` و`xhigh` و`max`، ولا تدعم مؤقتًا `none` أو `minimal`. يُوصى بالبدء بـ `reasoning: {"effort": "low"}`. عند تجاوز الإدخال 272,000 token، ينطبق تسعير السياق الطويل على الطلب بالكامل، وتخضع الرسوم للسعر الحالي في وحدة التحكم.

## عملية التقديم

لاستخدام OpenAI Responses API، انتقل أولًا إلى [وحدة تحكم Ace Data Cloud](https://platform.acedata.cloud/console/applications) للحصول على API Token الخاص بك، واحتفظ به كنسخة احتياطية.

![](https://cdn.acedata.cloud/dvc3cg.jpg)

إذا لم تكن قد سجلت الدخول أو أنشأت حسابًا بعد، فسيتم تحويلك تلقائيًا إلى صفحة تسجيل الدخول لدعوتك إلى التسجيل وتسجيل الدخول، وبعد الإكمال ستعود تلقائيًا إلى الصفحة الحالية.

**يمكن لـ API Token واحد استدعاء جميع خدمات المنصة، ولا حاجة للتقديم بشكل منفصل لكل خدمة.** سيُمنحك رصيد مجاني عند التقديم لأول مرة، ويمكنك التجربة مجانًا؛ وعندما لا يكون الرصيد كافيًا، يمكنك شحن الرصيد العام من [وحدة التحكم](https://platform.acedata.cloud/console/coin).

> 📘 الوثائق الكاملة: [OpenAI Responses API →](https://platform.acedata.cloud/documents/openai-responses)

## الاستخدام الأساسي

بعد ذلك، يمكنك تعبئة المحتوى المقابل في الواجهة، كما هو موضح في الصورة:

![](https://cdn.acedata.cloud/8lu8di.png)

عند استخدام هذه الواجهة للمرة الأولى، نحتاج إلى تعبئة ثلاثة عناصر على الأقل. أحدها هو `authorization`، ويمكن اختياره مباشرة من القائمة المنسدلة. المعلمة الأخرى هي `model`، و`model` هي فئة نموذج OpenAI ChatGPT الرسمية التي نختار استخدامها، وهنا لدينا بشكل رئيسي 20 نموذجًا، ويمكنك الاطلاع على التفاصيل في النماذج التي نوفرها. المعلمة الأخيرة هي `input`، و`input` هي مصفوفة كلمات السؤال التي ندخلها، وهي مصفوفة، ما يعني أنه يمكن رفع عدة كلمات سؤال في الوقت نفسه، وتحتوي كل كلمة سؤال على `role` و`content`، حيث يشير `role` إلى دور السائل، ونحن نوفر ثلاث هويات، وهي `user` و`assistant` و`system`. أما `content` الآخر فهو المحتوى المحدد لسؤالنا.

وفي الوقت نفسه، يمكنك ملاحظة وجود توليد للكود المقابل للاستدعاء على الجانب الأيمن، ويمكنك نسخ الكود وتشغيله مباشرة، أو النقر مباشرة على زر «Try» للاختبار.

المعلمات الاختيارية الشائعة:

* `max_tokens`: يحدّ من الحد الأقصى لعدد tokens في الرد الواحد.
* `temperature`: عشوائية التوليد، بين 0 و2، وكلما زادت القيمة زاد التشتت.
* `n`: عدد الردود المرشحة التي يتم إنشاؤها دفعة واحدة.
* `response_format`: إعداد تنسيق الإرجاع.
* `tools`: تعريف استدعاء الدوال/الأدوات.
* `background`: ما إذا كان التشغيل غير متزامن في الخلفية.

![](https://cdn.acedata.cloud/rsw47a.png)

بعد الاستدعاء، نجد أن النتيجة المرجعة كما يلي:

```json theme={null}
{
  "id": "resp_68a98322e3c88191a027de2711a02a490554cad0b36c0400",
  "object": "response",
  "created_at": 1755939618,
  "status": "completed",
  "background": false,
  "content_filters": null,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "max_tool_calls": null,
  "model": "gpt-5.5",
  "output": [
    {
      "id": "msg_68a98323422c8191a7f383eea48ba5160554cad0b36c0400",
      "type": "message",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "annotations": [],
          "text": "Hello! How can I assist you today?"
        }
      ],
      "role": "assistant"
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "prompt_cache_key": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "safety_identifier": null,
  "service_tier": "default",
  "store": true,
  "temperature": 1,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 8,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 10,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 18
  },
  "user": null,
  "metadata": {}
}
```

تحتوي النتيجة المرجعة على عدة حقول، ويُعرّف كل منها كما يلي:

* `id`، معرّف مهمة المحادثة التي تم إنشاؤها هذه المرة، ويُستخدم لتمييز مهمة المحادثة هذه بشكل فريد.
* `model `، نموذج OpenAI ChatGPT الرسمي المختار.
* `output`، معلومات الإجابة التي يقدّمها ChatGPT لكلمة السؤال.
* `usage `: معلومات إحصائية عن tokens لهذه الجلسة من السؤال والجواب.

من بينها، `output` يحتوي على معلومات إجابة ChatGPT، و`output` بداخله هو ChatGPT، ويمكن ملاحظة ذلك كما هو موضح في الصورة.

![](https://cdn.acedata.cloud/mald8o.png)

يمكن ملاحظة أن حقل `content` داخل `output` يحتوي على المحتوى المحدد لرد ChatGPT.

## الاستجابة المتدفقة

تدعم هذه الواجهة أيضًا الاستجابة المتدفقة، وهذا مفيد جدًا لربط صفحات الويب، إذ يمكنه جعل صفحة الويب تحقق تأثير العرض حرفًا بحرف.

إذا أردت إرجاع الاستجابة بشكل متدفق، يمكنك تغيير معلمة `stream ` في رأس الطلب إلى `true`.

يظهر التعديل كما في الصورة، لكن يجب أن يحتوي كود الاستدعاء على تعديلات مقابلة حتى يدعم الاستجابة المتدفقة.

![](https://cdn.acedata.cloud/xidnao.png)

بعد تعديل `stream` إلى `true`، ستعيد API بيانات JSON المقابلة سطرًا بسطر، وعلى مستوى الكود نحتاج إلى إجراء التعديلات المقابلة للحصول على النتائج سطرًا بسطر.

كود استدعاء نموذجي لـ Python:

```python theme={null}
import requests

url = "https://api.acedata.cloud/openai/responses"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "model": "gpt-4.1",
    "input": [{"role":"user","content":"Hello"}],
    "stream": True
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)
```

يكون تأثير الإخراج كما يلي:

```json theme={null}
data: {"type": "response.created", "sequence_number": 0, "response":
{"id": "resp_68a9837bb9bc8190b403947311db6faa0721186e8fbb89d0", "object": "response", "created_at": 1755939707, "status": "in_progress", "background": false, "content_filters": null, "error": null, "incomplete_details": null, "instructions": null, "max_output_tokens": null, "max_tool_calls": null, "model": "gpt-4.1-data", "output": [], "parallel_tool_calls": true, "previous_response_id": null, "prompt_cache_key": null, "reasoning": {"effort": null, "summary": null}, "safety_identifier": null, "service_tier": "auto", "store": true, "temperature": 1.0, "text": {"format": {"type": "text"}}, "tool_choice": "auto", "tools": [], "top_p": 1.0, "truncation": "disabled", "usage": null, "user": null, "metadata": {}}, "model": "gpt-4.1"} 

data: {"type": "response.in_progress", "sequence_number": 1, "response": {"id": "resp_68a9837bb9bc8190b403947311db6faa0721186e8fbb89d0", "object": "response", "created_at": 1755939707, "status": "in_progress", "background": false, "content_filters": null, "error": null, "incomplete_details": null, "instructions": null, "max_output_tokens": null, "max_tool_calls": null, "model": "gpt-4.1-data", "output": [], "parallel_tool_calls": true, "previous_response_id": null, "prompt_cache_key": null, "reasoning": {"effort": null, "summary": null}, "safety_identifier": null, "service_tier": "auto", "store": true, "temperature": 1.0, "text": {"format": {"type": "text"}}, "tool_choice": "auto", "tools": [], "top_p": 1.0, "truncation": "disabled", "usage": null, "user": null, "metadata": {}}, "model": "gpt-4.1"} 

data: {"type": "response.output_item.added", "sequence_number": 2, "output_index": 0, "item": {"id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "type": "message", "status": "in_progress", "content": [], "role": "assistant"}, "model": "gpt-4.1"} 

data: {"type": "response.content_part.added", "sequence_number": 3, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "part": {"type": "output_text", "annotations": [], "text": ""}, "model": "gpt-4.1"} 

data: {"type": "response.output_text.delta", "sequence_number": 4, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "delta": "مرحبًا", "model": "gpt-4.1"} 

data: {"type": "response.output_text.delta", "sequence_number": 5, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "delta": "!", "model": "gpt-4.1"} 

data: {"type": "response.output_text.delta", "sequence_number": 6, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "delta": " كيف", "model": "gpt-4.1"} 

data: {"type": "response.output_text.delta", "sequence_number": 7, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "delta": " يمكنني", "model": "gpt-4.1"} 

data: {"type": "response.output_text.delta", "sequence_number": 8, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "delta": " أن", "model": "gpt-4.1"} 

data: {"type": "response.output_text.delta", "sequence_number": 9, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "delta": " أساعدك", "model": "gpt-4.1"} 

data: {"type": "response.output_text.delta", "sequence_number": 10, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "delta": " اليوم", "model": "gpt-4.1"} 

data: {"type": "response.output_text.delta", "sequence_number": 11, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "delta": "؟", "model": "gpt-4.1"} 

data: {"type": "response.output_text.delta", "sequence_number": 12, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "delta": " 😊", "model": "gpt-4.1"} 

data: {"type": "response.output_text.done", "sequence_number": 14, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "text": "مرحبًا! كيف يمكنني أن أساعدك اليوم؟ 😊", "model": "gpt-4.1"} 

data: {"type": "response.content_part.done", "sequence_number": 15, "item_id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "output_index": 0, "content_index": 0, "part": {"type": "output_text", "annotations": [], "text": "مرحبًا! كيف يمكنني أن أساعدك اليوم؟ 😊"}, "model": "gpt-4.1"} 

data: {"type": "response.output_item.done", "sequence_number": 16, "output_index": 0, "item": {"id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "type": "message", "status": "completed", "content": [{"type": "output_text", "annotations": [], "text": "مرحبًا! كيف يمكنني أن أساعدك اليوم؟ 😊"}], "role": "assistant"}, "model": "gpt-4.1"} 

data: {"type": "response.completed", "sequence_number": 17, "response":
{"id": "resp_68a9837bb9bc8190b403947311db6faa0721186e8fbb89d0", "object": "response", "created_at": 1755939707, "status": "completed", "background": false, "content_filters": null, "error": null, "incomplete_details": null, "instructions": null, "max_output_tokens": null, "max_tool_calls": null, "model": "gpt-4.1-data", "output": [{"id": "msg_68a9837c49f081908f568bf9c6065c620721186e8fbb89d0", "type": "message", "status": "completed", "content": [{"type": "output_text", "annotations": [], "text": "مرحبًا! كيف يمكنني مساعدتك اليوم؟ 😊"}], "role": "assistant"}], "parallel_tool_calls": true, "previous_response_id": null, "prompt_cache_key": null, "reasoning": {"effort": null, "summary": null}, "safety_identifier": null, "service_tier": "default", "store": true, "temperature": 1.0, "text": {"format": {"type": "text"}}, "tool_choice": "auto", "tools": [], "top_p": 1.0, "truncation": "disabled", "usage": {"input_tokens": 8, "input_tokens_details": {"cached_tokens": 0}, "output_tokens": 11, "output_tokens_details": {"reasoning_tokens": 0}, "total_tokens": 19}, "user": null, "metadata": {}}, "model": "gpt-4.1"} 

```

يمكن ملاحظة أن الاستجابة تحتوي على العديد من `data`، و`delta` داخل `data` هو أحدث محتوى للإجابة، وهو متوافق مع المحتوى المذكور أعلاه. يمثل `delta` محتوى الإجابة المضاف، ويمكنك دمجه في نظامك بناءً على النتيجة. تنتهي الاستجابة المتدفقة بحالة `response.completed` أو `response.incomplete`؛ ويُعد `usage` في الحالة النهائية هو إجمالي استخدام token النهائي لهذا الطلب، وهو أيضًا أساس الفوترة.

إذا قطع العميل الاتصال قبل وصول الحالة النهائية، فسيُسجَّل هذا الطلب على أنه مغلق من قبل العميل (499)، ولن تتم الفوترة باستخدام token المقدّرة محليًا؛ وإذا انتهى الاتصال بشكل طبيعي ولكن لم يتم استلام الحالة النهائية و`usage` النهائي، فسيُسجَّل هذا الطلب على أنه استجابة غير مكتملة (502)، وبالمثل لن تتم الفوترة باستخدام token المقدّرة. عند مواجهة هاتين الحالتين، يُرجى إعادة إرسال الطلب.

تتضمن نتيجة `data` المُعادة عدة حقول، وهي موضحة كما يلي:

* `item_id`، معرّف مهمة المحادثة التي تم إنشاؤها هذه المرة، ويُستخدم للتمييز الفريد لمهمة المحادثة هذه.
* `type`، نوع مهمة Responses للمحادثة التي تم إنشاؤها هذه المرة.
* `model `، نموذج OpenAI ChatGPT الرسمي المحدد.
* `delta`، معلومات الإجابة التي يقدمها ChatGPT على نص السؤال.

يدعم JavaScript أيضًا، على سبيل المثال، يكون كود الاستدعاء المتدفق لـ Node.js كما يلي:

```javascript theme={null}
const options = {
  method: "post",
  headers: {
    accept: "application/json",
    authorization: "Bearer b82d32f570bc434d9ba9923aa0e7dce0",
    "content-type": "application/json",
  },
  body: JSON.stringify({
    model: "gpt-4.1",
    input: [{ role: "user", content: "Hello" }],
    stream: true,
  }),
};

fetch("https://api.acedata.cloud/openai/responses", options)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));
```

كود مثال Java:

```java theme={null}
JSONObject jsonObject = new JSONObject();
jsonObject.put("model", "gpt-4.1");
jsonObject.put("input", [{"role":"user","content":"Hello"}]);
jsonObject.put("stream", true);
MediaType mediaType = "application/json; charset=utf-8".toMediaType();
RequestBody body = jsonObject.toString().toRequestBody(mediaType);
Request request = new Request.Builder()
  .url("https://api.acedata.cloud/openai/responses")
  .post(body)
  .addHeader("accept", "application/json")
  .addHeader("authorization", "Bearer b82d32f570bc434d9ba9923aa0e7dce0")
  .addHeader("content-type", "application/json")
  .build();

OkHttpClient client = new OkHttpClient();
Response response = client.newCall(request).execute();
System.out.print(response.body!!.string())
```

يمكن إعادة كتابة اللغات الأخرى بشكل منفصل، والمبدأ واحد.

## محادثات متعددة الجولات

إذا كنت ترغب في دمج وظيفة المحادثات متعددة الجولات، فستحتاج إلى تحميل عدة نصوص أسئلة في حقل `input`، ويُوضّح المثال المحدد لنصوص الأسئلة المتعددة في الصورة التالية:

![](https://cdn.acedata.cloud/1jqwnf.png)

كود استدعاء مثال Python:

```python theme={null}
import requests

url = "https://api.acedata.cloud/openai/responses"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "model": "gpt-4.1",
    "input": [{"role":"user","content":"Hello"},{"role":"assistant","content":"Hello! How can I help you today? 😊"},{"role":"user","content":"What did I just say?"}]
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)
```

من خلال تحميل عدة نصوص أسئلة، يمكن بسهولة تحقيق محادثات متعددة الجولات، ويمكن الحصول على الإجابة التالية:

```json theme={null}
{
  "id": "resp_68a989c03c508191a1dd82ce2e37e88a0932a4328c0a5d5b",
  "object": "response",
  "created_at": 1755941312,
  "status": "completed",
  "background": false,
  "content_filters": null,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "max_tool_calls": null,
  "model": "gpt-4.1",
  "output": [
    {
      "id": "msg_68a989c092e4819189821a9eb8247e1e0932a4328c0a5d5b",
      "type": "message",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "annotations": [],
          "text": "You just said \"Hello.\" \n\nWould you like to continue the conversation or ask a question?"
        }
      ],
      "role": "assistant"
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "prompt_cache_key": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "safety_identifier": null,
  "service_tier": "default",
  "store": true,
  "temperature": 1,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 32,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 20,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 52
  },
  "user": null,
  "metadata": {}
}
```

يمكن ملاحظة أن المعلومات التي يحتويها `output` متوافقة مع محتوى الاستخدام الأساسي، وهو يتضمن المحتوى المحدد لرد ChatGPT على محادثات متعددة، وبهذه الطريقة يمكن الإجابة عن الأسئلة المقابلة بناءً على محتويات المحادثات المتعددة.

## نموذج الرؤية

gpt-4o هو نموذج لغوي كبير متعدد الوسائط طوّرته OpenAI، ويضيف قدرة الفهم البصري على أساس GPT-4. يمكن لهذا النموذج معالجة مدخلات النصوص والصور في الوقت نفسه، ويحقق الفهم والتوليد عبر الوسائط المختلفة.
تتوافق معالجة النصوص باستخدام نموذج gpt-4o مع محتوى الاستخدام الأساسي المذكور أعلاه، وفيما يلي مقدمة موجزة حول كيفية استخدام قدرات معالجة الصور الخاصة بالنموذج.

تتمثل الطريقة الرئيسية لاستخدام قدرات معالجة الصور في نموذج gpt-4o بإضافة حقل `type` إلى محتوى `content` الأصلي، ومن خلال هذا الحقل يمكن معرفة ما إذا كان المرفوع نصًا أو صورة، وبالتالي استخدام قدرات معالجة الصور في نموذج gpt-4o. فيما يلي شرح رئيسي لاستخدام هذه الوظيفة عبر طريقتين: Curl وPython.

* طريقة سكربت Curl

```
curl -X POST 'https://api.acedata.cloud/openai/responses' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
    "model": "gpt-4.1",
    "input": [
      {
        "role": "user",
        "content": [
          {"type": "input_text", "text": "what is in this image?"},
          {
            "type": "input_image",
            "image_url": "https://cdn.acedata.cloud/e724d7f13d.png"
          }
        ]
      }
    ]
  }'
```

* طريقة سكربت Python

```python theme={null}
import requests

url = "https://api.acedata.cloud/openai/chat/completions"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "model": "gpt-4.1",
    "input": [
      {
        "role": "user",
        "content": [
          {"type": "input_text", "text": "what is in this image?"},
          {
            "type": "input_image",
            "image_url": "https://cdn.acedata.cloud/e724d7f13d.png"
          }
        ]
      }
    ]
  }

response = requests.post(url, json=payload, headers=headers)
print(response.text)
```

بعد ذلك يمكن الحصول على النتيجة التالية، ومعلومات الحقول في النتيجة متوافقة مع ما ورد أعلاه، والتفاصيل كما يلي:

```json theme={null}
{
  "id": "resp_68a98c1bb784819e9b9f622007a2d37602483949012d2193",
  "object": "response",
  "created_at": 1755941915,
  "status": "completed",
  "background": false,
  "content_filters": null,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "max_tool_calls": null,
  "model": "gpt-4.1",
  "output": [
    {
      "id": "msg_68a98c1dd030819e97fb71e6ee33f5a902483949012d2193",
      "type": "message",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "annotations": [],
          "text": "This image shows a scenic path, possibly a boardwalk, running through a lush green field or meadow. The sky above is bright blue with some white clouds, and there are green trees and bushes in the background. It looks like a peaceful nature scene, possibly in a park, wetland, or prairie area. The image conveys a sense of tranquility and natural beauty."
        }
      ],
      "role": "assistant"
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "prompt_cache_key": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "safety_identifier": null,
  "service_tier": "default",
  "store": true,
  "temperature": 1,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 1118,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 75,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 1193
  },
  "user": null,
  "metadata": {}
}
```

يمكن ملاحظة أن محتوى الإجابة يعتمد على الصورة، لذلك يمكن من خلال الطريقتين المذكورتين أعلاه استخدام قدرات معالجة النصوص والصور لنموذج gpt-4.1 بسهولة.

إلى جانب gpt-4.1، يوجد أيضًا نموذج أقل تكلفة يُسمى gpt-4o-mini. يُعد gpt-4o-mini أحدث جيل من نماذج اللغة الكبيرة التي طورتها OpenAI، فهو لا يتميز بسرعة الاستجابة فحسب، بل إن سعره أقل أيضًا، ويدعم كذلك تعدد الوسائط. يمكن الرجوع إلى محتوى استخدام نموذج gpt-4.1 أعلاه لاستخدام وظيفة vision.

## إنشاء نموذج معالجة الملفات

مثال للطلب:

```json theme={null}
{
  "model": "gpt-4.1",
  "input": [
    {
      "role": "user",
      "content": [
        { "type": "input_text", "text": "what is in this file?" },
        {
          "type": "input_file",
          "file_url": "https://cdn.acedata.cloud/assets/examples/fish/64adc04b-c196-4a0f-9070-222ba101ce6c-fc50de38c165.wav"
        }
      ]
    }
  ]
}
```

نتيجة المثال:

```json theme={null}
{
  "id": "resp_68a98d7bb57c819ba25424f5f50a29a300a1af2af822e88a",
  "object": "response",
  "created_at": 1755942267,
  "status": "completed",
  "background": false,
  "content_filters": null,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "max_tool_calls": null,
  "model": "gpt-4.1",
  "output": [
    {
      "id": "msg_68a98d7d9b80819b9b0f09b7bcd00bf900a1af2af822e88a",
      "type": "message",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "annotations": [],
          "text": "The file you posted contains the **2024 annual letter to shareholders from Berkshire Hathaway Inc.**, written by Warren E. Buffett, Chairman of the Board. This document is a comprehensive communication that is typically included in Berkshire's annual report to shareholders.\n\n### What's Inside the File:\n\n#### 1. **Chairman's Letter to Shareholders**\n   - **Introduction & Philosophy:** Warren Buffett discusses the purpose of the annual report, Berkshire Hathaway’s communication style, and his philosophy for transparency and candid discussion of both successes and failures.\n   - **Discussion of Mistakes:** He talks openly about the mistakes made in capital allocation and personnel decisions, emphasizing the importance of admitting errors and acting promptly to correct them.\n   - **Succession Comments:** Buffett references his eventual retirement, and that Greg Abel will succeed him as CEO and writer of these letters.\n   - **Anecdotal Story:** The story of Pete Liegl, founder of Forest River (an RV manufacturer acquired by Berkshire), is told to illustrate management philosophy and business decision-making.\n\n#### 2. **2024 Business and Financial Performance**\n   - **Key Results:** Summary of how Berkshire performed financially in 2024 vs. 2023, including operating earnings breakdown by business segments such as insurance, BNSF railroad, and energy.\n   - **Insurance Business:** GEICO and the property-casualty insurance division had a standout year, with commentary on the industry and how Berkshire approaches insurance risk, pricing, and investment of insurance \"float.\"\n   - **Investments:** Discussion on Berkshire’s strategy of owning both full businesses and partial stakes (marketable securities) in large companies (e.g., Apple, American Express, Coca-Cola), and its deployment of cash.\n   - **Taxes:** Reference to Berkshire breaking records in corporate tax payments ($26.8 billion to the IRS in 2024).\n\n#### 3. **Long-term Philosophy & Capitalism Commentary**\n   - **On Equities:** Buffett explains why Berkshire prioritizes ownership of businesses (equities) over cash or bonds, and why the company favors long-term investments.\n   - **On Capitalism:** There’s a reflection on America’s growth, the role of capitalism, savings, and capital allocation in the nation’s success, and a nod to the importance of maintaining a stable currency.\n\n#### 4. **Japanese Investments**\n   - **Update on Japanese Holdings:** Berkshire’s growing investments in five Japanese trading companies, and the positive view of their management and governance.\n\n#### 5. **Berkshire Hathaway Annual Meeting**\n   - **Annual Gathering Info:** Details about the annual meeting in Omaha, including social events, book sales, and charitable initiatives related to the meeting.\n   - **Personal Stories:** Personal anecdotes involving Buffett’s family, (including his sister Bertie), to add a human touch to the letter.\n\n#### 6. **Performance Tables**\n   - **Berkshire vs S&P 500 (1965-2024):** Two detailed tables showing annual percentage change in Berkshire’s share price vs. total return for the S&P 500, as well as long-term compounded and overall gains.\n\n---\n\n### In Summary\n\nThis file is the **2024 Berkshire Hathaway annual letter to shareholders**, primarily written by Warren Buffett. It covers business performance, management philosophy, investment strategy, earnings and taxes, insurance operations, significant holdings, capital allocation, succession updates, and more. Tables show a remarkable outperformance of Berkshire Hathaway vs. the S&P 500 over nearly six decades – a central point of pride in the letter.\n\nIf you want specifics from any particular section, let me know!"
        }
      ],
      "role": "assistant"
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "prompt_cache_key": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "safety_identifier": null,
  "service_tier": "default",
  "store": true,
  "temperature": 1,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 8438,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 731,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 9169
  },
  "user": null,
  "metadata": {}
}
```

كما يمكن ملاحظة، قمنا أيضًا بمعالجة الملف المُدخل، وكانت النتيجة مماثلة لما ورد أعلاه.

## معالجة الأخطاء

عند استدعاء API، إذا واجهت خطأً، فستُرجع API رمز الخطأ والمعلومات المقابلة. على سبيل المثال:

* `400 token_mismatched`：طلب غير صالح، ربما بسبب معلمات مفقودة أو غير صالحة.
* `400 api_not_implemented`：طلب غير صالح، ربما بسبب معلمات مفقودة أو غير صالحة.
* `401 invalid_token`：غير مصرح به، رمز التفويض غير صالح أو مفقود.
* `429 too_many_requests`：طلبات كثيرة جدًا، لقد تجاوزت حد المعدل.
* `500 api_error`：خطأ داخلي في الخادم، حدث خطأ ما على الخادم.

### مثال على استجابة خطأ

```
{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}
```

## الخلاصة

من خلال هذه الوثيقة، أصبحت تعرف كيفية استخدام OpenAI Responses API لتنفيذ وظيفة إنشاء Responses الخاصة بـ OpenAI الرسمية بسهولة. نأمل أن تساعدك هذه الوثيقة على الربط واستخدام API بشكل أفضل. إذا كانت لديك أي أسئلة، فيُرجى الاتصال بفريق الدعم الفني لدينا في أي وقت.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.