Hi everyone,
I’m encountering an issue with unexpected costs while using the assistant APIs.
I’ve created an assistant, and uploaded a PDF file that is 1MB in size. I don’t have any other files or assistants loaded.
Next, I run the following code:
client = openai.OpenAI(api_key="API_KEY")
thread = client.beta.threads.create(
messages=[
{
"role": "user",
"content": instruction
}
]
)
run = client.beta.threads.runs.create_and_poll(
thread_id=thread.id,
assistant_id=assistant_id,
tool_choice={"type": "file_search"},
max_completion_tokens=2000
)
messages = list(client.beta.threads.messages.list(thread_id=thread.id, run_id=run.id))
message_content = messages[0].content[0].text
# Output the index
output = {"index": message_content.value}
The goal is to make a single call that generates information about the file and forces the assistant to use file_search
.
However, this single call costs me around $0.23, which seems unusually high. Every time I call it, I get charged this amount, no matter what.
I don’t know why is costing me this much.