Skip to content

Commit 3d443f7

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
docs: fix incorrect additional properties info (#190)
1 parent adbf4b0 commit 3d443f7

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

README.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,7 @@ See [Pagination](#pagination) below for more information on transparently workin
147147

148148
To make a request to the OpenAI API, you generally build an instance of the appropriate `Params` class.
149149

150-
In [Example: creating a resource](#example-creating-a-resource) above, we used the `ChatCompletionCreateParams.builder()` to pass to the `create` method of the `completions` service.
151-
152-
Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using the `putAdditionalProperty` method.
153-
154-
```java
155-
import com.openai.core.JsonValue;
156-
import com.openai.models.ChatCompletionCreateParams;
157-
158-
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
159-
// ... normal properties
160-
.putAdditionalProperty("secret_param", JsonValue.from("4242"))
161-
.build();
162-
```
150+
See [Undocumented request params](#undocumented-request-params) for how to send arbitrary parameters.
163151

164152
## Responses
165153

@@ -356,18 +344,26 @@ This library is typed for convenient access to the documented API. If you need t
356344

357345
### Undocumented request params
358346

359-
To make requests using undocumented parameters, you can provide or override parameters on the params object while building it.
347+
In [Example: creating a resource](#example-creating-a-resource) above, we used the `ChatCompletionCreateParams.builder()` to pass to the `create` method of the `completions` service.
348+
349+
Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using raw setters:
360350

361351
```java
362-
FooCreateParams address = FooCreateParams.builder()
363-
.id("my_id")
364-
.putAdditionalProperty("secret_prop", JsonValue.from("hello"))
352+
import com.openai.core.JsonValue;
353+
import com.openai.models.ChatCompletionCreateParams;
354+
355+
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
356+
.putAdditionalHeader("Secret-Header", "42")
357+
.putAdditionalQueryParam("secret_query_param", "42")
358+
.putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))
365359
.build();
366360
```
367361

362+
You can also use the `putAdditionalProperty` method on nested headers, query params, or body objects.
363+
368364
### Undocumented response properties
369365

370-
To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map<String, JsonValue>`. You can then access fields like `._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type.
366+
To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map<String, JsonValue>`. You can then access fields like `res._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type.
371367

372368
## Logging
373369

0 commit comments

Comments
 (0)