diff --git a/docs/providers/openai.md b/docs/providers/openai.md index e431473cf..e4188bae7 100644 --- a/docs/providers/openai.md +++ b/docs/providers/openai.md @@ -200,6 +200,18 @@ $response = Prism::text() ->asText(); ``` +#### Store + +```php +$response = Prism::text() + ->using('openai', 'gpt-5') + ->withPrompt('Give me a summary of the following legal document') + ->withProviderOptions([ // [!code focus] + 'store' => false // true, false // [!code focus] + ]) // [!code focus] + ->asText(); +``` + ## Streaming OpenAI supports streaming responses in real-time. All the standard streaming methods work with OpenAI models: diff --git a/src/Providers/OpenAI/Handlers/Structured.php b/src/Providers/OpenAI/Handlers/Structured.php index 7417aae43..d7ac0f893 100644 --- a/src/Providers/OpenAI/Handlers/Structured.php +++ b/src/Providers/OpenAI/Handlers/Structured.php @@ -204,6 +204,7 @@ protected function sendRequest(Request $request, array $responseFormat): ClientR 'service_tier' => $request->providerOptions('service_tier'), 'truncation' => $request->providerOptions('truncation'), 'reasoning' => $request->providerOptions('reasoning'), + 'store' => $request->providerOptions('store'), 'text' => [ 'format' => $responseFormat, ], diff --git a/src/Providers/OpenAI/Handlers/Text.php b/src/Providers/OpenAI/Handlers/Text.php index 643332676..c8a9a46fe 100644 --- a/src/Providers/OpenAI/Handlers/Text.php +++ b/src/Providers/OpenAI/Handlers/Text.php @@ -144,6 +144,7 @@ protected function sendRequest(Request $request): ClientResponse ] : null, 'truncation' => $request->providerOptions('truncation'), 'reasoning' => $request->providerOptions('reasoning'), + 'store' => $request->providerOptions('store'), ])) ); } diff --git a/tests/Providers/OpenAI/StructuredTest.php b/tests/Providers/OpenAI/StructuredTest.php index 26f7dcef1..11e5f7303 100644 --- a/tests/Providers/OpenAI/StructuredTest.php +++ b/tests/Providers/OpenAI/StructuredTest.php @@ -580,3 +580,38 @@ expect($response->structured)->toBeArray(); expect($response->structured)->toHaveKeys(['name', 'flexible_value']); }); + +it('passes store parameter when specified', function (): void { + FixtureResponse::fakeResponseSequence( + 'v1/responses', + 'openai/structured-structured-mode' + ); + + $schema = new ObjectSchema( + 'output', + 'the output object', + [ + new StringSchema('query', 'Search internal documents'), + ], + ['query'] + ); + + $store = false; + + Prism::structured() + ->using(Provider::OpenAI, 'gpt-4o') + ->withSchema($schema) + ->withPrompt('What was the revenue in Q3?') + ->withProviderOptions([ + 'store' => $store, + ]) + ->asStructured(); + + Http::assertSent(function (Request $request) use ($store): true { + $body = json_decode($request->body(), true); + + expect(data_get($body, 'store'))->toBe($store); + + return true; + }); +}); diff --git a/tests/Providers/OpenAI/TextTest.php b/tests/Providers/OpenAI/TextTest.php index 9024b35ce..e9e7a6ac5 100644 --- a/tests/Providers/OpenAI/TextTest.php +++ b/tests/Providers/OpenAI/TextTest.php @@ -741,3 +741,28 @@ expect($responseTwo->text)->toContain('Metcheck'); }); }); + +it('passes store parameter when specified', function (): void { + FixtureResponse::fakeResponseSequence( + 'v1/responses', + 'openai/generate-text-with-a-prompt' + ); + + $store = false; + + Prism::text() + ->using(Provider::OpenAI, 'gpt-4o') + ->withPrompt('Give me TLDR of this legal document') + ->withProviderOptions([ + 'store' => $store, + ]) + ->asText(); + + Http::assertSent(function (Request $request) use ($store): true { + $body = json_decode($request->body(), true); + + expect(data_get($body, 'store'))->toBe($store); + + return true; + }); +});