It’s not just limited to the File Search or Code Interpreter in the Assistant API, but there isn’t a way to programmatically retrieve costs.
For File Search, the cost is free for the first 1GB. Beyond that, it costs $0.1 per day for storage.
You first GB is free and beyond that, usage is billed at $0.10/GB/day of vector storage. There are no other costs associated with vector store operations.
https://platform.openai.com/docs/assistants/tools/file-search/vector-stores
As for the Code Interpreter, charges are session-based. If the user continues to use the same session, there is a usage-based charge of $0.03 per hour, but by default, a session is only valid for one hour. This means that typically, you will only be charged $0.03 per session.
Code Interpreter is charged at $0.03 per session. If your Assistant calls Code Interpreter simultaneously in two different threads (e.g., one thread per end-user), two Code Interpreter sessions are created. Each session is active by default for one hour, which means that you only pay for one session per if users interact with Code Interpreter in the same thread for up to one hour.
https://platform.openai.com/docs/assistants/tools/code-interpreter
In this case, for File Search, the cost depends on how many GB of data you upload. If you delete the files after 10 minutes, you would be charged for only one day. It would be free for the first 1GB, and beyond that, it would cost $0.03 per GB.
While it is inconvenient not to be able to directly know the cost from the API, for File Search and Code Interpreter, I don’t think you need to worry too much about the expenses.
I hope this helps 