Enable Anthropic on Vertex AI in Settings
| Field | Type | Required | Description |
|---|---|---|---|
| projectId | text | Required | Your Google Cloud project ID |
| region | text | Optional | Google Cloud region |
Add provider:
node packages/npm-webinfer/dist/cli.js provider add anthropic-vertexTest connection:
node packages/npm-webinfer/dist/cli.js provider test anthropic-vertexBasic usage:
import { generateText } from "@webinfer/client"
// WebInfer automatically routes to the best available provider
const result = await generateText({
prompt: "Write a haiku about programming"
})
console.log(result.text)Specify Anthropic on Vertex AI explicitly:
import { generateText } from "@webinfer/client"
const result = await generateText({
prompt: "Write a haiku about programming",
provider: "anthropic-vertex",
model: "claude-3-5-sonnet-v2@20241022"
})
console.log(result.text)
console.log("Provider:", result.provider)
console.log("Model:", result.model)Streaming:
import { streamText } from "@webinfer/client"
const { textStream } = await streamText({
prompt: "Write a story about AI",
provider: "anthropic-vertex"
})
for await (const chunk of textStream) {
process.stdout.write(chunk)
}