How can I get stored Logs via API?

OpenAI has these logs, and these are stored when you have a store=True parameter in the Response API. My question is, is there a way we can retrieve these stored results via an API call?

My use case is that I want to put in a model_name and then get the logs stored for that model. Any one can help?

For responses API and agent traces, it would be a nice feature to list the stored logged requests. feature-request

For completions, you can do that by using the list chat completions endpoint here.

Commenting for reach… Definitely need an API that returns all response id’s so that we can then loop through those and get the responses.

I’ve been using this script for the Completion logs. I know it doesn’t solve your issue but might be helpful for people that use the completions api

completions = client.chat.completions.list()

print("=" * 60)
print("Chat Completions")
print("=" * 60)

for completion in completions.data:
    print(f"\nID: {completion.id}")
    print(f"Created: {completion.created}")
    print(f"Model: {completion.model}")

    # Retrieve full conversation history using messages sub-resource
    try:
        messages = client.chat.completions.messages.list(completion.id)
        print("\nConversation:")
        for msg in messages.data:
            role = msg.role if hasattr(msg, 'role') else 'unknown'
            content = msg.content if hasattr(msg, 'content') else ''
            print(f"  [{role}]: {content}")
    except Exception as e:
        print(f"\nCould not retrieve messages: {e}")

    # Display the completion output
    if hasattr(completion, 'choices') and completion.choices:
        print("\nCompletion:")
        for choice in completion.choices:
            if hasattr(choice, 'message') and choice.message:
                print(f"  [{choice.message.role}]: {choice.message.content}")

    print("-" * 60)