MeerMost

AI in a Mobile App: How to Integrate ChatGPT

AI in a mobile app looks like one "ask the model" button, but in practice it is a server, a token counter and a plan for when the provider stops answering. Below is how to integrate ChatGPT so that the bill for requests does not grow faster than revenue, and what one request costs in real numbers. The examples come from Meerno, our app for learning words: there AI makes transcriptions, example phrases and voice, and everything below was checked against its code.

How much developing the app itself costs is calculated by the calculator: AI sits there under the "Complex: AI" features. This article covers only the integration.

Short answer

Integrating ChatGPT into an app means putting your own server between the app and OpenAI. The API key is stored on it, and it also verifies the user, counts tokens and applies limits; in the general case moderation sits on the server too. A request costs fractions of a cent: about $0.00027 on gpt-4o-mini with 1,000 input and 200 output tokens. It gets expensive with the length of history and the number of users.

The key does not live in the app

An iOS or Android build is in the hands of everyone who downloaded it. The string with the key is pulled out of it without special skills, and then other people's requests go to your bill. The Meerno app does not call OpenAI directly, and there is no OpenAI key in it: it calls our server at addresses like /proxy/ai, /proxy/translate, /proxy/tts, /proxy/stt. The Laravel backend calls OpenAI and DeepL itself.

Diagram: the app sends a request to the server, the server checks the user, the limit, the cache and moderation, and only then calls the AI provider

The server also solves three problems that a direct-from-the-app setup does not have. It knows who is asking, so it can count a limit per person. It can change the model or the prompt without releasing a new version on the App Store. And it is the only place where the real spend is visible.

A small thing that saves money: an allowlist of models. The app sends the model name to the proxy, but the server lets through only three permitted models and replaces any other with gpt-4o-mini. Without such a list, one user who tampers with the parameter runs an expensive model, while the quota deducts one unit, as for a cheap one.

Meerno screen: a translator with voice input

What a request costs

OpenAI charges for tokens: separately for input (everything you sent, including history and the system instruction) and for output (the response). A token is a piece of a word; in Russian text there are usually more tokens than words, so the same volume costs more in Russian. Below is a calculation from the price list on the official OpenAI page, checked on 10 November 2026. The token counts are taken as an example: 1,000 in and 200 out, that is, a small message with a short history.

ModelInput / output, $ per 1M tokensOne request, $100,000 requests, $
gpt-5-nano0.05 / 0.400.0001313
gpt-4o-mini0.15 / 0.600.0002727
gpt-5-mini0.25 / 2.000.0006565
gpt-4.1-mini0.40 / 1.600.0007272

The table counts one short message; real spend depends on history. If every request has to carry 4,000 tokens of conversation instead of 1,000, a request on gpt-4o-mini rises from $0.00027 to $0.00072: input grew fourfold, the total 2.7 times. That is why in the Meerno AI tutor, live in the app since version 2.2.1, the last 40 messages go to the model, and with a long conversation the 20 most recent remain, with the response capped at 200 tokens. These numbers sit in the server settings.

Count tokens from the usage field that the API itself returns. The Meerno tutor saves tokens_in and tokens_out for every message. For reasoning models, part of the output tokens goes to "thinking", and you cannot see it by eye.

A per-user limit and a daily ceiling

One user with a bot script can spend as much as a thousand ordinary ones. So there are two levels of limits.

The Meerno translator screen, chat bubbles and a stack of coins: every model answer costs money

Per person. The free plan gets a few AI messages a week, the paid plan hundreds. A guest without registration gets a one-time demo, after which the app shows registration. The counter is incremented atomically in the database and only after a successful response from the provider. An OpenAI failure does not burn the quota.

For everyone at once. Per-person limits will not catch what we did not think of in advance. Meerno has a spending switch: the server sums up the day's spending by an estimate per operation, and at 80% of the daily ceiling the free plan loses AI and the tutor, and at 100% the other paid operations go too. Paying users are not affected. The flag resets itself at the end of the UTC day, and a notification about the level change arrives in Telegram. The ceiling is changed by an environment variable without a deploy.

Cache: do not pay twice for the same thing

Frequent words are translated by thousands of different people. In Meerno, the translation of one language pair is first looked up in a cache in the database, and only misses reach DeepL. Voice synthesis is cached by the combination of text, voice, model and language. The cache remains an optimization: if the cache database is unavailable, the translation is still performed, just at a higher cost.

The rule is simple: the less uniqueness in a request, the more sense the cache makes. For chat it is almost useless, for translations, hints and voice it pays off quickly.

Moderation and the App Store rules

If the app outputs text generated by a model, or users publish something, App Review looks at guideline 1.2: a filter for objectionable content, a way to report, blocking of users, developer contact details. The rules explicitly name "apps for creating AI content". In Meerno, user dictionaries and images go through automatic moderation, the dictionaries via the OpenAI Moderation API, and there are reports and blocking of authors. This is moderation of user content, not of model answers.

