Skip to content

Mimic the Python SDK response.output_text property #129

@mergesort

Description

@mergesort

Hey @jamesrochabrun, thanks for the amazing library and the quick updates! I was just messing around with 4.0.5, and tried to replace my current usage of chat completions in a tool with the new responses API.

I noticed that the official OpenAI client has added a handy output_text property for doing what people do very often for the simplest of requests, deriving the text from a response.

This code from their Quickstart guide shows how they model this property.

from openai import OpenAI
client = OpenAI()

response = client.responses.create(
    model="gpt-4o",
    input="Write a one-sentence bedtime story about a unicorn."
)

print(response.output_text)

I think responseText would be a great computed property to have on ResponseModel, to easily provide that info for tools like mine, which ask ChatGPT for a simple text-based response.

Thanks again, I'm also using your SwiftAnthropic library in the same tool and your work is truly excellent — such a treat from the open source world!


P.S. I didn't want to file a separate issue for this but you have a stray ) in your 4.0.5 release notes.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions