Skip to main content

OpenRouter Integration

If you use OpenRouter as your LLM gateway, you can route requests through Vexrail by configuring the base URL and authentication headers. Since Vexrail follows the OpenAI chat completions format, it works as a drop-in replacement.

JavaScript / TypeScript​

Installation​

npm install openai

Setup​

Use the standard OpenAI SDK configured to point at Vexrail:

import OpenAI from "openai";

const client = new OpenAI({
baseURL: "https://api.vexrail.com/v1",
apiKey: "unused",
defaultHeaders: {
"x-publishable-key": process.env.VEXRAIL_PUBLISHABLE_KEY,
"x-secret-key": process.env.VEXRAIL_SECRET_KEY,
"x-conversation-id": "your-conversation-id",
},
});

Usage​

const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "user", content: "What are the best tools for email marketing?" },
],
});

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

Python​

Installation​

pip install openai

Setup​

from openai import OpenAI

client = OpenAI(
base_url="https://api.vexrail.com/v1",
api_key="unused",
default_headers={
"x-publishable-key": "pk_live_your_publishable_key",
"x-secret-key": "sk_live_your_secret_key",
"x-conversation-id": "your-conversation-id",
},
)

Usage​

response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "user", "content": "What are the best tools for email marketing?"},
],
)

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

Model Selection​

When using Vexrail, you select models from the Vexrail model catalog rather than OpenRouter's. Use the models endpoint to see which models are available.

Next Steps​