Frontier · mobile

Use Gemini 2.5 Pro Preview with Kotlin (Android)

Updated 2026-05-21 · By XALEN

How to use Gemini 2.5 Pro Preview (Frontier, ~1.5T) with Kotlin (Android). Install, authenticate, and make your first API call in minutes. Working code example included.

Model
Gemini 2.5 Pro Preview
~1.5T · 2M context · $0.07 input
Framework
Kotlin (Android)
mobile · implementation("com.squareup.okhttp3:okhttp:4.12.0")

1. Install

implementation("com.squareup.okhttp3:okhttp:4.12.0")

2. Code

import okhttp3.*
import org.json.JSONObject

suspend fun chat(question: String): String {
    val client = OkHttpClient()
    val body = JSONObject()
        .put("model", "gemini-2-5-pro-preview")
        .put("messages", org.json.JSONArray()
            .put(JSONObject().put("role", "user").put("content", question)))
    val request = Request.Builder()
        .url("https://api.xalen.io/v1/chat/completions")
        .addHeader("Authorization", "Bearer xln_test_YOUR_KEY")
        .post(body.toString().toRequestBody("application/json".toMediaType()))
        .build()
    val response = client.newCall(request).execute()
    val json = JSONObject(response.body!!.string())
    return json.getJSONArray("choices").getJSONObject(0)
        .getJSONObject("message").getString("content")
}

Gemini 2.5 Pro Preview with Other Frameworks

Python JavaScript React Next.js Flask FastAPI Django Express.js

Other Models with Kotlin (Android)

Vedika Standard Vedika Fast Vedika Pro Ultra Vedika Vision Vedika Code Vedika Astro Agent

200+ models. One API. Works with any framework.

Get API Key

Last updated: 2026-05-21