Switch to og openai client

This commit is contained in:
2025-07-19 12:35:41 +03:00
parent 963ac7111f
commit dcd0ab4188
4 changed files with 28 additions and 39 deletions

View File

@@ -1,15 +1,11 @@
import { tryit } from "radash";
import OpenAI from "openai";
export const useOpenAI = () => {
const config = useRuntimeConfig();
const client = $fetch.create({
baseURL: "https://api.openai.com/v1",
headers: {
Authorization: `Bearer ${config.openaiApiKey}`,
},
method: "post",
const client = new OpenAI({
apiKey: config.openaiApiKey,
});
return tryit(client);
return client;
};