通过AzureOpenAI请求gpt-4.1-mini

The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.

https://learn.microsoft.com/zh-cn/azure/ai-services/openai/how-to/create-resource?pivots=web-portal

https://ai.azure.com/build/deployments/model?wsid=/subscriptions/76b46e2c-41ac-407f-bc56-124f55f90dcc/resourceGroups/rg-13642061747-1824_ai/providers/Microsoft.MachineLearningServices/workspaces/13642061747-2861&tid=c60868ed-4b1e-488b-b146-7a0e22ceefc7

javascript 复制代码
import { AzureOpenAI } from "openai";

const endpoint = "https://ai-xxx.openai.azure.com/";
const modelName = "gpt-4.1-mini";
const deployment = "gpt-4.1-mini";

export async function main() {

  const apiKey = "<your-api-key>";
  const apiVersion = "2024-04-01-preview";
  const options = { endpoint, apiKey, deployment, apiVersion }

  const client = new AzureOpenAI(options);

  const response = await client.chat.completions.create({
    messages: [
      { role:"user", content: "你好" }
    ],
    max_completion_tokens: 800,
      temperature: 1,
      top_p: 1,
      frequency_penalty: 0,
      presence_penalty: 0,
      model: modelName
  });

  if (response?.error !== undefined && response.status !== "200") {
    throw response.error;
  }
  console.log(response.choices[0].message.content);
}

main().catch((err) => {
  console.error("The sample encountered an error:", err);
});
相关推荐
We་ct18 小时前
LeetCode 162. 寻找峰值:二分高效求解
前端·算法·leetcode·typescript·二分·暴力
HWL567918 小时前
uni-app的生命周期
前端·vue.js·uni-app
softbangong18 小时前
829-批量提取各子文件夹下文件到一级目录
java·服务器·前端·自动化工具·批量文件处理·文件提取工具·文件夹整理
李剑一18 小时前
别再瞎写 Cesium 可视化!热力图 + 四色图源码全公开,项目直接复用!
前端·vue.js·cesium
SuperEugene18 小时前
Vue3 + Vue Router + Pinia 路由守卫规范:beforeEach 应做 / 不应做,避死循环、防重复请求|状态管理与路由规范篇
开发语言·前端·javascript·vue.js·前端框架
Greg_Zhong18 小时前
Css知识之伪类和伪元素
前端·css
Mintopia18 小时前
GPT-5.3-Codex 底层逻辑是什么,为什么编码强?
前端·人工智能·ai编程
Mintopia18 小时前
Opus 模型凭什么收费贵,与其他模型对比理由是什么?
前端·人工智能
东东__net19 小时前
js逆向与谷歌加密库
开发语言·前端·javascript
程序员小郭8319 小时前
Spring Ai 05 ChatClient Advisor 实战(日志、提示词增强、内容安全)
java·开发语言·前端