Skip to content

Commit 0b52b12

Browse files
feat(api): make model required for the responses/compact endpoint
1 parent 5af1c38 commit 0b52b12

File tree

4 files changed

+30
-33
lines changed

4 files changed

+30
-33
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 136
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-fe8a79e6fd407e6c9afec60971f03076b65f711ccd6ea16457933b0e24fb1f6d.yml
3-
openapi_spec_hash: 38c0a73f4e08843732c5f8002a809104
4-
config_hash: 2c350086d87a4b4532077363087840e7
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-88d85ff87ad8983262af2b729762a6e05fd509468bb691529bc2f81e4ce27c69.yml
3+
openapi_spec_hash: 46a55acbccd0147534017b92c1f4dd99
4+
config_hash: 141b101c9f13b90e21af74e1686f1f41

MIGRATION.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ client.example.list(undefined, { headers: { ... } });
134134
- `client.beta.threads.messages.list()`
135135
- `client.batches.list()`
136136
- `client.responses.retrieve()`
137-
- `client.responses.compact()`
138137
- `client.responses.inputItems.list()`
139138
- `client.responses.inputTokens.count()`
140139
- `client.realtime.calls.reject()`

src/resources/responses/responses.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,12 @@ export class Responses extends APIResource {
213213
*
214214
* @example
215215
* ```ts
216-
* const compactedResponse = await client.responses.compact();
216+
* const compactedResponse = await client.responses.compact({
217+
* model: 'gpt-5.1',
218+
* });
217219
* ```
218220
*/
219-
compact(
220-
body: ResponseCompactParams | null | undefined = {},
221-
options?: RequestOptions,
222-
): APIPromise<CompactedResponse> {
221+
compact(body: ResponseCompactParams, options?: RequestOptions): APIPromise<CompactedResponse> {
223222
return this._client.post('/responses/compact', { body, ...options });
224223
}
225224
}
@@ -6487,27 +6486,14 @@ export interface ResponseRetrieveParamsStreaming extends ResponseRetrieveParamsB
64876486
}
64886487

64896488
export interface ResponseCompactParams {
6490-
/**
6491-
* Text, image, or file inputs to the model, used to generate a response
6492-
*/
6493-
input?: string | Array<ResponseInputItem> | null;
6494-
6495-
/**
6496-
* A system (or developer) message inserted into the model's context. When used
6497-
* along with `previous_response_id`, the instructions from a previous response
6498-
* will not be carried over to the next response. This makes it simple to swap out
6499-
* system (or developer) messages in new responses.
6500-
*/
6501-
instructions?: string | null;
6502-
65036489
/**
65046490
* Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a
65056491
* wide range of models with different capabilities, performance characteristics,
65066492
* and price points. Refer to the
65076493
* [model guide](https://platform.openai.com/docs/models) to browse and compare
65086494
* available models.
65096495
*/
6510-
model?:
6496+
model:
65116497
| 'gpt-5.1'
65126498
| 'gpt-5.1-2025-11-13'
65136499
| 'gpt-5.1-codex'
@@ -6592,6 +6578,19 @@ export interface ResponseCompactParams {
65926578
| (string & {})
65936579
| null;
65946580

6581+
/**
6582+
* Text, image, or file inputs to the model, used to generate a response
6583+
*/
6584+
input?: string | Array<ResponseInputItem> | null;
6585+
6586+
/**
6587+
* A system (or developer) message inserted into the model's context. When used
6588+
* along with `previous_response_id`, the instructions from a previous response
6589+
* will not be carried over to the next response. This makes it simple to swap out
6590+
* system (or developer) messages in new responses.
6591+
*/
6592+
instructions?: string | null;
6593+
65956594
/**
65966595
* The unique ID of the previous response to the model. Use this to create
65976596
* multi-turn conversations. Learn more about

tests/api-resources/responses/responses.test.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ describe('resource responses', () => {
7474
expect(dataAndResponse.response).toBe(rawResponse);
7575
});
7676

77-
test('compact', async () => {
78-
const responsePromise = client.responses.compact();
77+
test('compact: only required params', async () => {
78+
const responsePromise = client.responses.compact({ model: 'gpt-5.1' });
7979
const rawResponse = await responsePromise.asResponse();
8080
expect(rawResponse).toBeInstanceOf(Response);
8181
const response = await responsePromise;
@@ -85,13 +85,12 @@ describe('resource responses', () => {
8585
expect(dataAndResponse.response).toBe(rawResponse);
8686
});
8787

88-
test('compact: request options and params are passed correctly', async () => {
89-
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
90-
await expect(
91-
client.responses.compact(
92-
{ input: 'string', instructions: 'instructions', model: 'gpt-5.1', previous_response_id: 'resp_123' },
93-
{ path: '/_stainless_unknown_path' },
94-
),
95-
).rejects.toThrow(OpenAI.NotFoundError);
88+
test('compact: required and optional params', async () => {
89+
const response = await client.responses.compact({
90+
model: 'gpt-5.1',
91+
input: 'string',
92+
instructions: 'instructions',
93+
previous_response_id: 'resp_123',
94+
});
9695
});
9796
});

0 commit comments

Comments
 (0)