Skip to content

feat(api): support response format updates and local output types - #4212

Draft
markstuart-oai wants to merge 1 commit into
mainfrom
castiron/promotions/pr-365
Draft

markstuart-oai wants to merge 1 commit into
mainfrom
castiron/promotions/pr-365

Conversation

@markstuart-oai

Copy link
Copy Markdown
Contributor

Summary

Change the output format for later Responses calls by adding a configuration update to input. Use parse_as to choose the Python type that reads the answer.

Changes

  • Set configuration_update.text.format to a JSON schema or to {"type": "text"}. Retrieved input items expose the same format. A reasoning-only update keeps the active format.
  • Pass parse_as to synchronous or asynchronous responses.parse(). It selects the local parser. If supplied, text_format still sets the top-level request schema.
response = client.responses.parse(
    model=model,
    previous_response_id=previous.id,
    input=[
        {"type": "configuration_update", "text": {"format": detailed_format}},
        {"role": "user", "content": "Include the evidence."},
    ],
    parse_as=AnswerWithEvidence,
)

On a later request that carries only a previous response ID and a new message, pass parse_as=AnswerWithEvidence to keep reading that type locally.

Castiron-Internal-PR: openai/openai-python-internal#365
Castiron-Source-SHA: 76f8408a2d73fd095ef2e6e849072c6033eb93ba
Castiron-Public-Base-SHA: 10f9dd0
Comment thread src/openai/resources/responses/responses.py
Comment thread src/openai/resources/responses/responses.py
Comment thread src/openai/resources/responses/responses.py
Comment thread src/openai/resources/responses/responses.py

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant