Spring AI Configuration
This is a configuration fragment for org.springframework.ai:spring-ai-openai:1.1.8, not a complete Spring Boot application. Use the complete Java HTTP example for a standalone request without framework setup, or the OpenAI quickstart for a pinned SDK program.
Spring AI adds its configured completions path to the base. Keep the base at /proxy/openai and the path at /v1/chat/completions. The explicit OpenAiApi builder below passes the service header to both its blocking and streaming clients. Wire this instance into your application's chat model; a generic RestClient.Builder bean alone does not ensure the auto-configured model uses it.
import org.springframework.ai.openai.api.OpenAiApi;
import org.springframework.util.LinkedMultiValueMap;
var headers = new LinkedMultiValueMap<String, String>();
headers.add("Makas-Api-Key", System.getenv("MAKAS_API_KEY"));
var api = OpenAiApi.builder()
.baseUrl("https://eu.makas.ai/proxy/openai")
.completionsPath("/v1/chat/completions")
.apiKey(System.getenv("OPENAI_API_KEY"))
.headers(headers)
.build();
Run on Java 21 with Spring AI 1.1.8 resolved through your build. Keep credentials in server environment variables. The provider key becomes native OpenAI authorization; the separate Makas-Api-Key authenticates the regional Makas account. Configure a bounded output length and request timeout in the calling application.
The builder methods and path composition are documented in the pinned official Spring AI source. New Spring AI major versions may have different configuration. For buffered metadata and streaming terminal verification, see response headers.