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:
npx webinfer provider add anthropic-vertexTest connection:
npx webinfer provider test anthropic-vertexBasic usage:
import { generateText } from "webinfer"
// 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"
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"
const { textStream } = await streamText({
prompt: "Write a story about AI",
provider: "anthropic-vertex"
})
for await (const chunk of textStream) {
process.stdout.write(chunk)
}