The second point, which is most often forgotten, is 5.1.2(i): say where personal data goes, including third-party AI, and get explicit consent. If the app sends the user's texts to a model, the guideline applies to you too. The "app privacy" section in App Store Connect is filled in separately: it describes the data collected by you and by partners whose code is in the app. A server-side request to an AI provider is not named directly on that page, so it is better to agree on the wording before submission. Typical reasons for rejection at review are covered in the article on rejections.

Quote from App Store guideline 5.1.2(i): sharing data with third-party AI only with explicit permission

A plan for provider failure

A provider can respond with an error, slow down, raise prices or retire a model. The last one happens on a calendar. On its deprecations page OpenAI writes: the snapshot gpt-4o-mini-2024-07-18 is shut down on 14 January 2027, and developers were notified on 14 October 2026. Between the notice and the shutdown there are exactly three months. Whether this applies to the gpt-4o-mini alias, the page does not say. The Meerno code specifies exactly gpt-4o-mini, so we keep the date in mind and will test a replacement in advance.

Quote from the OpenAI deprecations page: the gpt-4o-mini-2024-07-18 snapshot is removed on January 14, 2027

What we built in:

  • The AI call is separated from the rest. Sign-in, dictionaries, words and training work in any state of AI.
  • The tutor has a switch: an environment variable turns off all its addresses without a deploy.
  • The request timeout is 30 seconds, and an error does not deduct quota.
  • The model is changed on the server: for the tutor through an environment setting, for other calls by editing the backend code. A new App Store version is not needed.

In MeerBot, our service for AI support bots, requests go through LiteLLM. Its configuration lists a fallback from another provider for the main model. Answers are built from the client's knowledge base (PDF, DOCX, website pages) through RAG: the model answers from the documents. You can try such a bot in the demo in Telegram.

Where to start

The first step is shorter than it seems: decide which one user task the AI solves, and calculate the cost of a request on it. Then a server with the key, a limit and a switch, then the cache and moderation, and only after that a nice chat interface.

You can estimate an app with AI in the calculator, and the development page has a separate item, "AI integration". If you do not have an app yet, start with the article on the stages of iOS app development. Breakdowns of such decisions appear in the Telegram channel.

Frequently asked

Can you put an OpenAI key directly in a mobile app?

No. The app is downloaded onto the devices of strangers, and a key can be pulled out of the build in an evening. After that, requests run at your expense. The key lives on your server, the app calls the server with the user's own token, and the server then calls the provider.

How much does one ChatGPT request from an app cost?

The price is counted in tokens, separately for input and output. For gpt-4o-mini, per the OpenAI price list as of 10 November 2026, that is $0.15 per million input tokens and $0.60 per million output tokens. A request of 1,000 input and 200 output tokens comes to about $0.00027. The main multiplier is the length of the conversation history you send each time.

Is moderation needed if the AI answers only the user?

Yes. If the app creates or shows AI content, App Review checks filtering of objectionable content, reporting of content, blocking of users and developer contact details (guideline 1.2 of the App Store rules). Running requests and responses through moderation on the server covers the first part. In Meerno, user dictionaries and images are moderated this way; AI answers are not checked by it.

What happens to the app if OpenAI is unavailable or retires a model?

Features without AI keep working if you designed it that way: the AI call is separated from sign-in, dictionaries and training. For model retirement the provider publishes dates in advance: per the OpenAI deprecations page, the snapshot gpt-4o-mini-2024-07-18 is shut down on 14 January 2027; whether this applies to the gpt-4o-mini alias, the page does not say. The model is changed on the server, without releasing a new app version, and the replacement is tested before that date.

What does Apple require from apps with AI?

To state clearly where personal data goes, including third-party AI, and to get explicit consent before sending it (guideline 5.1.2(i)). The privacy card in App Store Connect is filled in based on the data that you and your partners collect. If the app has accounts, account deletion is required.

All articles

Related articles

iOS App Development: The Stages and What's Inside Each One
Development

iOS App Development: The Stages and What's Inside Each One

iOS app development stages from the inside: product, UI, server, subscriptions, push notifications, and the App Store. Short how-tos for setting up each part, with Xcode and App Store Connect screenshots.

24 min read
Mobile App Support After Release: What It Includes
Development

Mobile App Support After Release: What It Includes

What mobile app support after release includes: OS updates, crashes, accounts and certificates, review replies. Apple and Google requirement dates.

7 min read
Your Own App or Happ: What to Give VPN Service Customers
Business

Your Own App or Happ: What to Give VPN Service Customers

Happ is free and installs in a minute, but it keeps getting pulled from the Russian App Store. Your own app can take months to pass review. What to give subscribers, and when.

8 min read