HOST
Java
HttpClient-Transport. Spring Boot ist Controller und Thymeleaf. Das SDK braucht Spring nicht.
Java
HttpClient-Transport. Spring Boot ist Controller und Thymeleaf. Das SDK braucht Spring nicht.
ai.sveda:sveda-java-sdk mintet Embed-Tokens. POST /sveda/session in Spring Boot oder SvedaClient.startHostSession.
AGENT PROMPT
Paste into Cursor
Copy this into Cursor, Claude Code, or any coding agent. It installs Sveda against this stack using public packages.
Install Sveda into this Java project.
Read:
- https://sveda.dev/docs/hosts/java
- https://sveda.dev/docs/client
- https://sveda.dev/docs/deploy
- https://sveda.dev/llms.txt
Follow the numbered steps on the Java page. If unsure which frontend this repo uses, ask the user. 1. Run sveda-server
# ghcr.io/neresson/sveda-server:latest
# curl -fsSL https://raw.githubusercontent.com/neresson/sveda/main/deploy/compose.yaml -o compose.yaml && curl -fsSL https://raw.githubusercontent.com/neresson/sveda/main/deploy/compose.env -o .env && # Edit .env: a model key, SVEDA_EMBED_HOST_API_KEY, SVEDA_CORS_ORIGINS && && docker compose up -d && curl -s http://127.0.0.1:8787/sveda/ready
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: sveda
POSTGRES_PASSWORD: sveda
POSTGRES_DB: sveda
healthcheck:
test: ["CMD-SHELL", "pg_isready -U sveda -d sveda"]
interval: 5s
timeout: 3s
retries: 10
volumes:
- sveda-postgres:/var/lib/postgresql/data
redis:
image: redis:7-alpine
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
sveda-server:
image: ghcr.io/neresson/sveda-server:latest
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "8787:8787"
environment:
SVEDA_BIND: 0.0.0.0:8787
SVEDA_EMBED_ENABLED: "true"
SVEDA_DATABASE_URL: postgres://sveda:sveda@postgres:5432/sveda
SVEDA_REDIS_URL: redis://redis:6379
SVEDA_APP_KEY: ${SVEDA_APP_KEY:-dev-app-key-change-me}
SVEDA_ADMIN_API_KEY: ${SVEDA_ADMIN_API_KEY:-dev-admin-key-change-me}
SVEDA_EMBED_HOST_API_KEY: ${SVEDA_EMBED_HOST_API_KEY:-dev-host-key-change-me}
SVEDA_CORS_ORIGINS: ${SVEDA_CORS_ORIGINS:-*}
DEEPSEEK_API_KEY: ${DEEPSEEK_API_KEY:-}
volumes:
sveda-postgres:# ghcr.io/neresson/sveda-server:latest
# curl -fsSL https://raw.githubusercontent.com/neresson/sveda/main/deploy/compose.yaml -o compose.yaml && curl -fsSL https://raw.githubusercontent.com/neresson/sveda/main/deploy/compose.env -o .env && # Edit .env: a model key, SVEDA_EMBED_HOST_API_KEY, SVEDA_CORS_ORIGINS && && docker compose up -d && curl -s http://127.0.0.1:8787/sveda/ready
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: sveda
POSTGRES_PASSWORD: sveda
POSTGRES_DB: sveda
healthcheck:
test: ["CMD-SHELL", "pg_isready -U sveda -d sveda"]
interval: 5s
timeout: 3s
retries: 10
volumes:
- sveda-postgres:/var/lib/postgresql/data
redis:
image: redis:7-alpine
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
sveda-server:
image: ghcr.io/neresson/sveda-server:latest
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
ports:
- "8787:8787"
environment:
SVEDA_BIND: 0.0.0.0:8787
SVEDA_EMBED_ENABLED: "true"
SVEDA_DATABASE_URL: postgres://sveda:sveda@postgres:5432/sveda
SVEDA_REDIS_URL: redis://redis:6379
SVEDA_APP_KEY: ${SVEDA_APP_KEY:-dev-app-key-change-me}
SVEDA_ADMIN_API_KEY: ${SVEDA_ADMIN_API_KEY:-dev-admin-key-change-me}
SVEDA_EMBED_HOST_API_KEY: ${SVEDA_EMBED_HOST_API_KEY:-dev-host-key-change-me}
SVEDA_CORS_ORIGINS: ${SVEDA_CORS_ORIGINS:-*}
DEEPSEEK_API_KEY: ${DEEPSEEK_API_KEY:-}
volumes:
sveda-postgres: 2. Install ai.sveda:sveda-java-sdk
Java 17. Maven Central:
ai.sveda:sveda-java-sdk.
The SDK uses
java.net.http.HttpClient
— Spring is optional.
<dependency>
<groupId>ai.sveda</groupId>
<artifactId>sveda-java-sdk</artifactId>
<version>0.1.0</version>
</dependency><dependency> <groupId>ai.sveda</groupId> <artifactId>sveda-java-sdk</artifactId> <version>0.1.0</version> </dependency>
3. Env
Spring binds
sveda.client.base-url=${SVEDA_CLIENT_BASE_URL:}.
Plain Java reads the same variables.
SVEDA_CLIENT_BASE_URL=http://127.0.0.1:8787
SVEDA_CLIENT_HOST_API_KEY=replace-meSVEDA_CLIENT_BASE_URL=http://127.0.0.1:8787 SVEDA_CLIENT_HOST_API_KEY=replace-me
4. Plain Java
Map the signed-in user to a named
policy
on mint when you need capability limits —
embed policies.
SvedaClient client = SvedaClient.builder()
.baseUrl(origin)
.hostApiKey(hostApiKey)
.build();
HostSession session = SvedaClient.startHostSession(client, "java-host");SvedaClient client = SvedaClient.builder()
.baseUrl(origin)
.hostApiKey(hostApiKey)
.build();
HostSession session = SvedaClient.startHostSession(client, "java-host"); 5. Spring Boot
Map
POST /sveda/session.
Thymeleaf
th:if="${svedaEnabled}"
on buttons and the host script. Serve
sveda-host.js
from
src/main/resources/static.
@PostMapping("/sveda/session")
public ResponseEntity<?> session() {
if (!properties.isConfigured()) {
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
.body(Map.of("message", "Set SVEDA_CLIENT_BASE_URL and SVEDA_CLIENT_HOST_API_KEY"));
}
SvedaClient client = SvedaClient.builder()
.baseUrl(properties.origin())
.hostApiKey(properties.hostApiKey())
.build();
return ResponseEntity.ok(SvedaClient.startHostSession(client, "spring-playground"));
}@PostMapping("/sveda/session")
public ResponseEntity<?> session() {
if (!properties.isConfigured()) {
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
.body(Map.of("message", "Set SVEDA_CLIENT_BASE_URL and SVEDA_CLIENT_HOST_API_KEY"));
}
SvedaClient client = SvedaClient.builder()
.baseUrl(properties.origin())
.hostApiKey(properties.hostApiKey())
.build();
return ResponseEntity.ok(SvedaClient.startHostSession(client, "spring-playground"));
} 6. Page markup
<html
lang="en"
data-sveda-origin="http://127.0.0.1:8787"
data-sveda-session="/sveda/session"
>
<body>
<button type="button" data-sveda-open="js">Open JS chat</button>
<button type="button" data-sveda-open="iframe">Open iframe chat</button>
<script type="module" src="/sveda-host.js"></script>
</body>
</html><html
lang="en"
data-sveda-origin="http://127.0.0.1:8787"
data-sveda-session="/sveda/session"
>
<body>
<button type="button" data-sveda-open="js">Open JS chat</button>
<button type="button" data-sveda-open="iframe">Open iframe chat</button>
<script type="module" src="/sveda-host.js"></script>
</body>
</html>