@@ -3012,33 +3012,35 @@ We offer AIProxy support so that developers can build **and** distribute apps us
30123012
30133013### How does my SwiftOpenAI code change?
30143014
3015- SwiftOpenAI supports proxying requests through AIProxy with a small change to your integration code.
3015+ SwiftOpenAI supports proxying requests through AIProxy with two changes to your Xcode project :
30163016
3017- Instead of initializing `service` with:
3017+ 1 . Instead of initializing `service` with:
30183018
30193019 let apiKey = " your_openai_api_key_here"
30203020 let service = OpenAIServiceFactory.service (apiKey : apiKey)
30213021
30223022Use:
30233023
3024- #if DEBUG && targetEnvironment (simulator)
30253024 let service = OpenAIServiceFactory.service (
30263025 aiproxyPartialKey : " hardcode_partial_key_here" ,
3027- aiproxyDeviceCheckBypass : " hardcode_device_check_bypass_here"
30283026 )
3029- #else
3030- let service = OpenAIServiceFactory.service (
3031- aiproxyPartialKey : " hardcode_partial_key_here"
3032- )
3033- #endif
30343027
3035- The `aiproxyPartialKey` and `aiproxyDeviceCheckBypass` values are provided to you on the [AIProxy developer dashboard](https :// developer.aiproxy.pro).
3028+ The `aiproxyPartialKey` value is provided to you on the [AIProxy developer dashboard](https :// developer.aiproxy.pro)
3029+
3030+ 2 . Add an `AIPROXY_DEVICE_CHECK_BYPASS' env variable to Xcode. This token is provided to you in the AIProxy
3031+ developer dashboard, and is necessary for the iOS simulator to communicate with the AIProxy backend.
3032+ - Type `cmd shift ,` to open up the " Edit Schemes" menu in Xcode
3033+ - Select `Run` in the sidebar
3034+ - Select `Arguments` from the top nav
3035+ - Add to the " Environment Variables" section (not the " Arguments Passed on Launch" section) an env
3036+ variable with name `AIPROXY_DEVICE_CHECK_BYPASS` and value that we provided you in the AIProxy dashboard
3037+
30363038
3037- ⚠️ It is important that you do not let the `aiproxyDeviceCheckBypass` token leak into a distribution
3038- build of your app (including TestFlight distributions ). Please retain the conditional compilation
3039- checks that are present in the sample code above .
3039+ ⚠️ The `AIPROXY_DEVICE_CHECK_BYPASS` is intended for the simulator only. Do not let it leak into
3040+ a distribution build of your app (including a TestFlight distribution ). If you follow the steps above,
3041+ then the constant won't leak because env variables are not packaged into the app bundle .
30403042
3041- #### What is the `aiproxyDeviceCheckBypass ` constant?
3043+ #### What is the `AIPROXY_DEVICE_CHECK_BYPASS ` constant?
30423044
30433045AIProxy uses Apple's [DeviceCheck](https :// developer.apple.com/documentation/devicecheck) to ensure
30443046that requests received by the backend originated from your app on a legitimate Apple device.
0 commit comments