You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Control escape characters (like u+001b) sent in the request cause a 400 bad request error.
�package main
import (
"context""github.com/openai/openai-go"
)
funcmain() {
client:=openai.NewClient()
model:="gpt-4o-mini"ctx:=context.Background()
messages:= []openai.ChatCompletionMessageParamUnion{
openai.SystemMessage("You are an AI model"),
openai.UserMessage("Hello\x1BWorld"),
}
params:= openai.ChatCompletionNewParams{
Messages: openai.F(messages),
Model: openai.String(model),
}
chatCompletion, err:=client.Chat.Completions.New(ctx, params)
iferr!=nil {
panic(err.Error())
}
println(chatCompletion.Choices[0].Message.Content)
}
panic: POST"https://api.openai.com/v1/chat/completions": 400BadRequest {
"error": {
"message": "We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
This is handled gracefully on the sashabaranov/go-openai library
Thanks!
The text was updated successfully, but these errors were encountered:
Control escape characters (like u+001b) sent in the request cause a 400 bad request error.
This is handled gracefully on the sashabaranov/go-openai library
Thanks!
The text was updated successfully, but these errors were encountered: