extra_query parameter in OpenAI.batches.list #1675
-
|
I am trying to filter batches on the server side using the extra_query parameter like this: Unfortunately, it's not working. I also couldn't find any examples. Is the extra_query parameter currently functional? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
For So parameters like from datetime import datetime, timezone
cutoff = datetime.fromisoformat("2024-08-26T00:00:00+00:00")
for batch in client.batches.list(limit=100):
created_at = datetime.fromtimestamp(batch.created_at, tz=timezone.utc)
if batch.status == "completed" and created_at < cutoff:
print(batch.id)If you have many batches, use pagination ( |
Beta Was this translation helpful? Give feedback.
extra_querywill append arbitrary query parameters to the HTTP request, but it does not make the server support filters that the endpoint does not define.For
client.batches.list(), the current API reference only documentsafterandlimitas query parameters:https://developers.openai.com/api/reference/resources/batches/methods/list/
So parameters like
statusorcreated_beforeare not server-side filters for this endpoint. You need to page through the batches and filter client-side, for example: