GigaChat API Integration into Mobile App

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
GigaChat API Integration into Mobile App
Medium
~3-5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

GigaChat API Integration in Mobile Applications

GigaChat from Sber is an OpenAI alternative for the Russian market with several specific features: OAuth 2.0 authorization via https://ngw.devices.sberbank.ru:9443/api/v2/oauth, custom multipart request format for working with images, and ability to operate within closed loop without sending data abroad. The last point is critical for fintech and medical apps.

Authorization: Common Pitfalls

GigaChat OAuth token lives 30 minutes. First trap — storing token directly in mobile app and obtaining it there. Client Secret for GigaChat can't be embedded in APK or IPA — same reasons as any service key. Mandatory scheme: backend stores credentials and refreshes token, mobile client works through proxying API.

Sber's certificate for ngw.devices.sberbank.ru isn't included in standard Android and iOS trust stores. On first integration this causes SSLHandshakeException / URLError.serverCertificateUntrusted without clear message. Solution — either Certificate Pinning with Sber CA added, or proxying through own domain with valid TLS.

// Android: OkHttp with custom TrustManager for Sber certificate
val sberCertStream = context.assets.open("sber_ca.crt")
val cf = CertificateFactory.getInstance("X.509")
val sberCert = cf.generateCertificate(sberCertStream)

val keyStore = KeyStore.getInstance(KeyStore.getDefaultType()).apply {
    load(null, null)
    setCertificateEntry("sber", sberCert)
}
val tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()).apply {
    init(keyStore)
}
val sslContext = SSLContext.getInstance("TLS").apply {
    init(null, tmf.trustManagers, null)
}
val client = OkHttpClient.Builder()
    .sslSocketFactory(sslContext.socketFactory, tmf.trustManagers[0] as X509TrustManager)
    .build()

Working with API: Request Format

GigaChat supports OpenAI-compatible format (/chat/completions), simplifying logic porting from GPT-4. Difference is in model parameter: use GigaChat, GigaChat-Plus, GigaChat-Pro.

// iOS: request to GigaChat through proxying backend
struct GigaChatMessage: Codable {
    let role: String
    let content: String
}

struct GigaChatRequest: Encodable {
    let model: String
    let messages: [GigaChatMessage]
    let stream: Bool
    let temperature: Double
}

let request = GigaChatRequest(
    model: "GigaChat",
    messages: [
        GigaChatMessage(role: "system", content: systemPrompt),
        GigaChatMessage(role: "user", content: userInput)
    ],
    stream: true,
    temperature: 0.7
)

Streaming mode returns Server-Sent Events — handling similar to YandexGPT: parse data: lines via URLSessionDataDelegate on iOS or EventSource on Android.

Mobile UX Considerations

GigaChat can work with images (GigaChat-Pro). Upload via multipart POST to /files returns file_id, passed in message as attachment. For mobile app this means: first upload photo, get id, then send to chat — two separate requests.

Token limits: GigaChat — 8k, GigaChat-Pro — 32k. On mobile client, truncate conversation history to reasonable message count (10–15 recent), otherwise input context fills quickly.

Implementation Process

Design proxy service with OAuth token management and automatic refresh. Resolve SSL issue (Sber CA or own domain). Choose model for scenario. Integrate streaming chat into mobile app with typical bubble UI. Test Russian language answer quality — GigaChat excels at business communication and financial text.

Timeline Guidelines

Setup authorization and basic requests — 2–3 days. Full chat with history, streaming generation, and image handling — 6–10 days.