JavaScript / Node.js quickstart — 5 lines to ship

The OpenAI JS SDK works against VerticalAPI without modification. Install with npm, set baseURL and apiKey, pass your provider key via defaultHeaders. Same code in browser, Node, Deno, Bun.

From zero to first call

  1. Sign up at verticalapi.com/dashboard

    Free tier — no card required. Generates your vapi_ key automatically.

  2. Add a provider key

    Paste your OpenAI sk-..., Anthropic sk-ant-..., or Google AIza... into the dashboard. Encrypted at rest.

  3. Install the JavaScript / Node.js SDK

    npm install openai

  4. Run the example below

    Drop-in OpenAI SDK pattern — base_url + api_key + provider key header. That's it.

  5. Inspect the trace

    Every call gets a unique request ID. Find it in the dashboard with full latency, tokens, and cost breakdown.

JavaScript / Node.js — first call

quickstart.javascriptJavaScript / Node.js
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.verticalapi.com/v1',
  apiKey: 'vapi_...',
  defaultHeaders: { 'X-Provider-Key': 'sk-...' }
});

const response = await client.chat.completions.create({
  model: 'gpt-4o',  // or claude-sonnet-4-5, gemini-2.5-pro
  messages: [{ role: 'user', content: 'Hello, world' }],
});
console.log(response.choices[0].message.content);

Swap model for claude-sonnet-4-5, gemini-2.5-pro, or any of 25+ supported providers. Update X-Provider-Key to match.

Common errors and fixes

CORS error in browser
Don't expose your VerticalAPI key client-side. Proxy through your own /api endpoint and inject the key server-side. The dashboard offers per-domain keys with origin restrictions for legitimate browser-direct setups.
TypeError: fetch is not defined (Node < 18)
Upgrade to Node 18+ which has built-in fetch, or pass a polyfilled fetch in the SDK config.
Streaming not flushing chunks
Use response = await client.chat.completions.create({stream: true, ...}); for await (const chunk of response) { ... } — the OpenAI SDK supports async iteration on streams.

Where to go from here

Pick a model: browse all 25+ providers. Compare two: read head-to-head comparisons. Or jump to a use case: chatbot, RAG, autonomous agents.