小编cam*_*per的帖子

OpenAI API 错误:“模块‘openai’没有导出成员‘配置’”

我正在尝试对 GPT-3.5 API 进行 API 调用,但从 OpenAI 导入的任何内容都会出现“没有导出的成员”错误。

import { Configuration, OpenAIApi } from "openai";
import { auth } from "@clerk/nextjs";
import { NextResponse } from "next/server";

const configuration = new Configuration({
    apiKey: process.env.OPENAI_API_KEY
});

const openai = new OpenAIApi(configuration);

export async function POST(
    req: Request
) {
    try {
        const { userId } = auth();
        const body = await req.json();
        const { messages } = body;

        if (!userId) {
            return new NextResponse("Unauthorised", { status: 401 });
        }

        if (!configuration.apiKey) …
Run Code Online (Sandbox Code Playgroud)

javascript node.js reactjs next.js openai-api

8
推荐指数
2
解决办法
5524
查看次数

标签 统计

javascript ×1

next.js ×1

node.js ×1

openai-api ×1

reactjs ×1