Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5f7c30b

Browse files
committedJan 22, 2025·
docs(readme): mention failed requests in request IDs
1 parent 89a9dd8 commit 5f7c30b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎README.md

+15
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,21 @@ Note that unlike other properties that use an `_` prefix, the `_request_id` prop
499499
*is* public. Unless documented otherwise, *all* other `_` prefix properties,
500500
methods and modules are *private*.
501501

502+
> [!IMPORTANT]
503+
> If you need to access request IDs for failed requests you must catch the `APIStatusError` exception
504+
505+
```python
506+
import openai
507+
508+
try:
509+
completion = await client.chat.completions.create(
510+
messages=[{"role": "user", "content": "Say this is a test"}], model="gpt-4"
511+
)
512+
except openai.APIStatusError as exc:
513+
print(exc.request_id) # req_123
514+
raise exc
515+
```
516+
502517

503518
### Retries
504519

0 commit comments

Comments
 (0)
Please sign in to comment.