Back to Blog
TutorialsMar 1, 20266 min read

Build an AI Chatbot in 30 Minutes with NexusAI API

JC

James Cooper

Developer Advocate

Want to add AI chat to your product? Here's how to do it in 30 minutes using the NexusAI API.

Prerequisites

  • A NexusAI account (Pro or Team plan for API access)
  • An API key from your dashboard settings
  • Node.js 18+ installed

Step 1: Install the SDK

bash
npm install @nexusai/sdk

Step 2: Initialize the Client

typescript

const nexus = new NexusAI({ apiKey: process.env.NEXUSAI_API_KEY, }); `

Step 3: Create a Chat Completion

typescript
const response = await nexus.chat.create({
  model: "gpt-4o",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "What is machine learning?" },
  ],

console.log(response.message.content); `

Step 4: Add Streaming

For a real-time typing effect:

typescript
const stream = await nexus.chat.stream({
  model: "gpt-4o",
  messages: [
    { role: "user", content: "Explain quantum computing simply." },
  ],

for await (const chunk of stream) { process.stdout.write(chunk.content); } `

Step 5: Connect to Your Frontend

Expose the API through a server route and connect it to your chat UI. The NexusAI SDK handles token counting, rate limiting, and error retries automatically.

Rate Limits

  • Pro plan: 60 requests/minute
  • Team plan: 300 requests/minute
  • All plans include automatic retry with exponential backoff

What's Next

Check out our full API documentation for advanced features like function calling, RAG integration, and multi-model routing.

Try NexusAI Free

Start creating with all 8 AI tools today. No credit card required.

Get Started Free