Vertex AI API Developer Docs
v2.4 · Now with streaming tool calls

Build with state-of-the-art AI models, in minutes.

One unified API for text generation, embeddings, and tool calling. Ship production-ready AI features with predictable pricing, low latency, and 99.95% uptime.

Engineers collaborating on AI tooling

Core documentation

Pick your path — everything you need from first request to production.

120M+

API calls served daily

182 ms

Median first-token latency

99.95%

Uptime, last 12 months

Getting started

Quickstart

A step-by-step guide to making your first AI API request — SDK installation, API key setup, and a working sample in three short steps.


1

Install the SDK

Install the official Vertex SDK for your language. The SDK handles authentication, retries, and streaming for you.

Terminal
# Node.js 18+
npm install @vertex-ai/sdk

2

Set up your API key

Create a key in your dashboard, then export it as an environment variable. Never hard-code keys in source control.

Shell
export VERTEX_API_KEY=sk-••••••••••
Free-tier keys are rate-limited to 60 requests/min. Upgrade for production workloads.

3

Make your first request

Run this snippet. You'll get a completion back in a single synchronous call — no configuration required.

first-request.js
import Vertex from "@vertex-ai/sdk";

const client = new Vertex();

const res = await client.chat.completions.create({
  model: "vertex-large-2",
  messages: [{ role: "user", content: "Explain embeddings in one sentence." }],
});

console.log(res.choices[0].message.content);

Expected output

"Embeddings are dense vector representations that let a model measure how similar two pieces of text are."


Next steps

Now that your first request works, go deeper with the full reference or the task-oriented guides.

POST

/v1/chat/completions

Generate a model response for a conversation. Send a list of messages and receive the assistant's reply, with optional streaming and tool calling.

Request

Authenticate with a bearer token in the Authorization header. Keys are scoped per project.

  • model — required. One of vertex-large-2, vertex-fast-2
  • messages — required. Conversation so far
  • stream — optional, default false
  • tools — optional function definitions
cURL

Parameters

NameTypeDefaultDescription
modelstringModel ID to use for the completion.
messagesarrayMessages so far, oldest first. Max 128 turns.
temperaturenumber1.0Sampling temperature, 0–2. Lower is more deterministic.
max_tokensinteger4096Upper bound on generated tokens.
streambooleanfalseStream tokens as server-sent events.

Response

Returns a completion object containing the assistant message, token usage, and a stable finish reason.

200 OK · application/json
{
  "id": "cmpl_8f2ka1",
  "object": "chat.completion",
  "model": "vertex-large-2",
  "choices": [{
    "index": 0,
    "message": { "role": "assistant", "content": "Hello! How can I help?" },
    "finish_reason": "stop"
  }],
  "usage": { "prompt_tokens": 12, "completion_tokens": 9 }
}

Errors

Errors use conventional HTTP status codes and always return a machine-readable JSON body.

CodeMessageHow to fix
400 Invalid request: model is required Check the request body against the schema.
401 Invalid or missing API key Verify the Authorization header.
429 Rate limit exceeded Back off exponentially; check Retry-After.
500 Internal server error Retry with jitter; contact support if persistent.

Ready to build something real?

Task-oriented guides cover streaming, tool calling, and shipping to production.

Read Developer Guides

Developer Guides

Task-oriented guides for shipping AI features

From your first text generation to production hardening — practical, copy-paste-ready guidance for every stage of the journey.

Brand new to the API?

Start here — your first working request in under five minutes.

Start with the Quickstart
Copied