Language Guide · Kotlin
Manage AI Prompts in Kotlin
No SDK required. One HTTP call.
Fetch versioned, variable-interpolated AI prompts from Kotlin using the standard java.net.http.HttpClient or OkHttp. Works with Android, Spring Boot, Ktor, and any JVM application.
Code Example
One function. Any AI provider.
Fetch a versioned, interpolated prompt from PromptForge with a single HTTP call. The returned content string passes directly to your AI SDK — no transformation, no adapter, no extra library.
- 1Fetch a versioned prompt by ID with your variable values.
- 2Receive the fully rendered content string in the response.
- 3Pass it directly to your AI provider SDK as the system prompt.
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
@Serializable
data class PromptResponse(val content: String)
suspend fun fetchPrompt(
apiKey: String,
promptId: String,
vars: Map<String, String> = emptyMap(),
): String = withContext(Dispatchers.IO) {
val params = (mapOf("_version" to "latest") + vars)
.entries.joinToString("&") { "${it.key}=${it.value}" }
val url = "https://www.promptforge-app.com/api/v1/prompts/$promptId?$params"
val request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer $apiKey")
.GET().build()
val body = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString())
.body()
Json.decodeFromString<PromptResponse>(body).content
}Why Kotlin teams choose PromptForge
Designed for developers who want control without complexity.
Coroutine-native with Dispatchers.IO
Wrap in withContext(Dispatchers.IO) for non-blocking calls in your coroutine scope. Fits naturally into Android ViewModels and Ktor route handlers.
Works for Android and server-side
The same suspend function pattern works in Android Jetpack Compose ViewModels and Spring Boot @Service beans with virtually no changes.
Full Java interop
java.net.http.HttpClient is available in every JVM 11+ environment. Swap to OkHttp or Ktor client for Android without changing the interface.
Integrate in 4 steps
From zero to fetching your first versioned prompt in under 10 minutes. No framework setup, no SDK installation — just HTTP.
- 1
Create a prompt with variables
Open the dashboard, click New Prompt, and write your system prompt using {{variable}} placeholders for any dynamic values.
- 2
Copy your prompt ID
Your prompt ID appears in the URL bar when editing: /dashboard/prompts/YOUR_PROMPT_ID. The API Usage panel also shows it with pre-filled examples.
- 3
Generate an API key
Go to the API settings page and click Generate Key. Store it in BuildConfig for Android or application.yml for Spring Boot.
- 4
Fetch with HttpClient or OkHttp
Call the endpoint inside withContext(Dispatchers.IO), deserialize with kotlinx.serialization or Gson, and pass the content string to your AI provider SDK.
Teams building AI features in Kotlin
Kotlin teams building AI-powered Android apps and Spring Boot services use PromptForge to keep system prompts editable without releasing a new APK or redeploying a service. The prompt update is a one-click dashboard action — not a commit, build, and deploy.
Start Free TrialStart for free, upgrade anytime
No credit card required to get started. Paid plans include a 14-day free trial.
- 1k API requests/month
- 1 prompt
- Unlimited versions
- Dynamic variables
- Version pinning
- API key management
No charge until your trial ends
- 10k API requests/month
- 5 prompt
- Unlimited versions
- Dynamic variables
- Version pinning
- API key management
No charge until your trial ends
- 100k API requests/month
- 25 prompt
- Unlimited versions
- Dynamic variables
- Version pinning
- API key management
No charge until your trial ends
- 500k API requests/month
- 100 prompt
- Unlimited versions
- Dynamic variables
- Version pinning
- API key management
Questions? Contact us