Skip to content

Commit

Permalink
docs(readme): mention failed requests in request IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie committed Jan 22, 2025
1 parent 89a9dd8 commit 5f7c30b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,21 @@ Note that unlike other properties that use an `_` prefix, the `_request_id` prop
*is* public. Unless documented otherwise, *all* other `_` prefix properties,
methods and modules are *private*.

> [!IMPORTANT]
> If you need to access request IDs for failed requests you must catch the `APIStatusError` exception
```python
import openai

try:
completion = await client.chat.completions.create(
messages=[{"role": "user", "content": "Say this is a test"}], model="gpt-4"
)
except openai.APIStatusError as exc:
print(exc.request_id) # req_123
raise exc
```


### Retries

Expand Down

0 comments on commit 5f7c30b

Please sign in to comment.