Skip to content

[ResponsesAPI] return openai-defined types #1580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jul 1, 2025

PR on top of #1576.

I'm starting to think that it makes sense to define Zod schemas for inputs as we need to validate user's inputs. But that for outputs we "only" need static type checking and therefore we could reuse the types defined in https://github.com/openai/openai-node.

Benefits: no need to redefine stuff manually. It's easy to make mistakes (a parameter that shouldn't be nullable, that could be an array, etc.) when translating from the specs to our codebase. If static typing don't complain then we can assume "it's good".
Also less code to maintain.

Drawback: less flexibility. We don't own the stack and things might get updated in the wild. It's less a problem in this context as it's a server and not a client (and therefore we manage the dependency updates).

Overall I do think it's better to import from openai. Since we won't implement everything at first, it's fine to use Omit<..., "key-that-we-dont-implement"> which explicitly removes a feature (better than implicit non-definition)


EDIT: and it's fine to use them for now and if it's ever blocking in the future, then we redefine stuff ourselves.

@Wauplin
Copy link
Contributor Author

Wauplin commented Jul 1, 2025

(merging as I think it'll be beneficial but open to discussion if anyone feel strongly)

@Wauplin Wauplin merged commit 2090cf7 into responses-server Jul 1, 2025
5 checks passed
@Wauplin Wauplin deleted the use-openai-types-instead branch July 1, 2025 15:20
@Wauplin Wauplin changed the title return openai-defined type [ResponsesAPI] return openai-defined types Jul 1, 2025
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