When a project requires allowing users to generate images from text descriptions, you try Midjourney — it produces high-quality results quickly, but there's no official API. All third-party wrappers violate Discord's terms of service. Without a clear architecture, the integration turns into a patchwork of workarounds. We've faced this many times and developed an approach: never use unofficial solutions in production, or if the client insists, do it with explicit caveats. Our certified team guarantees a reliable integration with official APIs.
Choosing the Right API for Production
Consider three main options. All have high generation quality, but stability and legal compliance differ drastically. Our 5+ years of experience with AI image generation mobile apps shows that official APIs save up to 40% on recurring costs due to cache and retry mechanisms.
| Parameter | Midjourney Proxy (useapi.net) | Flux Pro (FAL.ai) | Ideogram v2 |
|---|---|---|---|
| Quality | High (MJ v6) | High (on par with MJ v6) | High (artistic styles, excellent text) |
| Stability | Low (violates ToS, risk of ban) | High (official API, SLA) | High (official API) |
| Generation time | 60–180 sec | 5–15 sec | 10–20 sec |
| Legal compliance | Risky | Clean | Clean |
Why Flux Pro Is 12x Faster than Midjourney Proxy
For production, Flux Pro is best in class. It generates an image in 5–15 seconds, while Midjourney via proxy takes up to three minutes — a 12x difference, not counting downtime due to account blocks. Additionally, Flux Pro allows tuning inference steps, guidance scale, and ratio — flexibility Midjourney lacks. FAL.ai official documentation confirms support for both synchronous and asynchronous modes.
Integrating Flux Pro on Swift - Step-by-Step
- Sign up at FAL.ai and obtain an API key.
- Set up the network layer with authentication header.
- Send a POST request with prompt and optional parameters.
- Handle the response synchronously or asynchronously with polling.
- Display the generated image URL in the UI.
Example implementation:
struct FalFluxService {
private let baseURL = "https://fal.run/fal-ai/flux-pro"
func generate(prompt: String) async throws -> URL {
var request = URLRequest(url: URL(string: baseURL)!)
request.httpMethod = "POST"
request.setValue("Key \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let body: [String: Any] = [
"prompt": prompt,
"image_size": "square_hd",
"num_inference_steps": 28,
"guidance_scale": 3.5,
"num_images": 1,
"enable_safety_checker": true
]
request.httpBody = try JSONSerialization.data(withJSONObject: body)
let (data, _) = try await URLSession.shared.data(for: request)
let response = try JSONDecoder().decode(FalResponse.self, from: data)
return URL(string: response.images[0].url)!
}
}
Midjourney proxy: Kotlin code (if the client insists)
If the client insists on Midjourney, we use proxy services like useapi.net. Example in Kotlin:
class MidjourneyProxyService(private val apiKey: String) {
private val client = OkHttpClient.Builder()
.readTimeout(300, TimeUnit.SECONDS) // MJ generates up to 3–4 minutes
.build()
suspend fun imagine(prompt: String): String = withContext(Dispatchers.IO) {
val body = JSONObject().apply {
put("prompt", prompt)
}.toString().toRequestBody("application/json".toMediaType())
val request = Request.Builder()
.url("https://api.useapi.net/v2/jobs/imagine")
.header("Authorization", "Bearer $apiKey")
.post(body)
.build()
val response = client.newCall(request).execute()
val json = JSONObject(response.body!!.string())
json.getString("jobid")
}
suspend fun getResult(jobId: String): MidjourneyResult? = withContext(Dispatchers.IO) {
val request = Request.Builder()
.url("https://api.useapi.net/v2/jobs/?jobid=$jobId")
.header("Authorization", "Bearer $apiKey")
.get()
.build()
val response = client.newCall(request).execute()
val json = JSONObject(response.body!!.string())
when (json.optString("status")) {
"completed" -> {
val attachments = json.getJSONArray("attachments")
MidjourneyResult.Success(attachments.getJSONObject(0).getString("url"))
}
"failed" -> MidjourneyResult.Failed(json.optString("error"))
else -> null
}
}
}
Midjourney generates a 2x2 grid of images. After obtaining the result, the user can select one variant (upscale) or request variations. This requires additional API calls (/v2/jobs/button with action U1–U4 or V1–V4).
What's Included in the Work
We provide a turnkey integration with guaranteed stability:
- Selection of the optimal AI service for your tasks
- Implementation of an API client with error handling and retry logic (3 attempts, 5-second interval)
- UI for prompt input and result display (with shimmer loading animations)
- Support for upscale, variations, and gallery storage
- Documentation for usage and configuration
- Testing on real devices
- One month support after delivery
Timelines and Cost
Integration of a proxy API with polling and basic UI — 4–6 days. Flux/Ideogram with native API, upscale/variations, gallery — 10–14 days. Typical project costs start at $3,000 and can save up to 40% on API costs with caching. We evaluate your project in 1–2 days and provide a detailed estimate.
Organizing Request Queuing and Caching
Image generation is resource-intensive. To keep the app responsive, tasks are queued. On the server side, we use Redis + Bull (Node.js) or Laravel Queues (PHP): each request gets a jobId, whose status the client polls every 2–3 seconds. On success, the image URL is cached in a CDN (Cloudflare R2 or S3) so repeated requests for the same prompt are delivered instantly without a paid API call. On the mobile client, we show a shimmer loading animation — the user sees the process is ongoing. A 5-minute timeout with automatic retry 3 times ensures resilience against temporary AI service failures. This approach reduces API load and saves up to 40% of the budget with an active user base. Additionally, we implement a generation history storage — users can return to previous prompts and reuse successful results without another API call. History is stored locally in CoreData (iOS) or Room (Android) and synchronized with the server via background sync, providing offline access to generations. Our certified developers guarantee a robust and scalable solution.
Our Experience and Expertise
We have been in mobile development for over 5 years and have delivered more than 50 projects integrating AI services. Our portfolio includes apps with image generation, natural language processing, and computer vision. Deep understanding of both client and server sides ensures a reliable solution. We provide a one-month support guarantee and full documentation.
If you need AI image generation in your mobile app, get a consultation or send a technical specification for evaluation. Contact us — we'll evaluate your project in 1–2 days.







