Skip to content

Commit 82b33bf

Browse files
committed
Allow beta feature flags to be passed into Anthropic API calls
1 parent 8cb4528 commit 82b33bf

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/platform/src/Bridge/Anthropic/ModelClient.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,24 @@ public function supports(Model $model): bool
3737
return $model instanceof Claude;
3838
}
3939

40-
public function request(Model $model, array|string $payload, array $options = []): RawHttpResult
40+
public function request(Model $model, array|string $payload, array $options = [], array $betaFeatures = []): RawHttpResult
4141
{
42+
$headers = [
43+
'x-api-key' => $this->apiKey,
44+
'anthropic-version' => $this->version,
45+
];
46+
4247
if (isset($options['tools'])) {
4348
$options['tool_choice'] = ['type' => 'auto'];
4449
}
4550

51+
if (!empty($betaFeatures)) {
52+
$headers['anthropic-beta'] = implode(',', $betaFeatures);
53+
}
54+
55+
4656
return new RawHttpResult($this->httpClient->request('POST', 'https://api.anthropic.com/v1/messages', [
47-
'headers' => [
48-
'x-api-key' => $this->apiKey,
49-
'anthropic-version' => $this->version,
50-
],
57+
'headers' => $headers,
5158
'json' => array_merge($options, $payload),
5259
]));
5360
}

0 commit comments

Comments
 (0)