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

# الاستجابات

> استدعِ Responses API باستخدام SDK الخاص بـ Python.

**الطريقة**: `client.generate_response()` (يمكنك بث الأجزاء المُحللة باستخدام `client.stream_responses()`).

### مثال

```python theme={null}
resp = client.generate_response({
    "model": "openai/gpt-4.1",
    "input": [{"role": "user", "content": [{"type": "input_text", "text": "Summarise this"}]}],
    "temperature": 0.7,
})
```

### البث

```python theme={null}
for chunk in client.stream_responses({
    "model": "openai/gpt-4.1",
    "input": [{"role": "user", "content": [{"type": "input_text", "text": "Stream this"}]}],
    "stream": True,
}):
    if chunk.get("text"):
        print(chunk["text"], end="", flush=True)
```

### المعلمات الأساسية

* `model` (مطلوب): معرّف النموذج المستهدف.
* `input` (مطلوب): مصفوفة مرتبة من عناصر الإدخال (رسائل واستدعاءات أدوات وغيرها).
* `temperature` (0–2): كلما ارتفعت القيمة زادت عشوائية النتيجة.
* `top_p` (0–1) و`top_k` (>=1): عناصر تحكم أخذ العينات بالنواة وأفضل k خيارات.
* `max_output_tokens` (عدد صحيح): الحد الأقصى للرموز المُنشأة في كل استجابة.
* الأدوات: `tools` (تعريفات)، و`tool_choice` (auto/none/محدد)، و`max_tool_calls` (عدد صحيح)، و`parallel_tool_calls` (قيمة منطقية).
* Logprobs: `logprobs` (قيمة منطقية)، و`top_logprobs` (0–20) لإرجاع logprobs لكل رمز.
* الإخراج: `response_format` (json/text)، و`service_tier`، و`store` (قيمة منطقية)، و`stream` (قيمة منطقية).
* البيانات الوصفية: `metadata` (كائن يُمرر كما هو)، و`reasoning` (كائن لتلميحات مستوى الجهد).
* إضافات البوابة: `usage` (قيمة منطقية لطلب الاستخدام)، و`meta` (قيمة منطقية لتضمين كتلة meta).

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

`ResponsesResponse`

```json theme={null}
{
  "id": "resp_123",
  "object": "response",
  "created_at": 1677652288,
  "status": "completed",
  "model": "gpt-4.1",
  "output": [
    {
      "type": "message",
      "id": "msg_123",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Hello there, how may I assist you today?"
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 9,
    "output_tokens": 12,
    "total_tokens": 21
  }
}
```

أو إطارات SSE مفصولة بأسطر جديدة عند `stream: true`:

```
data: {"id":"resp_123","object":"response","created_at":1677652288,"status":"in_progress","model":"gpt-4.1","output":[{"type":"message","id":"msg_123","status":"in_progress","role":"assistant","content":[]}]}

data: {"id":"resp_123","object":"response","created_at":1677652288,"status":"in_progress","model":"gpt-4.1","output":[{"type":"message","id":"msg_123","status":"in_progress","role":"assistant","content":[{"type":"output_text","text":"Hello"}]}]}

data: {"id":"resp_123","object":"response","created_at":1677652288,"status":"completed","model":"gpt-4.1","output":[{"type":"message","id":"msg_123","status":"completed","role":"assistant","content":[{"type":"output_text","text":"Hello there, how may I assist you today?"}]}],"usage":{"input_tokens":9,"output_tokens":12,"total_tokens":21}}

data: [DONE]
```


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