Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/providers/openai.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/Providers/OpenAI/Handlers/Structured.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
Expand Down
1 change: 1 addition & 0 deletions src/Providers/OpenAI/Handlers/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ protected function sendRequest(Request $request): ClientResponse
] : null,
'truncation' => $request->providerOptions('truncation'),
'reasoning' => $request->providerOptions('reasoning'),
'store' => $request->providerOptions('store'),
]))
);
}
Expand Down
35 changes: 35 additions & 0 deletions tests/Providers/OpenAI/StructuredTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
25 changes: 25 additions & 0 deletions tests/Providers/OpenAI/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});
Loading