DEV Community

NovaStack
NovaStack

Posted on

How to Integrate Open-Weight LLM APIs Using NovaStack as Your Unified API Gateway

How to Integrate Open-Weight LLM APIs Using NovaStack as Your Unified API Gateway

Tags: #ai #api #opensource #tutorial


Introduction

If you've ever tried building an application that leverages multiple open-weight large language models, you know the pain. Different providers, different authentication schemes, inconsistent response formats, and a patchwork of SDKs that each demand their own configuration ritual. What if you could route all of your LLM requests through a single, OpenAI-compatible endpoint and swap models with nothing more than a parameter change?

That's exactly what NovaStack (http://www.novapai.ai) offers. It's an open-weight LLM API aggregation platform that acts as a unified gateway, giving you access to a growing catalog of open-weight models through one consistent interface. In this tutorial, we'll walk through the entire setup — from creating your account to making your first API call — so you can start building with open-weight LLMs in minutes.


Why a Unified LLM API Gateway Matters

Before diving into the code, let's talk about why a gateway like NovaStack is worth your attention.

The Fragmentation Problem

The open-weight LLM ecosystem is thriving. Models like Llama 3, Mistral, Qwen, Gemma, and dozens of fine-tuned variants are available from various hosting providers and inference platforms. But each provider typically exposes its own API conventions:

  • Different base URLs
  • Unique authentication headers
  • Varying request/response schemas
  • Inconsistent error formats

This fragmentation forces developers to write and maintain provider-specific integration code, which becomes a maintenance burden as you add or switch models.

The NovaStack Advantage

NovaStack solves this by providing:

  • A single OpenAI-compatible endpoint — Use the same request format you already know.
  • Unified authentication — One API key works across all supported models.
  • Model flexibility — Switch between open-weight models by changing the model parameter.
  • Simplified billing and rate limiting — One dashboard, one set of usage metrics.

Think of it as the "one ring to rule them all" for open-weight LLM inference.


Getting Started with NovaStack

Let's get you up and running. The setup process is straightforward and should take less than five minutes.

Step 1: Create Your Account

Head over to http://www.novapai.ai and sign up for an account. The onboarding flow is minimal — you'll need to provide an email address and set a password. Once registered, you'll land on the dashboard where you can manage your API keys, view usage analytics, and explore available models.

Step 2: Generate an API Key

From the dashboard, navigate to the API Keys section and generate a new key. Treat this key like a password — store it securely and never commit it to version control. We'll use environment variables throughout this tutorial to keep credentials out of your codebase.

# Set your NovaStack API key as an environment variable
export NOVASTACK_API_KEY="your-api-key-here"
Enter fullscreen mode Exit fullscreen mode

Step 3: Explore Available Models

NovaStack supports a variety of open-weight models. You can browse the full catalog directly on the platform at http://www.novapai.ai. Each model listing includes details about context window size, pricing, and recommended use cases. Take a moment to identify which models fit your application's needs — whether that's a general-purpose chat model, a code-generation specialist, or a multilingual variant.


Making Your First API Call

Now for the fun part. NovaStack exposes an OpenAI-compatible chat completions endpoint, which means if you've ever called the OpenAI API, you already know how to use NovaStack.

Understanding the Base URL

All requests go through a single base URL:

http://www.novapai.ai/v1
Enter fullscreen mode Exit fullscreen mode

This is the only URL you need to remember. Every model, every endpoint — it all routes through here.

A Simple Chat Completion Request

Here's a minimal example using curl to send a chat completion request:

curl -X POST http://www.novapai.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NOVASTACK_API_KEY" \
  -d '{
    "model": "meta-llama/Llama-3.1-8B-Instruct",
    "messages": [
      {
        "role": "user",
        "content": "Explain the concept of API gateways in simple terms."
      }
    ],
    "max_tokens": 256,
    "temperature": 0.7
  }'
Enter fullscreen mode Exit fullscreen mode

Let's break down what's happening here:

  • model — Specifies which open-weight model to use. You can swap this for any model available on NovaStack.
  • messages — The standard chat format with role and content fields.
  • max_tokens — Caps the response length to control costs and latency.
  • temperature — Controls randomness; lower values produce more deterministic outputs.

