Build a chatbot via VerticalAPI

Building a production chatbot in 2026 means picking the right model for tone, latency and cost — and switching between providers as your traffic patterns evolve. Here's the recommended setup.

How it fits together

Frontend (React/Next) → POST /api/chat → your backend → VerticalAPI /v1/chat/completions (streaming) → token-streamed response back to frontend. Add a Redis cache for system prompts and a per-user rate limit at your edge.

Optional example in python

The code is a beta utility example, not the primary product promise. Confirm the current beta documentation before running it.

chatbot.pythonPython
from openai import OpenAI

client = OpenAI(
    base_url="https://api.verticalapi.com/v1",
    api_key="vapi_...",
    default_headers={"X-Provider-Key": "sk-ant-..."}
)

response = client.chat.completions.create(
    model="claude-haiku-4-5",
    messages=[
        {"role": "system", "content": "You are Acme's friendly support bot."},
        {"role": "user", "content": user_message}
    ],
    stream=True,
)
for chunk in response:
    yield chunk.choices[0].delta.content or ""

Cost inputs to verify

Typical chatbot serving 100K conversations/month at ~10 turns each (~500 tokens per turn) costs roughly $50-150/month on Claude Haiku 4.5, $20-60 on Gemini Flash, or $30-80 on Llama 3.3 70B via Groq. <!-- TODO Hugo: refine with actual conversion data -->

Compare source-dated model prices →

Common questions

Should I stream responses?

Yes — streaming reduces perceived latency dramatically.

How do I switch model based on user tier?

Pass model='claude-sonnet-4-5' for paid users, model='claude-haiku-4-5' for free. Same endpoint, same auth, just a different model field.

What about tool calling / function calling?

Standard OpenAI tools[] array works on Claude, GPT-4o, Gemini, Mistral, Llama (via Together/Groq/Fireworks). VerticalAPI normalizes provider differences so your tool definitions are portable.