Developer Documentation

Drop-in OpenAI SDK

Keep your existing code, Cursor, Claude Code, Cline, or LangChain config. Change one base URL and your API key.

Quickstart

Send a chat completion request to the free cluster endpoint:

curl
curl https://nextrouter.nextapi.online/v1/chat/completions \
  -H "Authorization: Bearer $NEXTROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-4.1-flash-free-01",
    "messages": [{ "role": "user", "content": "Explain quantum computing in one sentence." }],
    "stream": true
  }'

Python (OpenAI SDK)

python
from openai import OpenAI

client = OpenAI(
    base_url="https://nextrouter.nextapi.online/v1",
    api_key="nr-sk-your-key-here",
)

# 1M Context Nemotron or DeepSeek R1 reasoning
stream = client.chat.completions.create(
    model="nemotron-3.5-lightning", # 1,048,576 Token Context Window!
    messages=[{"role": "user", "content": "Write a distributed Redis queue worker."}],
    stream=True,
)

for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

Node.js / TypeScript

typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://nextrouter.nextapi.online/v1",
  apiKey: process.env.NEXTROUTER_API_KEY,
});

const completion = await client.chat.completions.create({
  model: "deepseek-4.1-flash-free-01",
  messages: [{ role: "user", content: "Optimize this PostgreSQL query." }],
  stream: true,
});

for await (const chunk of completion) {
  process.stdout.write(chunk.choices[0]?.delta?.content || "");
}