Language Guide · Java
Manage AI Prompts in Java
No SDK required. One HTTP call.
Fetch versioned, variable-interpolated AI prompts from Java using the built-in HttpClient (Java 11+). Works with Spring Boot, Quarkus, Micronaut, and any Jakarta EE stack.
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 com.fasterxml.jackson.databind.ObjectMapper;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.uri(URI.create(
"https://www.promptforge-app.com/api/v1/prompts/YOUR_PROMPT_ID"
+ "?_version=latest&role=developer&task=review+code"
))
.header("Authorization", "Bearer YOUR_API_KEY")
.GET()
.build();
var response = client.send(
request,
HttpResponse.BodyHandlers.ofString()
);
var json = new ObjectMapper().readTree(response.body());
var content = json.get("content").asText();
// Pass content to any AI SDKWhy Java teams choose PromptForge
Designed for developers who want control without complexity.
No new Maven dependencies
java.net.http.HttpClient ships with the JDK since Java 11. If you already use Jackson for JSON, you need nothing extra in your pom.xml.
Spring-friendly by design
Inject the API key via @Value, call it from a @Service, or wire it into a RestTemplate/WebClient filter. Fits any Spring Boot architecture.
Works across every Java stack
The same HttpClient pattern works in Spring Boot, Quarkus, Micronaut, Jakarta EE, and plain main() applications without any framework coupling.
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 application.properties or an environment variable and inject with @Value.
- 4
Call with java.net.http.HttpClient
Build an HttpRequest with the Authorization header, send it synchronously or asynchronously, and parse the JSON body with Jackson. Pass the content string to your AI provider SDK.
Teams building AI features in Java
Java enterprise teams use PromptForge to give product managers direct control over AI prompts without requiring a code change or sprint ticket. The prompt lives outside the JAR — update it in the dashboard and the new version is live on the next request.
Start Free TrialStart for free, upgrade anytime
No credit card required to get started. Paid plans include a 14-day free trial.
- 1 Production Prompt
- 1,000 API Requests/mo
- Stable/Latest Channel Routing
- No Credit Card Required
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