DEV Community

AI ROUTER
AI ROUTER

Posted on

Point an OpenAI-compatible SDK at a ChatGPT API relay

When a project already uses the OpenAI SDK shape, the lowest-friction way to test a relay service is to change two things only:

  1. the API base URL
  2. the API key

AI ROUTER provides an OpenAI-compatible ChatGPT API relay endpoint at:

https://api.ai-router.dev/v1
Enter fullscreen mode Exit fullscreen mode

That means a small prototype, coding-agent workflow, internal tool, or automation script can keep the same request pattern while using a relay account that exposes API key management, usage tracking, quota, balance, and subscription status.

cURL smoke test

curl https://api.ai-router.dev/v1/chat/completions \
  -H "Authorization: Bearer $AI_ROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [
      { "role": "user", "content": "Reply with a short API smoke test." }
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

Python

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AI_ROUTER_API_KEY"],
    base_url="https://api.ai-router.dev/v1",
)

response = client.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[{"role": "user", "content": "Write one test sentence."}],
)

print(response.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

Node.js

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.AI_ROUTER_API_KEY,
  baseURL: "https://api.ai-router.dev/v1",
});

const response = await client.chat.completions.create({
  model: "gpt-5.4-mini",
  messages: [{ role: "user", content: "Write one test sentence." }],
});

console.log(response.choices[0].message.content);
Enter fullscreen mode Exit fullscreen mode

What to check before scaling

  • Confirm the model name is available in your account.
  • Start with a small daily or weekly quota plan.
  • Watch API key usage, balance, quota, and subscription status from the dashboard.
  • Keep retry and timeout handling in your application code.
  • Avoid treating any relay as an official OpenAI service unless the provider explicitly says so.

I also published curl, Python, and Node.js examples here:

https://github.com/airouter-dev/chatgpt-api-relay-examples

Product page:

https://ai-router.dev

Top comments (0)