From 402fd71c0758908208a537b4f5884a90e94a65a5 Mon Sep 17 00:00:00 2001 From: Eric Junker Date: Tue, 17 Feb 2026 15:12:08 -0600 Subject: [PATCH] fix: URL encode model names to support inference profiles AWS Bedrock inference profiles contain special characters (colons and slashes) in their ARNs that must be URL encoded when used in the API endpoint path. Example inference profile: arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123def456 This change adds rawurlencode() to the model name before constructing the base URL, ensuring inference profiles work correctly. --- src/Bedrock.php | 2 +- tests/BedrockTest.php | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/BedrockTest.php diff --git a/src/Bedrock.php b/src/Bedrock.php index 198ba77..631fedd 100644 --- a/src/Bedrock.php +++ b/src/Bedrock.php @@ -115,7 +115,7 @@ public function apiVersion(PrismRequest $request): ?string */ protected function client(TextRequest|StructuredRequest|EmbeddingRequest $request, array $options = [], array $retry = []): PendingRequest { - $model = $request->model(); + $model = rawurlencode($request->model()); $enableCaching = $request instanceof EmbeddingRequest ? false diff --git a/tests/BedrockTest.php b/tests/BedrockTest.php new file mode 100644 index 0000000..d78a8c3 --- /dev/null +++ b/tests/BedrockTest.php @@ -0,0 +1,25 @@ +using('bedrock', $inferenceProfile) + ->withPrompt('Hello') + ->asText(); + + Http::assertSent(function (Request $request) use ($inferenceProfile): bool { + // The URL should contain encoded colons (%3A) and slashes (%2F) + return str_contains($request->url(), '%3A') + && str_contains($request->url(), '%2F') + && str_contains($request->url(), rawurlencode($inferenceProfile)); + }); +});