HOST
Java
HttpClient transport. Spring Boot is a controller and Thymeleaf. The SDK does not need Spring.
1. Run sveda-server
export SVEDA_EMBED_ENABLED=true
export SVEDA_BIND=0.0.0.0:8787
export SVEDA_EMBED_HOST_API_KEY=replace-me
export SVEDA_CORS_ORIGINS=http://127.0.0.1:8000
export DEEPSEEK_API_KEY=sk-...
sveda-server 2. Install ai.sveda:client
Java 17. Install the sibling module into the local Maven repo, then depend on it. The SDK uses
java.net.http.HttpClient
— Spring is optional.
mvn -f sveda-java/pom.xml install <dependency>
<groupId>ai.sveda</groupId>
<artifactId>client</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-me 4. Plain Java
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"));
} 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>