Spring Boot

Spring Boot with an OpenAI-compatible uncensored API

Configure Spring AI's OpenAI starter for Abliterator: base-url, api-key and chat model properties, ChatClient calls, Flux streaming and @Tool methods in Spring Boot.

Reviewed Spring BootJava

Quick answer

Add spring-ai-starter-model-openai and set spring.ai.openai.base-url=https://abliterator.ai/v1, spring.ai.openai.api-key=${ABL_API_KEY} and spring.ai.openai.chat.model=kimi-k3.1-pro-abliterated. Then inject ChatClient.Builder.

Spring AI's OpenAI module talks to any Chat Completions server through three properties, as shown for DeepSeek and vLLM in the Spring AI OpenAI chat docs. This page targets Spring AI 2.1 on Spring Boot 4. No JDK was available on the machine used to check it, so the code was compared against the Spring AI source (ChatClient, OpenAiSetup, OpenAiChatProperties) instead of compiled.

Dependencies

Generate a project at start.spring.io with Spring Web and "OpenAI" under AI, or add to pom.xml:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.springframework.ai</groupId>
      <artifactId>spring-ai-bom</artifactId>
      <version>2.1.0</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
  </dependency>
  <dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-starter-model-openai</artifactId>
  </dependency>
</dependencies>

Configure Abliterator

src/main/resources/application.properties:

spring.ai.openai.base-url=https://abliterator.ai/v1
spring.ai.openai.api-key=${ABL_API_KEY}
spring.ai.openai.chat.model=kimi-k3.1-pro-abliterated
spring.ai.model.embedding=none
spring.ai.model.image=none
spring.ai.model.audio.speech=none
spring.ai.model.audio.transcription=none
spring.ai.model.moderation=none

The none lines switch off the starter's embedding, image, audio and moderation beans; Abliterator does not serve those endpoints. Export the key before starting: export ABL_API_KEY=sk-abl-v1-....

Call, stream and get typed output

package com.example.abliterator;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.util.List;

@RestController
public class SecurityController {

    private final ChatClient chat;

    public SecurityController(ChatClient.Builder builder) {
        this.chat = builder
                .defaultSystem("You are an application security engineer. Be specific and cite CWE IDs.")
                .build();
    }

    @GetMapping("/explain")
    public String explain(@RequestParam String finding) {
        return chat.prompt().user("Explain this finding and its fix: " + finding).call().content();
    }

    @GetMapping(value = "/brief", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> brief(@RequestParam(defaultValue = "SSRF") String topic) {
        return chat.prompt().user("Write a developer training brief on " + topic).stream().content();
    }

    record Triage(String severity, String cwe, List<String> fixes) {}

    @GetMapping("/triage")
    public Triage triage(@RequestParam String finding) {
        return chat.prompt().user("Triage: " + finding).call().entity(Triage.class);
    }
}

stream().content() returns a Flux<String> of text deltas, which Spring MVC writes as Server-Sent Events. entity(Triage.class) asks for JSON matching the record and maps it.

Tools with @Tool

Annotate methods and pass the object to .tools(...). Spring AI sends the schemas, runs the calls and loops until the model answers:

package com.example.abliterator;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DependencyController {

    static class AdvisoryTools {
        @Tool(description = "Look up known advisories for a Maven artifact and version")
        String advisories(@ToolParam(description = "groupId:artifactId") String artifact,
                          @ToolParam(description = "version") String version) {
            return artifact + ":" + version + " -> CVE-2026-1111 (CVSS 8.1), fixed in 2.17.3";
        }
    }

    private final ChatClient chat;

    public DependencyController(ChatClient.Builder builder) {
        this.chat = builder.build();
    }

    @GetMapping("/audit")
    public String audit(@RequestParam String artifact, @RequestParam String version) {
        return chat.prompt()
                .user("Is " + artifact + " " + version + " safe to ship? Check advisories first.")
                .tools(new AdvisoryTools())
                .call()
                .content();
    }
}

Troubleshooting

  • 404 on /v1/v1/chat/completions or /chat/completions. The base URL does not match your Spring AI line. On 2.x use https://abliterator.ai/v1; on 1.x use the origin without /v1.
  • The model name is ignored. spring.ai.openai.chat.options.model is the 1.x property and is deprecated in 2.x. Use spring.ai.openai.chat.model.
  • 401 although the key is exported. ${ABL_API_KEY} resolves at startup; the variable must be visible to the JVM process (IDE run configuration, container env, systemd unit).
  • Startup or runtime calls to /embeddings. A vector store or other starter is using the OpenAI embedding model. Keep spring.ai.model.embedding=none and configure a separate embedding provider.
  • Do not use OpenAiResponsesChatModel. It calls the Responses API, which Abliterator does not serve. The default OpenAiChatModel behind ChatClient is correct.

Frequently asked questions

Should spring.ai.openai.base-url include /v1?

On Spring AI 2.x, yes: the URL is passed unchanged to the openai-java client, which appends chat/completions. Spring AI 1.x appended /v1/chat/completions itself, so there the base URL must stop at the host.

Does @Tool work with Abliterator models?

Yes. ChatClient sends @Tool methods as standard function tools, runs the ones the model calls and returns the final answer. Both Abliterator models support tool calling.

Can I use both Abliterator models in one application?

Yes. Keep kimi-k3.1-pro-abliterated as the default in properties and override per request with .options(OpenAiChatOptions.builder().model("deepseek-v4.1-flash-abliterated")) on the prompt. In Spring AI 2.x, options() takes the builder itself, without .build().