import OpenAI from "openai";

const apiKey = process.env.MODELRUSH_API_KEY;
if (!apiKey) throw new Error("Set MODELRUSH_API_KEY before running this example.");

const client = new OpenAI({
  apiKey,
  baseURL: "https://api.modelrush.ai/v1",
  timeout: 30_000,
  maxRetries: 2,
});

const response = await client.chat.completions.create({
  model: "modelrush/deepseek-v4.1-flash",
  messages: [
    { role: "system", content: "Answer concisely and name any uncertainty." },
    { role: "user", content: "Give me three checks for a production AI API integration." },
  ],
});

console.log(response.choices[0]?.message?.content ?? "No text returned.");
console.log("request_id", response._request_id ?? "not returned by this SDK version");
