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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.9.0"
".": "0.10.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 31
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-efe26b096126c693462514b8cbd3ec3e376569232becbfb730cd26fb31c7c7e3.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-04225437444990f383d0581df2f07022baab6ad510de0f3a8bd6b07c38d83cc9.yml
openapi_spec_hash: cae9199aabfd7b87f0ff2dcc10760c92
config_hash: 79b43ba5cfb2877d888e0d5ecab99d41
config_hash: fcc34074db6eaf64bc99b578c6c82c61
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.10.0 (2026-04-07)

Full Changelog: [v0.9.0...v0.10.0](https://github.com/anthropics/anthropic-sdk-php/compare/v0.9.0...v0.10.0)

### Features

* **api:** Add support for claude-mythos-preview ([140ef63](https://github.com/anthropics/anthropic-sdk-php/commit/140ef63deb83be8c2b787e4b0c5a3275e61a1ed1))
* **vertex:** add support for US multi-region endpoint ([347a703](https://github.com/anthropics/anthropic-sdk-php/commit/347a703e1ee910668eac06b3f6fdffa44c20ecbc))


### Chores

* **client:** internal updates ([553ec56](https://github.com/anthropics/anthropic-sdk-php/commit/553ec5616546f1d1fdeeb5b23d10c8c58855998c))

## 0.9.0 (2026-04-01)

Full Changelog: [v0.8.0...v0.9.0](https://github.com/anthropics/anthropic-sdk-php/compare/v0.8.0...v0.9.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Full documentation is available at **[platform.claude.com/docs/en/api/sdks/php](
<!-- x-release-please-start-version -->

```sh
composer require "anthropic-ai/sdk:^0.9.0"
composer require "anthropic-ai/sdk:^0.10.0"
```

<!-- x-release-please-end -->
Expand Down
4 changes: 2 additions & 2 deletions src/Aws/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Anthropic AWS gateway client.
*
* Connects to the Anthropic AWS gateway at https://gateway.{region}.api.aws
* Connects to the Anthropic AWS gateway at https://aws-external-anthropic.{region}.api.aws
* with support for x-api-key auth and AWS SigV4 signing.
*
* Auth is resolved by precedence:
Expand Down Expand Up @@ -44,7 +44,7 @@ public function __construct(
) {
$this->auth = new AwsAuth(
serviceName: 'aws-external-anthropic',
baseUrlPattern: 'https://gateway.{region}.api.aws',
baseUrlPattern: 'https://aws-external-anthropic.{region}.api.aws',
apiKeyEnvVar: 'ANTHROPIC_AWS_API_KEY',
baseUrlEnvVar: 'ANTHROPIC_AWS_BASE_URL',
workspaceIdEnvVar: 'ANTHROPIC_AWS_WORKSPACE_ID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ final class Params implements BaseModel
public string|array|null $system;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not support setting temperature. A value of 1.0 of will be accepted for backwards compatibility, all other values will be rejected with a 400 error.
*
* Amount of randomness injected into the response.
*
* Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.
Expand Down Expand Up @@ -362,6 +364,8 @@ final class Params implements BaseModel
public ?array $tools;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not accept top_k; any value will be rejected with a 400 error.
*
* Only sample from the top K options for each subsequent token.
*
* Used to remove "long tail" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
Expand All @@ -372,6 +376,8 @@ final class Params implements BaseModel
public ?int $topK;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not support setting top_p. A value >= 0.99 will be accepted for backwards compatibility, all other values will be rejected with a 400 error.
*
* Use nucleus sampling.
*
* In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both.
Expand Down
6 changes: 6 additions & 0 deletions src/Beta/Messages/MessageCreateParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ final class MessageCreateParams implements BaseModel
public string|array|null $system;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not support setting temperature. A value of 1.0 of will be accepted for backwards compatibility, all other values will be rejected with a 400 error.
*
* Amount of randomness injected into the response.
*
* Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.
Expand Down Expand Up @@ -343,6 +345,8 @@ final class MessageCreateParams implements BaseModel
public ?array $tools;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not accept top_k; any value will be rejected with a 400 error.
*
* Only sample from the top K options for each subsequent token.
*
* Used to remove "long tail" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
Expand All @@ -353,6 +357,8 @@ final class MessageCreateParams implements BaseModel
public ?int $topK;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not support setting top_p. A value >= 0.99 will be accepted for backwards compatibility, all other values will be rejected with a 400 error.
*
* Use nucleus sampling.
*
* In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both.
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/Batches/BatchCreateParams/Request/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ final class Params implements BaseModel
public string|array|null $system;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not support setting temperature. A value of 1.0 of will be accepted for backwards compatibility, all other values will be rejected with a 400 error.
*
* Amount of randomness injected into the response.
*
* Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.
Expand Down Expand Up @@ -312,6 +314,8 @@ final class Params implements BaseModel
public ?array $tools;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not accept top_k; any value will be rejected with a 400 error.
*
* Only sample from the top K options for each subsequent token.
*
* Used to remove "long tail" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
Expand All @@ -322,6 +326,8 @@ final class Params implements BaseModel
public ?int $topK;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not support setting top_p. A value >= 0.99 will be accepted for backwards compatibility, all other values will be rejected with a 400 error.
*
* Use nucleus sampling.
*
* In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both.
Expand Down
6 changes: 6 additions & 0 deletions src/Messages/MessageCreateParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ final class MessageCreateParams implements BaseModel
public string|array|null $system;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not support setting temperature. A value of 1.0 of will be accepted for backwards compatibility, all other values will be rejected with a 400 error.
*
* Amount of randomness injected into the response.
*
* Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.
Expand Down Expand Up @@ -294,6 +296,8 @@ final class MessageCreateParams implements BaseModel
public ?array $tools;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not accept top_k; any value will be rejected with a 400 error.
*
* Only sample from the top K options for each subsequent token.
*
* Used to remove "long tail" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
Expand All @@ -304,6 +308,8 @@ final class MessageCreateParams implements BaseModel
public ?int $topK;

/**
* @deprecated Deprecated. Models released after Claude Opus 4.6 do not support setting top_p. A value >= 0.99 will be accepted for backwards compatibility, all other values will be rejected with a 400 error.
*
* Use nucleus sampling.
*
* In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both.
Expand Down
2 changes: 2 additions & 0 deletions src/Messages/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
enum Model: string
{
// Anthropic model identifiers

case CLAUDE_MYTHOS_PREVIEW = 'claude-mythos-preview';

case CLAUDE_OPUS_4_6 = 'claude-opus-4-6';

Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
namespace Anthropic;

// x-release-please-start-version
const VERSION = '0.9.0';
const VERSION = '0.10.0';
// x-release-please-end
6 changes: 5 additions & 1 deletion src/Vertex/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ private function __construct(
);

// @see https://docs.cloud.google.com/vertex-ai/docs/reference/rest#rest_endpoints
$baseUrl = 'https://'.$location.'-aiplatform.googleapis.com';
$baseUrl = match ($location) {
'global' => 'https://aiplatform.googleapis.com',
'us' => 'https://aiplatform.us.rep.googleapis.com',
default => 'https://'.$location.'-aiplatform.googleapis.com',
};

parent::__construct(
headers: [],
Expand Down
10 changes: 5 additions & 5 deletions tests/Aws/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function testRegionFromAwsRegionEnv(): void
$client->messages->create(1024, [], 'claude-haiku-4-5');
$request = $this->getLastRequest();

$this->assertSame('gateway.eu-west-1.api.aws', $request->getUri()->getHost());
$this->assertSame('aws-external-anthropic.eu-west-1.api.aws', $request->getUri()->getHost());
}

public function testRegionFromAwsDefaultRegionEnv(): void
Expand All @@ -259,7 +259,7 @@ public function testRegionFromAwsDefaultRegionEnv(): void
$client->messages->create(1024, [], 'claude-haiku-4-5');
$request = $this->getLastRequest();

$this->assertSame('gateway.ap-southeast-1.api.aws', $request->getUri()->getHost());
$this->assertSame('aws-external-anthropic.ap-southeast-1.api.aws', $request->getUri()->getHost());
}

public function testAwsRegionEnvTakesPrecedenceOverDefault(): void
Expand All @@ -276,7 +276,7 @@ public function testAwsRegionEnvTakesPrecedenceOverDefault(): void
$client->messages->create(1024, [], 'claude-haiku-4-5');
$request = $this->getLastRequest();

$this->assertSame('gateway.us-east-1.api.aws', $request->getUri()->getHost());
$this->assertSame('aws-external-anthropic.us-east-1.api.aws', $request->getUri()->getHost());
}

public function testExplicitRegionOverridesEnv(): void
Expand All @@ -293,7 +293,7 @@ public function testExplicitRegionOverridesEnv(): void
$client->messages->create(1024, [], 'claude-haiku-4-5');
$request = $this->getLastRequest();

$this->assertSame('gateway.us-west-2.api.aws', $request->getUri()->getHost());
$this->assertSame('aws-external-anthropic.us-west-2.api.aws', $request->getUri()->getHost());
}

// ── Base URL resolution ─────────────────────────────────────────
Expand All @@ -305,7 +305,7 @@ public function testBaseUrlDerivedFromRegion(): void
$client->messages->create(1024, [], 'claude-haiku-4-5');
$request = $this->getLastRequest();

$this->assertSame('gateway.us-east-1.api.aws', $request->getUri()->getHost());
$this->assertSame('aws-external-anthropic.us-east-1.api.aws', $request->getUri()->getHost());
}

public function testExplicitBaseUrlOverridesRegion(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Services/Beta/MessagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function testCountTokens(): void
{
$result = $this->client->beta->messages->countTokens(
messages: [['content' => 'string', 'role' => 'user']],
model: 'claude-opus-4-6',
model: 'claude-mythos-preview',
);

// @phpstan-ignore-next-line method.alreadyNarrowedType
Expand All @@ -152,7 +152,7 @@ public function testCountTokensWithOptionalParams(): void
{
$result = $this->client->beta->messages->countTokens(
messages: [['content' => 'string', 'role' => 'user']],
model: 'claude-opus-4-6',
model: 'claude-mythos-preview',
cacheControl: ['type' => 'ephemeral', 'ttl' => '5m'],
contextManagement: [
'edits' => [
Expand Down
4 changes: 2 additions & 2 deletions tests/Services/MessagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function testCountTokens(): void
{
$result = $this->client->messages->countTokens(
messages: [['content' => 'string', 'role' => 'user']],
model: 'claude-opus-4-6',
model: 'claude-mythos-preview',
);

// @phpstan-ignore-next-line method.alreadyNarrowedType
Expand All @@ -121,7 +121,7 @@ public function testCountTokensWithOptionalParams(): void
{
$result = $this->client->messages->countTokens(
messages: [['content' => 'string', 'role' => 'user']],
model: 'claude-opus-4-6',
model: 'claude-mythos-preview',
cacheControl: ['type' => 'ephemeral', 'ttl' => '5m'],
outputConfig: [
'effort' => 'low',
Expand Down
61 changes: 61 additions & 0 deletions tests/Vertex/ClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace Tests\Vertex;

use Anthropic\Vertex\Client;
use PHPUnit\Framework\TestCase;

/**
* @internal
*
* @coversNothing
*/
class ClientTest extends TestCase
{
/**
* @dataProvider locationBaseUrlProvider
*/
public function testBaseUrlForLocation(string $location, string $expectedHost): void
{
$client = $this->createClientWithLocation($location);

$reflection = new \ReflectionMethod($client, 'getBaseUrl');
$baseUrl = $reflection->invoke($client);

$this->assertInstanceOf(\Psr\Http\Message\UriInterface::class, $baseUrl);
$this->assertSame($expectedHost, (string) $baseUrl);
}

/**
* @return iterable<string, array{string, string}>
*/
public static function locationBaseUrlProvider(): iterable
{
yield 'global region' => ['global', 'https://aiplatform.googleapis.com'];

yield 'us region' => ['us', 'https://aiplatform.us.rep.googleapis.com'];

yield 'us-central1 region' => ['us-central1', 'https://us-central1-aiplatform.googleapis.com'];

yield 'europe-west1 region' => ['europe-west1', 'https://europe-west1-aiplatform.googleapis.com'];

yield 'asia-southeast1 region' => ['asia-southeast1', 'https://asia-southeast1-aiplatform.googleapis.com'];
}

private function createClientWithLocation(string $location): Client
{
$reflection = new \ReflectionClass(Client::class);
$constructor = $reflection->getConstructor();
assert(null !== $constructor);

$client = $reflection->newInstanceWithoutConstructor();

$credentialsProvider = function () {
throw new \RuntimeException('Should not be called in tests');
};

$constructor->invoke($client, $credentialsProvider, $location, 'test-project');

return $client;
}
}