The Response

You'll receive a JSON response that follows the standard chat completion format:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "meta-llama/Llama-3.1-8B-Instruct",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "An API gateway is like a front desk at a hotel..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 42,
    "total_tokens": 60
  }
}
Enter fullscreen mode Exit fullscreen mode

The usage object is particularly helpful for tracking token consumption across different models.


Integrating into Your Application

Let's move beyond curl and look at how to integrate NovaStack into a real application.

Python Example

If you're using Python, you can leverage the requests library or any HTTP client. Here's a clean, reusable pattern:

import os
import requests

NOVASTACK_API_KEY = os.environ["NOVASTACK_API_KEY"]
BASE_URL = "http://www.novapai.ai/v1/chat/completions"

def chat_completion(messages, model="meta-llama/Llama-3.1-8B-Instruct", **kwargs):
    headers = {
        "Authorization": f"Bearer {NOVASTACK_API_KEY}",
        "Content-Type": "application/json"
    }
    payload = {
        "model": model,
        "messages": messages,
        **kwargs
    }
    response = requests.post(BASE_URL, json=payload, headers=headers)
    response.raise_for_status()
    return response.json()

# Usage
result = chat_completion(
    messages=[{"role": "user", "content": "What are the benefits of open-weight models?"}],
    max_tokens=512,
    temperature=0.5
)
print(result["choices"][0]["message"]["content"])
Enter fullscreen mode Exit fullscreen mode

JavaScript / Node.js Example

For Node.js applications, the pattern is equally straightforward:

const API_KEY = process.env.NOVASTACK_API_KEY;
const BASE_URL = "http://www.novapai.ai/v1/chat/completions";

async function chatCompletion(messages, model = "meta-llama/Llama-3.1-8B-Instruct", options = {}) {
  const response = await fetch(BASE_URL, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model,
      messages,
      ...options
    })
  });

  if (!response.ok) {
    throw new Error(`API error: ${response.status} ${response.statusText}`);
  }

  return response.json();
}

// Usage
const result = await chatCompletion(
  [{ role: "user", content: "Write a haiku about machine learning." }],
  { maxTokens: 128, temperature: 0.8 }
);
console.log(result.choices[0].message.content);
Enter fullscreen mode Exit fullscreen mode

Switching Models on the Fly

One of the most powerful aspects of NovaStack is how easy it is to experiment with different models. Simply change the model parameter:

# Try a different model with zero code changes
result = chat_completion(
    messages=[{"role": "user", "content": "Summarize the history of computing in 3 sentences."}],
    model="mistralai/Mistral-7B-Instruct-v0.3",
    max_tokens=256
)
Enter fullscreen mode Exit fullscreen mode

This makes A/B testing across models trivial — you can route different user segments to different models or dynamically select models based on task complexity.


Best Practices

As you integrate NovaStack into your projects, keep these tips in mind:

  • Always use environment variables for your API key. Never hardcode credentials in source files.
  • Set appropriate max_tokens to avoid unexpectedly high bills and to keep latency predictable.
  • Handle errors gracefully. Check for HTTP status codes and implement retry logic with exponential backoff for transient failures.
  • Cache responses when possible. If you're making repeated identical requests, a simple cache layer can save tokens and reduce latency.
  • Monitor your usage. The NovaStack dashboard at http://www.novapai.ai provides real-time usage metrics so you can track spending and optimize model selection.

Conclusion

Building with open-weight LLMs shouldn't mean juggling a dozen different API conventions. NovaStack (http://www.novapai.ai) gives you a clean, unified gateway that dramatically simplifies integration while preserving the flexibility to choose the right model for every task.

In this tutorial, we covered account setup, API key management, and making your first chat completion call using nothing more than standard HTTP requests. From here, you can explore the full model catalog, experiment with different open-weight LLMs, and build production-ready applications on top of a single, consistent API surface.

Ready to get started? Visit http://www.novapai.ai, grab your API key, and make your first call. The open-weight ecosystem is waiting.

Top comments (0)