diff --git a/app/api/openai/raw.ts b/app/api/openai/raw.ts index 6c97432..5f3c769 100644 --- a/app/api/openai/raw.ts +++ b/app/api/openai/raw.ts @@ -1,4 +1,3 @@ -import { OpenAiRawRequestParams } from "@/misc/apiRoutes"; import { NextApiRequest, NextApiResponse } from "next"; import OpenAI from "openai"; const openai = new OpenAI(); @@ -18,3 +17,11 @@ const _handler = async (req: NextApiRequest, res: NextApiResponse) => { res.status(200).json({ data: completion.choices[0].message }); }; + +export interface OpenAiRawRequestParams { + prompt: string; +} + +export interface OpenAiRawResponseParams { + data: string; +} diff --git a/docs/openai/raw.md b/docs/openai/raw.md new file mode 100644 index 0000000..394f1aa --- /dev/null +++ b/docs/openai/raw.md @@ -0,0 +1,10 @@ +# POST `/openai/raw` +```ts +export interface OpenAiRawRequestParams { + prompt: string; +} + +export interface OpenAiRawResponseParams { + data: string; +} +``` \ No newline at end of file diff --git a/misc/apiRoutes.ts b/misc/apiRoutes.ts index 169b8f6..485b728 100644 --- a/misc/apiRoutes.ts +++ b/misc/apiRoutes.ts @@ -1,15 +1,12 @@ +import { OpenAiRawRequestParams, OpenAiRawResponseParams } from '@/app/api/openai/raw'; import axios from 'axios'; const api = axios.create(); export const endpoints = { openAi: { - getRawResponse: async (params: OpenAiRawRequestParams) => { + getRawResponse: async (params: OpenAiRawRequestParams): Promise => { return api.post('/openai/raw', params); }, } -}; - -export interface OpenAiRawRequestParams { - prompt: string; -} \ No newline at end of file +}; \ No newline at end of file