Skip to content
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

feat(openai): Responses API #256

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mattmcdev
Copy link
Contributor

@mattmcdev mattmcdev commented Mar 12, 2025

This change migrates OpenAI from /chat/completions to the new Responses API.

I believe it is (almost) non-breaking, and the only newly introduced features are support for the new previous_response_id argument and truncation argument when passed in providerMeta.

The only breaking change - the callId property of ToolCall I've renamed to id because OpenAI now requires both an id and call_id for tool calling, so it was that or something like callCallId. To avoid making this breaking, perhaps setting callId equal to id when it's not provided ?

I also changed the providerMeta function in HasProviderMeta to return null when the valuePath can't be found. I assume it's meant to return the entire object when valuePath is null, which it still does with this change. Before it also returned the entire object when valuePath was set but the path returned null - I couldn't see anywhere that seemed to want that behaviour - maybe it was a bug ?

Why this change ? As well as supporting the previous_response_id to help easily keep context in long threads, the Responses API is also their recommended option for new users.

⚠️ Tests are currently failing because I've not updated the streaming fixtures - if you're happy with this proposed change I'll get those updated to the new format and document previous_response_id

@mattmcdev mattmcdev force-pushed the feat-openai-responses branch 5 times, most recently from cb174a9 to 33c4b11 Compare March 12, 2025 12:46
@sixlive
Copy link
Contributor

sixlive commented Mar 12, 2025

I'll take a closer look at this later today. I haven't done any research on the responses API yet.

@mattmcdev
Copy link
Contributor Author

mattmcdev commented Mar 12, 2025

I'll take a closer look at this later today. I haven't done any research on the responses API yet.

Thank you - I think there's other provider metadata that could be supported, but wanted to keep this mainly focused on switching to the Responses API and then build upon that. Just added previous_response_id and truncation because they're an immediate fix for a chat thread length issue I've been having !

@mattmcdev mattmcdev force-pushed the feat-openai-responses branch from 33c4b11 to 7e8347b Compare March 12, 2025 14:16
@mattmcdev mattmcdev force-pushed the feat-openai-responses branch from 7e8347b to 855d18b Compare March 14, 2025 09:59
Copy link

kinsta bot commented Mar 14, 2025

Preview deployments for prism ⚡️

Status Branch preview Commit preview
❌ Failed to deploy N/A N/A

Commit: 04a0aff955203c9bfba5f6b15db4e1a242355f05

Deployment ID: fb34d344-5f3b-409f-85e3-056bd7c42845

Static site name: prism-97nz9

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.

2 participants