-
Notifications
You must be signed in to change notification settings - Fork 837
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
Using Structured Outputs throws body used already for: https://api.openai.com/v1/chat/completions
in 4.59.0
#1102
Labels
bug
Something isn't working
Comments
Looking at a comparison with This seems like the most likely candidate: #1058 |
Thanks for the report @jreidgreer, I can't reproduce this, could you share more details about how you're using the SDK? Here's the snippet I used to try to reproduce import { zodResponseFormat } from 'openai/helpers/zod';
import OpenAI from 'openai/index';
import { z } from 'zod';
const Step = z.object({
explanation: z.string(),
output: z.string(),
});
const MathResponse = z.object({
steps: z.array(Step),
final_answer: z.string(),
});
const client = new OpenAI();
async function makeRequest() {
const completion = await client.beta.chat.completions.parse({
model: 'gpt-4o-2024-08-06',
messages: [
{ role: 'system', content: 'You are a helpful math tutor.' },
{ role: 'user', content: 'solve 8x + 31 = 2' },
],
response_format: zodResponseFormat(MathResponse, 'math_response'),
});
console.dir(completion, { depth: 5 });
const message = completion.choices[0]?.message;
if (message?.parsed) {
console.log(message.parsed.steps);
console.log(`answer: ${message.parsed.final_answer}`);
}
}
async function main() {
await makeRequest();
await makeRequest();
}
main(); |
@jreidgreer can you share a stackblitz or equivalent that reproduces the bug? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Confirm this is a Node library issue and not an underlying OpenAI API issue
Describe the bug
Since
4.59.0
, using structured outputs with Zod causes the following error:To Reproduce
You can reproduce by using the chat completions endpoint with structured outputs. I haven't tried this without Zod.
Using
this.client.chat.completions.create
withresponse_format: { type: "json_object" }
works just fine.This is a regression introduced in
v4.59.0
Code snippets
No response
OS
macOS
Node version
v20.13.1
Library version
4.59.0
The text was updated successfully, but these errors were encountered: