Skip to content

Commit 0f80ab0

Browse files
docs: revise readme docs about nested params (#900)
1 parent b8da2f7 commit 0f80ab0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,24 @@ for batch in first_page.data:
375375
# Remove `await` for non-async usage.
376376
```
377377

378+
## Nested params
379+
380+
Nested parameters are dictionaries, typed using `TypedDict`, for example:
381+
382+
```python
383+
from anthropic import Anthropic
384+
385+
client = Anthropic()
386+
387+
completion = client.completions.create(
388+
max_tokens_to_sample=256,
389+
model="claude-3-7-sonnet-latest",
390+
prompt="\n\nHuman: Hello, world!\n\nAssistant:",
391+
metadata={"user_id": "13803d75-b4b5-4c3e-b2a2-6f21399b021b"},
392+
)
393+
print(completion.metadata)
394+
```
395+
378396
## Handling errors
379397

380398
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `anthropic.APIConnectionError` is raised.

0 commit comments

Comments
 (0)