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

Emoji in message causes API failure #245

Open
aashishkapur opened this issue Feb 27, 2025 · 0 comments
Open

Emoji in message causes API failure #245

aashishkapur opened this issue Feb 27, 2025 · 0 comments

Comments

@aashishkapur
Copy link

        openAIClient := openai.NewClient(openaioption.WithAPIKey(......))

	st := `🏴󠁧󠁢󠁷󠁬󠁳󠁿 Welsh`
	params := &openai.ChatCompletionNewParams{
		Model:    openai.F(openai.ChatModelGPT4o2024_11_20),
		Messages: openai.F([]openai.ChatCompletionMessageParamUnion{openai.SystemMessage(st)}),
	}

	resp, err := openAIClient.Chat.Completions.New(ctx, *params)
	if err != nil {
		log.Fatal(err)
	}

produces

POST "https://api.openai.com/v1/chat/completions": 400 Bad Request {
    "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
    }
}

The SDK doesn't appear to handle this edge case - it seems to handle other emojis just fine.

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

No branches or pull requests

1 participant