Skip to content

Commit

Permalink
docs(readme): document how to make undocumented requests (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Mar 21, 2024
1 parent 0b9aa6d commit d0f8069
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,41 @@ with client.messages.with_streaming_response.create(

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

### Making custom/undocumented requests

This library is typed for convenient access the documented API.

If you need to access undocumented endpoints, params, or response properties, the library can still be used.

#### Undocumented endpoints

To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
http verbs. Options on the client will be respected (such as retries) will be respected when making this
request.

```py
import httpx

response = client.post(
"/foo",
cast_to=httpx.Response,
body={"my_param": True},
)

print(response.headers.get("x-foo"))
```

#### Undocumented params

If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` request
options.

#### Undocumented properties

To access undocumented response properties, you can access the extra fields like `response.unknown_prop`. You
can also get all the extra fields on the Pydantic model as a dict with
[`response.model_extra`](https://docs.pydantic.dev/latest/api/base_model/#pydantic.BaseModel.model_extra).

### Configuring the HTTP client

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

0 comments on commit d0f8069

Please sign in to comment.