I’d like to see the cost of particular records that have specific metadata attributes.
Responses Api allows to attach a custom metadata object.
In documentation it says that it can be used in dashboard and via api. But I didn’t find in dashboard (usage) anything like that. Only period and project
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
with xxxxx.Client() as client:
response = client.withredirects.get(
"http://api-ide.unified-4.api.openai.com/v1/responses?metadata[client]=aleksan",
headers=headers,
)
response.raise_for_status()
response_object = resp.json()
responses_list = response_object.get("data")
responses_total = response_object.get("total")
responses_has_more = response_object.get("has_more")
responses_first_id = response_object.get("first_id")
responses_last_id = response_object.get("last_id ")
id_list = [item["id"] for item in responses_list if "id" in item]
id_metadata_map = {item["id"]: item["metadata"]
for item in responses_list
if "id" in item and "metadata" in item}
If you click into a conversation in the responses logs, and expand, you’ll see that there is indeed “tokens” shown for each message. It is tedious to get to, and you can’t see them in aggregate, but token consumption is there, which can be translated to monetary costs.
It also doesn’t seem to be foolproof, and any error like I just discover on one stored “responses” (where others running similar calls have token values) means the whole site cannot be trusted to deliver accuracy.
“Usage” in the dashboard allows you to download a block of API calls, regardless of whether they were stored by Responses, but that also is not as versatile as one might wish. Also not trustworthy to deliver on its promises, because instead of being able to demonstrate the quality of data there, I can only demonstrate a spinning icon of never being able to download.