API REFERENCE
NestAI provides an OpenAI-compatible API to build AI-powered apps on top of your private infrastructure. Same APIs, same SDKs — but your data stays on your server.
Base URL
https://nestai.chirai.dev/api/v1Authentication
Authorization: Bearer nai-xxxxxxxxGenerate your API key from Dashboard → API.
Core Endpoints
| Endpoint | Method | Description |
|---|---|---|
| /chat/completions | POST | Generate responses (OpenAI compatible) |
| /models | GET | List available models |
Basic Usage
curl https://nestai.chirai.dev/api/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llama3.1",
"messages": [
{ "role": "user", "content": "Write a sales email" }
]
}'What You Can Build
1. Chat Applications
Build ChatGPT-like interfaces using your own models. Perfect for internal tools, support systems, or customer-facing apps.
2. AI Agents
Use with LangChain or AutoGen to build autonomous agents that run privately.
3. Document Q&A (RAG)
Upload documents and query them using the files field.
{
"model": "llama3.1",
"messages": [{ "role": "user", "content": "Summarise this doc" }],
"files": [{ "type": "collection", "id": "YOUR_COLLECTION_ID" }]
}4. Code Generation
Use coding models like qwen2.5-coder for: - code generation - debugging - refactoring
5. Automation & Workflows
Integrate into backend workflows: - email generation - report summarisation - CRM automation
6. Internal Tools
Build private AI tools for: - legal review - HR queries - financial analysis
Streaming Responses
from openai import OpenAI
client = OpenAI(
base_url="https://nestai.chirai.dev/api/v1",
api_key="YOUR_API_KEY"
)
with client.chat.completions.stream(
model="llama3.1",
messages=[{"role": "user", "content": "Explain AI"}],
) as stream:
for text in stream.text_stream:
print(text, end="")
SDK Usage
Node.js
import OpenAI from "openai"
const client = new OpenAI({
baseURL: "https://nestai.chirai.dev/api/v1",
apiKey: "YOUR_API_KEY"
})
const res = await client.chat.completions.create({
model: "llama3.1",
messages: [{ role: "user", content: "Hello" }]
})
console.log(res.choices[0].message.content)Python
from openai import OpenAI
client = OpenAI(
base_url="https://nestai.chirai.dev/api/v1",
api_key="YOUR_API_KEY"
)
res = client.chat.completions.create(
model="llama3.1",
messages=[{"role": "user", "content": "Hello"}]
)
print(res.choices[0].message.content)Build a Working AI App in 5 Minutes
Spin up a simple AI chat app using NestAI in under 5 minutes. This uses the OpenAI SDK — just replace the base URL.
1. Install dependencies
npm init -y
npm install openai express cors dotenv2. Create .env file
NESTAI_API_KEY=your_api_key_here3. Create server (server.js)
import express from "express"
import OpenAI from "openai"
import cors from "cors"
import dotenv from "dotenv"
dotenv.config()
const app = express()
app.use(cors())
app.use(express.json())
const client = new OpenAI({
baseURL: "https://nestai.chirai.dev/api/v1",
apiKey: process.env.NESTAI_API_KEY
})
app.post("/chat", async (req, res) => {
const { message } = req.body
const response = await client.chat.completions.create({
model: "llama3.1",
messages: [{ role: "user", content: message }]
})
res.json({
reply: response.choices[0].message.content
})
})
app.listen(3000, () => {
console.log("Server running on http://localhost:3000")
})4. Run server
node server.js5. Test it
curl http://localhost:3000/chat \
-H "Content-Type: application/json" \
-d '{"message": "Explain AI in simple terms"}'Frontend Example (Optional)
async function sendMessage(message) {
const res = await fetch("http://localhost:3000/chat", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ message })
})
const data = await res.json()
return data.reply
}Connect this function to any UI (React, Vue, plain HTML) to build a full chat app.
---Next Steps
| Goal | What to do |
|---|---|
| Build chatbot UI | Connect frontend to /chat endpoint |
| Add memory | Store messages in DB |
| Use RAG | Attach knowledge collections |
| Use better models | Switch to Qwen / DeepSeek |
| Scale usage | Deploy backend on your infra |
Models
Call /models to see available models on your server.
Features
| Feature | Details |
|---|---|
| OpenAI Compatible | Works with existing SDKs |
| No Rate Limits | No RPM/TPM restrictions |
| Private by Default | Data never leaves your server |
| Streaming | Real-time responses |
| Multi-model | Use any installed model |
Helpful Resources
| Resource | Link |
|---|---|
| OpenAI API Docs | https://platform.openai.com/docs |
| LangChain Docs | https://docs.langchain.com |
| LlamaIndex Docs | https://docs.llamaindex.ai |