Open AI integration overview

Change Log

June 11, 2024

  • Added support of DALL·E 2 and DALL·E 3.

February 28, 2024

September 15, 2023

  • Added support of new OpenAI endpoints: v1/images/edits, v1/images/variations.

August 23, 2023

  • Added support of new OpenAI endpoints: v1/images/generations, v1/audio/transcriptions, v1/audio/translations.
  • New rate limits for GPT-4 model. Users can only send messages with up to 1,600 tokens and a maximum of 4 messages per minute.

We encourage AI apps to join Setapp. Most AI apps depend on OpenAI, meaning each user must have their own OpenAI keys. This implies that a user must visit the OpenAI website, register, get the key, and know where to use it. The procedure is not obvious and not easy for average users, but we know how to simplify it and invite more people to use your AI app.

Setapp can be used as a “proxy” between your app and OpenAI. There is no need to generate an OpenAI key for each user —— your app can use Setapp OpenAI key to access OpenAI. In other words, we receive a full request from your app, so add our OpenAI key and forward it.

How to integrate your AI app into Setapp

  1. Integrate Setapp Framework into your Mac app.
  2. Integrate our Vendor API Authorization with your back-end.
  3. Integrate our OpenAI API with your back-end.
  4. Replace client calls to OpenAI with requests for your back end.

This is an example of your request:

curl -X POST \ 
  -H 'OpenAIPath: v1/chat/completions' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d requestBody

Where:

  • OpenAIPath header contains the desired OpenAI endpoint (ex. v1/chat/completions)
  • Authorization header contains a Bearer access token received from the Vendor API Authorization flow with ai.openai scope
  • requestBody is your regular request body for OpenAI API, for example:
{  
  "model": "gpt-3.5-turbo",  
  "messages": [  
    {  
      "role": "system",  
      "content": "You are a helpful assistant."  
    },  
    {  
      "role": "user",  
      "content": "Hello!"  
    }  
  ]  
}

Find more examples of requests in OpenAI API documentation.

Main specs of API:

  • The API endpoint is available for app developers as https://vendor-api.setapp.com/resource/v1/ai/openai
  • Full API endpoint specification: https://docs.setapp.com/reference/post_ai-openai
  • Available OpenAI endpoints:
    • 'v1/chat/completions'
    • 'v1/completions'
    • 'v1/embeddings'
    • 'v1/images/generations'
    • 'v1/images/edits'
    • 'v1/images/variations'
    • 'v1/audio/transcriptions'
    • 'v1/audio/translations'
  • Use POST request with access token received from the current auth flow and full OpenAI request body (without OpenAI key).
  • Endpoint has its own scope ai.openai
  • If a user wants to use their own OpenAI key, you should make requests directly to OpenAI; Setapp's endpoint won't accept such requests.
  • The API endpoint has the following limits:
    • 4 req/minute/user and 75 req/day/user for GPT-4.
    • 10000 req/hour/user and 10000 req/day/user for embedding models.
    • 100 req/hour/user and 200 req/day/user for all other models.
    • 1600 or 16000 tokens input size, depending on the subscription plan.
  • Available responses:
    • 200 — Successful request.
    • 400 — Bad request. It's an issue with the request body or the OpenAI path header.
    • 401 — Request unauthorized. Check your access token.
    • 403 — Access is forbidden. Check your access token scope.
    • 429 — Too many requests. Try again later.
    • 500 — Unexpected server error. Try again later or contact the Setapp team.

How to integrate DALL·E in Setapp and calculate a fee

You can integrate the DALL·E model into your AI app and include it in your Setapp version app. Setapp now supports DALL·E 2 and DALL·E 3 alongside GPT-4o.

See OpenAI pricing when calculating your expenses.

API description

See the relevant API description on the OpenAI website.

Use this endpoint for image generation in Setapp, similar to the case described in How to integrate your app into Setapp. There, you can define the image model, the number of images, and their size.