GPT-5 Codex API Integration
GPT-5 Codex کو Rivya Public API v1 کے ذریعے model id gpt-5-codex-chat، supported inputs، parameters، Files API rules، credits اور response examples کے ساتھ استعمال کریں۔
gpt-5-codex-chat
text, file
Minimal request کے لیے required نہیں
3
چیٹ
Chat API: non-streaming + SSE streaming
TOKEN_BASED
20000 characters
Request contract
Chat requests ایک وقت میں ایک message بھیجتی ہیں۔ Session history Rivya store کرتا ہے؛ raw messages array نہ بھیجیں۔
| Key | Type | Required | Default | Description |
|---|---|---|---|---|
| model | string | Yes | gpt-5-codex-chat | gpt-5-codex-chat API model id استعمال کریں۔ |
| session_id | string | No | - | اختیاری API-created chat session id۔ نئی session شروع کرنے کے لیے اسے omit کریں۔ |
| message | string | Yes | - | اگلا user message۔ Chat API history server-side session سے آتی ہے، raw messages array سے نہیں۔ |
| attachments | array | No | - | Files API سے واپس آنے والی optional image file_id values۔ External attachment URLs قبول نہیں کی جاتیں۔ |
| enable_web_search | boolean | No | false | صرف اس وقت apply ہوتا ہے جب selected chat model web search support کرتا ہو۔ |
| reasoning_effort | string | No | default | اختیاری reasoning effort: supported ہونے پر default، minimal، low، medium، high یا xhigh۔ |
| client_request_id | string | No | - | آپ کے system میں requests trace کرنے کے لیے optional client-side id۔ |
Model parameters
یہ chat model اوپر والے shared Chat API fields استعمال کرتا ہے۔ Web search، image file attachments، thoughts اور reasoning کے لیے model-specific support readiness data میں reflected ہے۔
Minimal request
{
"model": "gpt-5-codex-chat",
"message": "Write a concise launch plan for a new product image campaign"
}Reference-file request
{
"model": "gpt-5-codex-chat",
"message": "Write a concise launch plan for a new product image campaign",
"attachments": [
{
"file_id": "file_uploaded_image_id"
}
]
}Create response
Chat endpoint completed assistant message، token usage اور اس turn کی final credit settlement واپس کرتا ہے۔
{
"id": "chatcmpl_msg_gpt_5_codex_chat_example",
"object": "chat.completion",
"session_id": "chat_session_gpt_5_codex_chat",
"model": "gpt-5-codex-chat",
"created_at": "2026-05-11T00:00:00.000Z",
"message": {
"id": "assistant_message_id",
"role": "assistant",
"content": "A concise launch plan with clear next steps."
},
"usage": {
"input_tokens": 1200,
"output_tokens": 320,
"total_tokens": 1520
},
"credits": {
"reserved": 3,
"final": 3
}
}Common errors
validation_failed, insufficient_credits, idempotency_conflict, rate_limited, not_found, chat_model_not_supported, chat_session_conflict, chat_attachment_not_supported
Public API v1 میں Chat API non-streaming اور SSE streaming turns support کرتی ہے۔ Image attachments کو Files API کی file_id values استعمال کرنی ہوں گی۔