Repository: prism-php/prism (PHP)

Issue:
Assertions example in docs leads to a call to an undefined method
This test fails because `Call to undefined method Prism\Prism\Text\Request::provider()`. It passes otherwise.

```php
<?php

use Prism\Prism\Prism;
use Prism\Prism\Enums\Provider;
use Prism\Prism\ValueObjects\Usage;
use Prism\Prism\Testing\TextResponseFake;

it('can generate text', function () {
    $fakeResponse = TextResponseFake::make()
        ->withText('Hello, I am Claude!')
        ->withUsage(new Usage(10, 20));

    // Set up the fake
    $fake = Prism::fake([$fakeResponse]);

    // Run your code
    $response = Prism::text()
        ->using(Provider::Anthropic, 'claude-3-5-sonnet-latest')
        ->withPrompt('Who are you?')
        ->asText();

    // Make assertions
    expect($response->text)->toBe('Hello, I am Claude!');

    $fake->assertRequest(function ($requests) {
        expect($requests[0]->provider())->toBe('anthropic');
        expect($requests[0]->model())->toBe('claude-3-5-sonnet-latest');
    });
})
```



Fix (patch):
diff --git a/src/Embeddings/PendingRequest.php b/src/Embeddings/PendingRequest.php
index 3118c00b2..38716f4ac 100644
--- a/src/Embeddings/PendingRequest.php
+++ b/src/Embeddings/PendingRequest.php
@@ -80,6 +80,7 @@ protected function toRequest(): Request
     {
         return new Request(
             model: $this->model,
+            providerKey: $this->providerKey(),
             inputs: $this->inputs,
             clientOptions: $this->clientOptions,
             clientRetry: $this->clientRetry,
diff --git a/src/Embeddings/Request.php b/src/Embeddings/Request.php
index 780fe59e9..164fd318d 100644
--- a/src/Embeddings/Request.php
+++ b/src/Embeddings/Request.php
@@ -21,6 +21,7 @@ class Request implements PrismRequest
      */
     public function __construct(
         protected string $model,
+        protected string $providerKey,
         protected array $inputs,
         protected array $clientOptions,
         protected array $clientRetry,
@@ -58,4 +59,9 @@ public function model(): string
     {
         return $this->model;
     }
+
+    public function provider(): string
+    {
+        return $this->providerKey;
+    }
 }
diff --git a/src/Images/PendingRequest.php b/src/Images/PendingRequest.php
index bcae22e86..8581dca5c 100644
--- a/src/Images/PendingRequest.php
+++ b/src/Images/PendingRequest.php
@@ -42,6 +42,7 @@ public function toRequest(): Request
     {
         return new Request(
             model: $this->model,
+            providerKey: $this->providerKey(),
             prompt: $this->prompt,
             clientOptions: $this->clientOptions,
             clientRetry: $this->clientRetry,
diff --git a/src/Images/Request.php b/src/Images/Request.php
index 6677d7069..4b926252d 100644
--- a/src/Images/Request.php
+++ b/src/Images/Request.php
@@ -20,6 +20,7 @@ class Request implements PrismRequest
      */
     public function __construct(
         protected string $model,
+        protected string $providerKey,
         protected string $prompt,
         protected array $clientOptions,
         protected array $clientRetry,
@@ -54,4 +55,9 @@ public function model(): string
     {
         return $this->model;
     }
+
+    public function provider(): string
+    {
+        return $this->providerKey;
+    }
 }
diff --git a/src/Structured/PendingRequest.php b/src/Structured/PendingRequest.php
index 4f83f6abd..ed9c593df 100644
--- a/src/Structured/PendingRequest.php
+++ b/src/Structured/PendingRequest.php
@@ -64,6 +64,7 @@ public function toRequest(): Request
 
         return new Request(
             model: $this->model,
+            providerKey: $this->providerKey(),
             systemPrompts: $this->systemPrompts,
             prompt: $this->prompt,
             messages: $messages,
diff --git a/src/Structured/Request.php b/src/Structured/Request.php
index d230d1fd8..be8b55214 100644
--- a/src/Structured/Request.php
+++ b/src/Structured/Request.php
@@ -27,6 +27,7 @@ class Request implements PrismRequest
     public function __construct(
         protected array $systemPrompts,
         protected string $model,
+        protected string $providerKey,
         protected ?string $prompt,
         protected array $messages,
         protected ?int $maxTokens,
@@ -55,6 +56,11 @@ public function model(): string
         return $this->model;
     }
 
+    public function provider(): string
+    {
+        return $this->providerKey;
+    }
+
     public function prompt(): ?string
     {
         return $this->prompt;
diff --git a/src/Text/PendingRequest.php b/src/Text/PendingRequest.php
index 9034b0868..d08ac6b50 100644
--- a/src/Text/PendingRequest.php
+++ b/src/Text/PendingRequest.php
@@ -83,6 +83,7 @@ public function toRequest(): Request
 
         return new Request(
             model: $this->model,
+            providerKey: $this->providerKey(),
             systemPrompts: $this->systemPrompts,
             prompt: $this->prompt,
             messages: $messages,
diff --git a/src/Text/Request.php b/src/Text/Request.php
index 77c2cbd25..7b70c2de1 100644
--- a/src/Text/Request.php
+++ b/src/Text/Request.php
@@ -29,6 +29,7 @@ class Request implements PrismRequest
      */
     public function __construct(
         protected string $model,
+        protected string $providerKey,
         protected array $systemPrompts,
         protected ?string $prompt,
         protected array $messages,
@@ -130,6 +131,11 @@ public function model(): string
         return $this->model;
     }
 
+    public function provider(): string
+    {
+        return $this->providerKey;
+    }
+
     public function addMessage(Message $message): self
     {
         $this->messages = array_merge($this->messages, [$message]);