Im using the npm package however when running the sample from the docs, im getting:
Trace: Error: 404 Invalid URL (POST /v1/assistants)
Here is my example, am I missing something?
import { Context } from "hono";
import OpenAI from "openai";
export const createAssistant = async (c: Context) => {
const openai = new OpenAI({
apiKey: c.env.OPENAI_API_KEY,
});
const assistant = await openai.beta.assistants.create({
name: "Math Tutor",
instructions: "You are a personal math tutor. Write and run code to answer math questions.",
tools: [{ type: "code_interpreter" }],
model: "gpt-4-1106-preview"
});
const { id, name, instructions, tools, model } = assistant;
const retrieveAssistant = await openai.beta.assistants.retrieve(id)
console.log('retrieveAssistant', retrieveAssistant);
const thread = await openai.beta.threads.create({ messages: [] });
const message = await openai.beta.threads.messages.create(
thread.id,
{
role: "user",
content: "I need to solve the equation `3x + 11 = 14`. Can you help me?"
}
);
console.log('message', message);
const runCreate = await openai.beta.threads.runs.create(
thread.id,
{
assistant_id: assistant.id,
instructions: "Please address the user as Jane Doe. The user has a premium account."
}
);
const runRetrieve = await openai.beta.threads.runs.retrieve(
thread.id,
runCreate.id
);
return c.json(runRetrieve)
}