Integration guide

Integration video

To get started you can follow the integration video, or follow the steps below.

Step 1

Create an account

To get started login or signup on the AIProxy dashboard.

Step 2

Create and configure a new project

Next create your first project. To configure your project click "Edit project settings" button and enter the required information.

Watch the video below to learn how to find your p8 file, DeviceCheck Key ID, and Apple Team ID.

Once you've filled out the required information, choose which proxy rules you want to enable and click "Save settings".

Step 3

Generate a new key

Now that your project is configured you can now create an AIProxy key by visiting the "Keys" tab in the dashboard. Enter a name and your OpenAI key and click the "Add new key" button.

Important - Do not use a key that has previously leaked in a production version of your app. You need to use a fresh, uncompromised key.
Add a new key form
Step 4

Add AIProxy to your app

Important - copy the code generated on the next screen! We do not store this information on our backend for security reasons. If you no longer have access to your aiproxyPartialKey, you will need to generate a new one.

At this point you're ready to start integrating AIProxy into your app. AIProxy is built right into SwiftOpenAI, an open-source Swift package for interacting with OpenAI's public API. Using this package is the easiest way to get set up quickly. Here's how:

  1. Add the SwiftOpenAI package to your Xcode project
  2. Initialize using the code generated on the key details screen.
Key details

If you’re not using the SwiftOpenAI package you can use the AIProxy.swift file and edit the placeholder constants with your aiproxyPartialKey and deviceCheckBypass values. For sample requests visit the Swift examples page.

Step 5

Configure Xcode for DeviceCheck

An integral layer of security for AIProxy is Apple's DeviceCheck. A successful DeviceCheck integration requires the following:

1. Your Apple developer team must be selected under the 'Signing & Capabilities' tab in Xcode

Set explicit team from Signing and Capabilities

2. The bundle identifier of your app must be explicit (i.e. it can't contain a wildcard)

Set explicit bundle identifier

3. The bundle identifier of your app must be listed as an App Identifier

Create App ID in Apple's dashboared

4. On MacOS, your signing certificate can't be set to 'Sign to Run Locally'

Do not set the option 'Sign to Run Locally'