Skip to content

Commit 73869ee

Browse files
committed
docs(readme): document how to make undocumented requests (#1256)
1 parent 2b23eb5 commit 73869ee

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,41 @@ with client.chat.completions.with_streaming_response.create(
487487

488488
The context manager is required so that the response will reliably be closed.
489489

490+
### Making custom/undocumented requests
491+
492+
This library is typed for convenient access the documented API.
493+
494+
If you need to access undocumented endpoints, params, or response properties, the library can still be used.
495+
496+
#### Undocumented endpoints
497+
498+
To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
499+
http verbs. Options on the client will be respected (such as retries) will be respected when making this
500+
request.
501+
502+
```py
503+
import httpx
504+
505+
response = client.post(
506+
"/foo",
507+
cast_to=httpx.Response,
508+
body={"my_param": True},
509+
)
510+
511+
print(response.headers.get("x-foo"))
512+
```
513+
514+
#### Undocumented params
515+
516+
If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request
517+
options.
518+
519+
#### Undocumented properties
520+
521+
To access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You
522+
can also get all the extra fields on the Pydantic model as a dict with
523+
[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).
524+
490525
### Configuring the HTTP client
491526

492527
You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:

0 commit comments

Comments
 (0)