Quickstart

VMSRouter provides an OpenRouter-compatible API gateway that gives you access to hundreds of AI models through a single endpoint. Self-host it on your own infrastructure and keep full control over your data and costs.

1. Get an API Key

Sign in to your VMSRouter dashboard, navigate to API Keys, and create a new key. Your key will look like sk-or-v1-....

2. Make Your First Request

Send a POST request to the chat completions endpoint. Replace <YOUR_API_KEY> with your actual API key and choose any model from the Models catalog.

cURL

curl https://api.vms.rent/api/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -d '{
    "model": "openai/gpt-4o",
    "messages": [
      { "role": "user", "content": "Hello, VMSRouter!" }
    ]
  }'

Python

import requests
import json

response = requests.post(
    url="https://api.vms.rent/api/v1/chat/completions",
    headers={
        "Authorization": "Bearer <YOUR_API_KEY>",
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "model": "openai/gpt-4o",
        "messages": [
            {"role": "user", "content": "Hello, VMSRouter!"}
        ],
    }),
)

print(response.json()["choices"][0]["message"]["content"])

JavaScript (fetch)

const response = await fetch("https://api.vms.rent/api/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": "Bearer <YOUR_API_KEY>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "openai/gpt-4o",
    messages: [
      { role: "user", content: "Hello, VMSRouter!" }
    ],
  }),
});

const data = await response.json();
console.log(data.choices[0].message.content);

Authentication

All API requests require authentication using a Bearer token. You can create and manage API keys from the API Keys page.

API Key Format

API keys use the sk-or-v1- prefix, matching the OpenRouter key format. This ensures compatibility with existing OpenRouter clients and SDKs.

Using Your Key

Include your API key in the Authorization header:

Authorization: Bearer sk-or-v1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Key Management

From the API Keys dashboard you can:

  • Create new keys with custom names
  • Set usage quotas and expiration dates
  • Restrict keys to specific models
  • Revoke or disable keys at any time

Chat Completions

The chat completions endpoint is the primary way to interact with language models through VMSRouter. It is fully compatible with the OpenAI chat completions API.

Endpoint

POST https://api.vms.rent/api/v1/chat/completions

Request Body

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g. openai/gpt-4o, anthropic/claude-sonnet-4-20250514)
messagesarrayYesArray of message objects with role and content
temperaturenumberNoSampling temperature (0-2). Defaults to 1
max_tokensnumberNoMaximum tokens in the response
streambooleanNoEnable Server-Sent Events streaming. Defaults to false
top_pnumberNoNucleus sampling parameter (0-1)
stopstring | arrayNoStop sequence(s) to halt generation
toolsarrayNoFunction definitions for tool calling
response_formatobjectNoSpecify output format (e.g. JSON mode)

Response Format

{
  "id": "chatcmpl-xxxxxxxx",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "openai/gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 8,
    "total_tokens": 20
  }
}

Streaming

Enable streaming to receive tokens as they are generated, providing a real-time experience similar to ChatGPT.

How It Works

Set stream: true in your request body. The response will be sent as Server-Sent Events (SSE), with each event containing a JSON chunk.

cURL

curl https://api.vms.rent/api/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -d '{
    "model": "openai/gpt-4o",
    "messages": [{"role": "user", "content": "Tell me a story"}],
    "stream": true
  }'

Python

import requests
import json
import sseclient

response = requests.post(
    url="https://api.vms.rent/api/v1/chat/completions",
    headers={
        "Authorization": "Bearer <YOUR_API_KEY>",
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "model": "openai/gpt-4o",
        "messages": [{"role": "user", "content": "Tell me a story"}],
        "stream": True,
    }),
    stream=True,
)

client = sseclient.SSEClient(response)
for event in client.events():
    if event.data == "[DONE]":
        break
    chunk = json.loads(event.data)
    content = chunk["choices"][0].get("delta", {}).get("content", "")
    if content:
        print(content, end="", flush=True)

Models

VMSRouter provides access to hundreds of models across dozens of providers. Use the models endpoint to discover available models programmatically, or browse the Models catalog.

List Models

GET https://api.vms.rent/api/v1/models

cURL

curl https://api.vms.rent/api/v1/models \
  -H "Authorization: Bearer <YOUR_API_KEY>"

Response

{
  "data": [
    {
      "id": "openai/gpt-4o",
      "object": "model",
      "created": 1700000000,
      "owned_by": "openai"
    },
    {
      "id": "anthropic/claude-sonnet-4-20250514",
      "object": "model",
      "created": 1700000000,
      "owned_by": "anthropic"
    }
  ]
}

Model IDs

VMSRouter uses the OpenRouter model ID convention: provider/model-name. For example:

  • openai/gpt-4o — OpenAI GPT-4o
  • anthropic/claude-sonnet-4-20250514 — Anthropic Claude Sonnet 4
  • google/gemini-2.5-flash — Google Gemini 2.5 Flash
  • meta-llama/llama-4-maverick — Meta Llama 4 Maverick
  • deepseek/deepseek-chat — DeepSeek Chat

OpenAI SDK Compatibility

VMSRouter is a drop-in replacement for the OpenAI API. You can use the official OpenAI SDK by simply changing the base URL.

Python

from openai import OpenAI

client = OpenAI(
    base_url="https://api.vms.rent/api/v1",
    api_key="<YOUR_API_KEY>",
)

completion = client.chat.completions.create(
    model="openai/gpt-4o",
    messages=[
        {"role": "user", "content": "Hello, VMSRouter!"}
    ],
)

print(completion.choices[0].message.content)

TypeScript / JavaScript

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.vms.rent/api/v1",
  apiKey: "<YOUR_API_KEY>",
});

const completion = await client.chat.completions.create({
  model: "openai/gpt-4o",
  messages: [
    { role: "user", content: "Hello, VMSRouter!" }
  ],
});

console.log(completion.choices[0].message.content);

Streaming with OpenAI SDK

const stream = await client.chat.completions.create({
  model: "openai/gpt-4o",
  messages: [{ role: "user", content: "Tell me a story" }],
  stream: true,
});

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