Skip to content

[FEATURE REQ] Consider allowing instantiation of the types NOT via Json only.Β #732

@DeagleGross

Description

@DeagleGross

Describe the feature or improvement you are requesting

Hey, thanks for building this OpenAI SDK.

I am working on integration OpenAI Responses into the agent framework, and I've faced many problems operating with the OpenAI SDK types because:

  1. most of the types can be constructed only via the JSON
  2. some of the type properties are internal
  3. some of the types! are internal

My scenario is that I have an "abstract AIAgent", which can respond with OpenAI Responses, but also can respond with for example OpenAI ChatCompletions or MCP or . Its undetermenistic. Moreover, we have our own subset of types to represent the response in a generic way - for example AIContent.

  1. The biggest frustration is that I am not able to implement streaming of the response via OpenAI SDK types, because I can not instantiate the types needed (e.g. StreamingResponseCreatedUpdate and others). I had to define my own types to stream the response for that.

  2. Moreover, ResponseCreationOptions has internal fields / properties, which ARE parsed. I would like to use this type in my endpoint handler input, but I cant, and I have to write manual deserialization logic + access e.g. Stream property via reflection code. That complicates the code incredibly.

  3. Some of the types are simply internal, and without building up tons of reflection code I dont see a clear way to use them.

I really like that there is an SDK carefully defining the types per spec, but these design decisions heavily restrict SDK manipulation. I would like to suggest opening up constructors and avoid internal members. That would definitley allow easier integration. I've seen other issues (e.g. #306) asking for similar thing.

Additional context

No response

Metadata

Metadata

Assignees

Labels

area: architectureThis item is related to general architecture of the OpenAI client library.feature-requestCategory: A new feature or enhancement to an existing feature is being requested.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions