AI ROUTER provides an OpenAI-compatible endpoint for ChatGPT API relay usage:
https://api.ai-router.dev/v1
For many projects, the migration path is to keep the OpenAI SDK and change the SDK base URL to AI ROUTER.
from openai import OpenAI
client = OpenAI(
api_key="replace_with_your_ai_router_api_key",
base_url="https://api.ai-router.dev/v1",
)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AI_ROUTER_API_KEY,
baseURL: "https://api.ai-router.dev/v1",
});Model IDs are not hard-coded in this repository because availability can differ by API key and can change. With an authenticated key, list the IDs available to your integration:
curl -sS https://api.ai-router.dev/v1/models \
-H "Authorization: Bearer $AI_ROUTER_API_KEY"Use an id from the response as your request's model value. You can also
choose a model from the AI ROUTER dashboard. Do not assume that a model ID from
another account or an old example remains available.
OpenAI-compatible means AI ROUTER follows familiar OpenAI-style API patterns where supported. It does not mean AI ROUTER is an official OpenAI service, and it does not mean every model, parameter, or behavior is identical. Check the dashboard for available models and plan rules.
- Create a small test API key.
- Set the SDK base URL.
- Send one chat completion request.
- Check usage in the dashboard.
- Increase plan size only after the workflow is stable.
Related: