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

Connection failed when accessing OpenAI API in Flutter desktop app on macOS #35

Closed
milkyway044 opened this issue Apr 8, 2023 · 3 comments

Comments

@milkyway044
Copy link

Getting the following error:

[OpenAI] accessing endpoint: /completions
[OpenAI] starting request to https://api.openai.com/v1/completions
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Connection failed
#0      IOClient.send
io_client.dart:88
<asynchronous suspension>
#1      BaseClient._sendUnstreamed
base_client.dart:93
<asynchronous suspension>
#2      _withClient
http.dart:164
<asynchronous suspension>
#3      OpenAINetworkingClient.post
client.dart:105
<asynchronous suspension>
#4      OpenAICompletion.create
completion.dart:118
<asynchronous suspension>

This issue is specific to the Flutter desktop macOS platform. We have tested the same API endpoint on Flutter web and it works without any issues.

@ZingerLittleBee
Copy link

maybe u should check network permission open or not on macOS
check here https://stackoverflow.com/questions/61196860/how-to-enable-flutter-internet-permission-for-macos-desktop-app

@anasfik
Copy link
Owner

anasfik commented Apr 9, 2023

@ZingerLittleBee thank you!

@milkyway044 can you check if the issue related to @ZingerLittleBee comment!

@milkyway044
Copy link
Author

@ZingerLittleBee, @anasfik fortunately, I was able to resolve the issue by adding the following key-value pair to the macos/Runner/DebugProfile.entitlements and Release.entitlements:

<key>com.apple.security.network.client</key>
<true/>

Thank you for creating such a useful package!

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

3 participants