OpenAI Responses
أرسل طلباً عبر عملية Responses المتوافقة مع OpenAI في RunAPI.
نظرة عامة
استخدم عملية Responses المتوافقة مع OpenAI في RunAPI مع نموذج متوافق وأشكال الطلب والاستجابة الخاصة بالبروتوكول.
البدء السريع
- أنشئ مفتاح API واضبطه كـ RUNAPI_API_KEY.
- اختر نموذجاً متوافقاً، ثم أرسل معاملات المسار الموثَّقة وجسم JSON.
- اقرأ استجابة JSON أو أحداث الخادم المُرسَلة المعروضة لهذه العملية، وتعامل مع أخطاء البروتوكول.
نقطة النهاية
- عنوان URL الأساسي
https://runapi.ai- إصدار العقد
v1- المصادقة المفضّلة
Authorization: Bearer YOUR_API_TOKEN
وسائل حمل المصادقة
يقبل RunAPI كل بروتوكول مُدرج أدناه. تستخدم العينات المُولَّدة الترويسة المفضَّلة للبروتوكول.
- header - مفضّل
Authorization: Bearer YOUR_API_TOKEN- header
x-api-key: YOUR_API_TOKEN- header
x-goog-api-key: YOUR_API_TOKEN- query
?key=YOUR_API_TOKEN
النماذج المتوافقة
افتح صفحة النموذج للاطلاع على التسعير الحالي وحدود المعدل وتفاصيل الاستخدام التجاري.
عرض 58 نموذجاً متوافقاً
- claude-fable-5-1
- claude-fable-5
- claude-sonnet-5
- claude-opus-5
- claude-opus-4-8
- claude-opus-4-7
- claude-opus-4-6
- claude-sonnet-4-6
- claude-opus-4-5-20251101
- claude-sonnet-4-5-20250929
- claude-haiku-4-5-20251001
- claude-opus-4-1-20250805
- gpt-5.5
- gpt-5.5-pro
- gpt-5.4
- gpt-5.4-mini
- gpt-5.4-nano
- gpt-5.4-pro
- gpt-5.3-codex
- gpt-5.3-codex-spark
- gpt-5.6-luna
- gpt-5.6-sol
- gpt-5.6-terra
- gpt-6-astra
- gemini-3.6-flash
- gemini-3.5-flash
- gemini-3.1-pro-preview
- gemini-3-flash-preview
- gemini-2.5-pro
- gemini-2.5-flash
- deepseek-v4-flash-vision-exp
- deepseek-v4-pro
- deepseek-v4-flash
- glm-5.2
- glm-5.1
- glm-5-turbo
- glm-5
- glm-4.7
- glm-4.6
- glm-4.5
- glm-4.5-air
- kimi-k3
- kimi-k2.7-code
- kimi-k2.6
- kimi-k2.5
- MiniMax-M3
- MiniMax-M2.7
- MiniMax-M2.7-highspeed
- MiniMax-M2.5
- MiniMax-M2.5-highspeed
- MiniMax-M2.1
- MiniMax-M2
- mimo-v2.5-pro
- mimo-v2.5
- grok-4.20-0309-non-reasoning
- grok-4.6
- grok-4.5
- grok-4.3
عقد الطلب
تُدرج فقط الحقول التي تتوفر لها أدلة دعم من بروتوكول عام ومن RunAPI. تُمرَّر حقول نص JSON الإضافية كما هي.
جسم JSON13 حقل
input["string", "array"]النص أو عناصر الرسائل أو نتائج الأدوات المقدَّمة إلى النموذج.
instructions["string", "null"]تعليمات النظام أو المطوّر لهذه الاستجابة.
max_output_tokens["integer", "null"]الحد الأقصى لرموز المخرجات، شاملاً الرموز المرئية ورموز التفكير.
modelstringمعرّف نموذج RunAPI الذي يُرجعه كتالوج النماذج المتوافق.
moderation["object", "null"]إرجاع إشارات الإشراف المستقلة للمدخلات الحالية والمخرجات الكاملة.
moderation.modelstringomni-moderation-latest
moderation.policy["object", "null"]moderation.policy.input["object", "null"]moderation.policy.input.modestringscore, block
moderation.policy.output["object", "null"]moderation.policy.output.modestringscore, block
stream["boolean", "null"]إرجاع أحداث Responses المكتوبة كأحداث مُرسَلة من الخادم.
القيمة الافتراضية:false
toolsarrayالأدوات التي يمكن للنموذج استدعاؤها.
مثال على الطلب
{
"input": "Summarize one practical improvement for an API deployment.",
"model": "gpt-5.4",
"moderation": {
"model": "omni-moderation-latest",
"policy": {
"input": {
"mode": "score"
},
"output": {
"mode": "block"
}
}
}
}
استجابة متزامنة
المخطط
{
"additionalProperties": true,
"properties": {
"id": {
"type": "string"
},
"model": {
"type": "string"
},
"moderation": {
"additionalProperties": true,
"properties": {
"input": {
"oneOf": [
{
"additionalProperties": true,
"properties": {
"categories": {
"additionalProperties": true,
"type": "object"
},
"category_applied_input_types": {
"additionalProperties": true,
"type": "object"
},
"category_scores": {
"additionalProperties": true,
"type": "object"
},
"flagged": {
"type": "boolean"
},
"model": {
"const": "omni-moderation-latest",
"type": "string"
},
"type": {
"const": "moderation_result",
"type": "string"
}
},
"required": [
"type",
"model",
"flagged",
"categories",
"category_scores",
"category_applied_input_types"
],
"type": "object"
},
{
"additionalProperties": true,
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"type": {
"const": "error",
"type": "string"
}
},
"required": [
"type",
"code",
"message"
],
"type": "object"
}
]
},
"output": {
"oneOf": [
{
"additionalProperties": true,
"properties": {
"categories": {
"additionalProperties": true,
"type": "object"
},
"category_applied_input_types": {
"additionalProperties": true,
"type": "object"
},
"category_scores": {
"additionalProperties": true,
"type": "object"
},
"flagged": {
"type": "boolean"
},
"model": {
"const": "omni-moderation-latest",
"type": "string"
},
"type": {
"const": "moderation_result",
"type": "string"
}
},
"required": [
"type",
"model",
"flagged",
"categories",
"category_scores",
"category_applied_input_types"
],
"type": "object"
},
{
"additionalProperties": true,
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"type": {
"const": "error",
"type": "string"
}
},
"required": [
"type",
"code",
"message"
],
"type": "object"
}
]
}
},
"required": [
"input",
"output"
],
"type": "object"
},
"object": {
"const": "response",
"type": "string"
},
"output": {
"type": "array"
},
"status": {
"type": "string"
},
"usage": {
"additionalProperties": true,
"properties": {
"input_tokens": {
"type": "integer"
},
"output_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"input_tokens",
"output_tokens",
"total_tokens"
],
"type": "object"
}
},
"required": [
"id",
"object",
"status",
"model",
"output"
],
"type": "object"
}
مثال
{
"id": "resp_example",
"model": "gpt-5.4",
"moderation": {
"input": {
"categories": {
"sexual": false,
"violence": true
},
"category_applied_input_types": {
"sexual": [
"text"
],
"violence": [
"text"
]
},
"category_scores": {
"sexual": 0.0002,
"violence": 0.96
},
"flagged": true,
"model": "omni-moderation-latest",
"type": "moderation_result"
},
"output": {
"categories": {
"sexual": false,
"violence": false
},
"category_applied_input_types": {
"sexual": [
"text"
],
"violence": [
"text"
]
},
"category_scores": {
"sexual": 0.0002,
"violence": 0.0001
},
"flagged": false,
"model": "omni-moderation-latest",
"type": "moderation_result"
}
},
"object": "response",
"output": [
{
"content": [
{
"annotations": [],
"text": "Hello! How can I help today?",
"type": "output_text"
}
],
"id": "msg_example",
"role": "assistant",
"status": "completed",
"type": "message"
}
],
"status": "completed",
"usage": {
"input_tokens": 12,
"output_tokens": 8,
"total_tokens": 20
}
}
حدث SSE: output_text_delta
المخطط
{
"additionalProperties": true,
"properties": {
"content_index": {
"type": "integer"
},
"delta": {
"type": "string"
},
"item_id": {
"type": "string"
},
"output_index": {
"type": "integer"
},
"type": {
"const": "response.output_text.delta",
"type": "string"
}
},
"required": [
"type",
"item_id",
"output_index",
"content_index",
"delta"
],
"type": "object"
}
مثال
{
"content_index": 0,
"delta": "Hello",
"item_id": "msg_example",
"output_index": 0,
"type": "response.output_text.delta"
}
حدث SSE: completed
المخطط
{
"additionalProperties": true,
"properties": {
"response": {
"additionalProperties": true,
"properties": {
"id": {
"type": "string"
},
"model": {
"type": "string"
},
"moderation": {
"additionalProperties": true,
"properties": {
"input": {
"oneOf": [
{
"additionalProperties": true,
"properties": {
"categories": {
"additionalProperties": true,
"type": "object"
},
"category_applied_input_types": {
"additionalProperties": true,
"type": "object"
},
"category_scores": {
"additionalProperties": true,
"type": "object"
},
"flagged": {
"type": "boolean"
},
"model": {
"const": "omni-moderation-latest",
"type": "string"
},
"type": {
"const": "moderation_result",
"type": "string"
}
},
"required": [
"type",
"model",
"flagged",
"categories",
"category_scores",
"category_applied_input_types"
],
"type": "object"
},
{
"additionalProperties": true,
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"type": {
"const": "error",
"type": "string"
}
},
"required": [
"type",
"code",
"message"
],
"type": "object"
}
]
},
"output": {
"oneOf": [
{
"additionalProperties": true,
"properties": {
"categories": {
"additionalProperties": true,
"type": "object"
},
"category_applied_input_types": {
"additionalProperties": true,
"type": "object"
},
"category_scores": {
"additionalProperties": true,
"type": "object"
},
"flagged": {
"type": "boolean"
},
"model": {
"const": "omni-moderation-latest",
"type": "string"
},
"type": {
"const": "moderation_result",
"type": "string"
}
},
"required": [
"type",
"model",
"flagged",
"categories",
"category_scores",
"category_applied_input_types"
],
"type": "object"
},
{
"additionalProperties": true,
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"type": {
"const": "error",
"type": "string"
}
},
"required": [
"type",
"code",
"message"
],
"type": "object"
}
]
}
},
"required": [
"input",
"output"
],
"type": "object"
},
"object": {
"const": "response",
"type": "string"
},
"output": {
"type": "array"
},
"status": {
"type": "string"
},
"usage": {
"additionalProperties": true,
"properties": {
"input_tokens": {
"type": "integer"
},
"output_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"input_tokens",
"output_tokens",
"total_tokens"
],
"type": "object"
}
},
"required": [
"id",
"object",
"status",
"model",
"output",
"usage"
],
"type": "object"
},
"type": {
"const": "response.completed",
"type": "string"
}
},
"required": [
"type",
"response"
],
"type": "object"
}
مثال
{
"response": {
"id": "resp_example",
"model": "gpt-5.4",
"moderation": {
"input": {
"categories": {
"sexual": false,
"violence": true
},
"category_applied_input_types": {
"sexual": [
"text"
],
"violence": [
"text"
]
},
"category_scores": {
"sexual": 0.0002,
"violence": 0.96
},
"flagged": true,
"model": "omni-moderation-latest",
"type": "moderation_result"
},
"output": {
"categories": {
"sexual": false,
"violence": false
},
"category_applied_input_types": {
"sexual": [
"text"
],
"violence": [
"text"
]
},
"category_scores": {
"sexual": 0.0002,
"violence": 0.0001
},
"flagged": false,
"model": "omni-moderation-latest",
"type": "moderation_result"
}
},
"object": "response",
"output": [
{
"content": [
{
"annotations": [],
"text": "Hello! How can I help today?",
"type": "output_text"
}
],
"id": "msg_example",
"role": "assistant",
"status": "completed",
"type": "message"
}
],
"status": "completed",
"usage": {
"input_tokens": 12,
"output_tokens": 8,
"total_tokens": 20
}
},
"type": "response.completed"
}
خطأ في البروتوكول: invalid_request
المخطط
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
مثال
{
"error": {
"code": null,
"message": "input must be a string or an array",
"param": "input",
"type": "invalid_request_error"
}
}
الاستخدام
المخطط
{
"additionalProperties": true,
"properties": {
"input_tokens": {
"type": "integer"
},
"output_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"input_tokens",
"output_tokens",
"total_tokens"
],
"type": "object"
}
مثال
{
"input_tokens": 12,
"output_tokens": 8,
"total_tokens": 20
}
نماذج الأكواد المولَّدة
كل نموذج من نماذج cURL وJavaScript وPython يُرسل الطلب المُتحقق منه من هذا العقد دون الحاجة إلى SDK خاص بالبروتوكول.
التثبيت
pip install requests
import requests
response = requests.post(
"https://runapi.ai/v1/responses",
headers={"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"},
json={"model": "gpt-5.4", "input": "Summarize one practical improvement for an API deployment.", "moderation": {"model": "omni-moderation-latest", "policy": {"input": {"mode": "score"}, "output": {"mode": "block"}}}}
)
response.raise_for_status()
print(response.json())