Spring AI with Open Ai
🔄 Updated: September 2026 · Rewritten for Spring AI 2.0.1 The starter artifact, the configuration properties and the client class have all changed since 2024 Integrating OpenAI ChatGPT with Spring AI Spring AI gives Java developers a clean, Spring-idiomatic way to call OpenAI's models — chat, streaming, structured output, tool calling and embeddings — without hand-rolling HTTP clients or JSON mapping. This guide walks through the whole setup, from getting an API key to building endpoints that do real work. Contents [ hide ] Getting Started: Obtaining an OpenAI API Key You need an API key before anything else: Sign up at platform.openai.com (note: the API dashboard, not the ChatGPT consumer site). Add a payment method and some credit. API access is billed separately from a ChatGPT Plus subscription — having Plus does not give you API credit. Go to the API Keys page and create a new secret key. Copy it immediately. OpenAI shows the key...