
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@anthropic-ai/vertex-sdk
Advanced tools
This library provides convenient access to the Anthropic Vertex API.
For the non-Vertex Anthropic API at api.anthropic.com, see @anthropic-ai/sdk.
npm install @anthropic-ai/vertex-sdk
import { AnthropicVertex } from '@anthropic-ai/vertex-sdk';
// Reads from the `CLOUD_ML_REGION` & `ANTHROPIC_VERTEX_PROJECT_ID` environment variables.
// Additionally goes through the standard `google-auth-library` flow.
const client = new AnthropicVertex();
async function main() {
const result = await client.messages.create({
messages: [
{
role: 'user',
content: 'Hey Claude!',
},
],
model: 'claude-3-5-sonnet-v2@20241022',
max_tokens: 300,
});
console.log(JSON.stringify(result, null, 2));
}
main();
For more details on how to use the SDK, see the README.md for the main Anthropic SDK which this library extends.
This library supports multiple authentication methods:
The client automatically uses the default Google Cloud authentication flow:
import { AnthropicVertex } from '@anthropic-ai/vertex-sdk';
// Uses default authentication and environment variables
const client = new AnthropicVertex({
region: 'us-central1',
projectId: 'my-project-id',
});
You can customize the authentication using the googleAuth option:
import { AnthropicVertex } from '@anthropic-ai/vertex-sdk';
import { GoogleAuth } from 'google-auth-library';
const client = new AnthropicVertex({
googleAuth: new GoogleAuth({
scopes: 'https://www.googleapis.com/auth/cloud-platform',
keyFile: '/path/to/service-account.json',
}),
region: 'us-central1',
projectId: 'my-project-id',
});
For advanced use cases like impersonation, you can provide a pre-configured AuthClient:
import { AnthropicVertex } from '@anthropic-ai/vertex-sdk';
import { GoogleAuth, Impersonated } from 'google-auth-library';
// Create an impersonated credential
const authClient = new Impersonated({
sourceClient: await new GoogleAuth().getClient(),
targetPrincipal: 'impersonated-account@projectID.iam.gserviceaccount.com',
lifetime: 30,
delegates: [],
targetScopes: ['https://www.googleapis.com/auth/cloud-platform'],
});
const client = new AnthropicVertex({
authClient,
region: 'us-central1',
projectId: 'my-project-id',
});
TypeScript >= 4.5 is supported.
The following runtimes are supported:
import { AnthropicVertex } from "npm:@anthropic-ai/vertex-sdk"."node" environment ("jsdom" is not supported at this time).Note that React Native is not supported at this time.
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
FAQs
The official TypeScript library for the Anthropic Vertex API
The npm package @anthropic-ai/vertex-sdk receives a total of 38,957 weekly downloads. As such, @anthropic-ai/vertex-sdk popularity was classified as popular.
We found that @anthropic-ai/vertex-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.