This guide walks you through making your first LLM request through LLM Gateway. By the end, you'll have a working API key and a completed request visible in your dashboard.
Step 1: Get an API Key
- Sign in to the LLM Gateway dashboard.
- Create a new Project.
- Copy the API key.
- Export it in your shell or add it to a
.envfile:
export LLM_GATEWAY_API_KEY="llmgtwy_XXXXXXXXXXXXXXXX"
Step 2: Make Your First Request
LLM Gateway uses an OpenAI-compatible API. Point your requests to https://api.llmgateway.io/v1 and you're done.
Using curl
curl -X POST https://api.llmgateway.io/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "What is an LLM gateway?"}
]
}'
Using Node.js (OpenAI SDK)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.llmgateway.io/v1",
apiKey: process.env.LLM_GATEWAY_API_KEY,
});
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "What is an LLM gateway?" }],
});
console.log(response.choices[0].message.content);
Using Python
import requests
import os
response = requests.post(
"https://api.llmgateway.io/v1/chat/completions",
headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('LLM_GATEWAY_API_KEY')}",
},
json={
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "What is an LLM gateway?"}
],
},
)
response.raise_for_status()
print(response.json()["choices"][0]["message"]["content"])
Using the AI SDK
If you're using the Vercel AI SDK, you can use the native provider:
import { llmgateway } from "@llmgateway/ai-sdk-provider";
import { generateText } from "ai";
const { text } = await generateText({
model: llmgateway("openai/gpt-4o"),
prompt: "What is an LLM gateway?",
});
Or use the OpenAI-compatible adapter:
import { createOpenAI } from "@ai-sdk/openai";
const llmgateway = createOpenAI({
baseURL: "https://api.llmgateway.io/v1",
apiKey: process.env.LLM_GATEWAY_API_KEY!,
});
Step 3: Enable Streaming
Pass stream: true to any request and the gateway will proxy the event stream unchanged:
curl -X POST https://api.llmgateway.io/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $LLM_GATEWAY_API_KEY" \
-d '{
"model": "gpt-4o",
"stream": true,
"messages": [
{"role": "user", "content": "Write a short poem about APIs"}
]
}'
Step 4: Monitor in the Dashboard
Every call appears in the dashboard with latency, cost, and provider breakdown. Go back to your project to see your request logged with the model used, token counts, cost, and response time.
Step 5: Try a Different Provider
The best part of using a gateway: switching providers is a one-line change. Try the same request with a different model:
# Anthropic
"model": "anthropic/claude-haiku-4-5"
# Google
"model": "google-ai-studio/gemini-2.5-flash"
Same API, same code. Just a different model string.
What's Next
- Try models in the Playground — test any model with a chat interface before integrating
- Browse all models — compare pricing, context windows, and capabilities
- Read the full docs — streaming, tool calling, structured output, and more
- Join the Discord — get help and share what you're building
Top comments (4)
Nice starter flow. For first-call onboarding I like adding one intentional failure right after the happy path: call a wrong model name or invalid key and check whether the dashboard shows a clear error, timestamp, model, and token state. That tells you whether debugging will be possible when a real user reports a broken integration.
LLM gateways are becoming essential infrastructure. The 5-minute setup is impressive - we've built something similar at itapi.ai where a single API call routes to 40+ models. One thing I'd add: monitoring and cost tracking across providers is often the hidden complexity. How do you track token usage and costs when traffic spans multiple providers? We found that having a unified cost-per-request dashboard helped our users optimize their model selection and reduced their API spend by ~60%.
This is a test comment to verify submission works.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.