<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/spring-ai-tutorial-01---chat-with-openai-xikccn2m7" -->

---
title: Spring AI Tutorial : 01 - Chat with OpenAI | daily.dev
description: A hands-on walkthrough of building a Spring Boot application with Spring AI to chat with OpenAI models. Covers creating an OpenAI API key, setting it as an...
canonical: https://daily.dev/posts/spring-ai-tutorial-01---chat-with-openai-xikccn2m7
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Spring AI Tutorial : 01 - Chat with OpenAI | daily.dev
og:description: A hands-on walkthrough of building a Spring Boot application with Spring AI to chat with OpenAI models. Covers creating an OpenAI API key, setting it as an...
og:url: https://daily.dev/posts/spring-ai-tutorial-01---chat-with-openai-xikccn2m7
og:image: https://api.daily.dev/og/posts/xIKcCN2m7.png
og:image:alt: Spring AI Tutorial : 01 - Chat with OpenAI
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Spring AI Tutorial : 01 - Chat with OpenAI

**[SivaLabs \(YouTube\)](https://daily.dev/sources/sivalabs-youtube)** · 10 min read · 0 upvotes · 0 comments

## Summary

A hands-on walkthrough of building a Spring Boot application with Spring AI to chat with OpenAI models. Covers creating an OpenAI API key, setting it as an environment variable, generating a Spring Boot project via Spring Initializr with the OpenAI starter, configuring base URL, API key, model (GPT5), and temperature, and building a simple REST chat controller using ChatClient. Also shows how to enable a logging advisor to inspect requests and responses sent to the LLM.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=djb3KRV-cno>

## Questions this post answers

### How do I configure Spring AI to use the GPT-5 model with OpenAI in a Spring Boot application?

Configure the OpenAI base URL, API key, chat model, and temperature properties in the Spring Boot application configuration, referencing an environment variable for the API key. Specify gpt-5 as the chat model name. Note that GPT-5 only supports a temperature value of 1, unlike older models such as GPT-4 which accept other temperature values.

_daily.dev surfaces practical Spring AI configuration guidance for developers wiring OpenAI into Spring Boot apps._

### How can I log the requests and responses Spring AI sends to OpenAI's chat models?

Inject Spring AI's built-in SimpleLoggingAdvisor into the ChatClient and enable debug logging for org.springframework.ai.chat.client.advisor. This logs the full chat client request, including the user prompt, model name, and temperature, as well as the response details such as token usage and model metadata, not just the extracted text.

_Developers debugging LLM request and response behavior can track Spring AI advisor techniques via daily.dev._

## Similar posts on daily.dev

- [Spring AI tutorial: Get started with Spring AI](https://daily.dev/posts/spring-ai-tutorial-get-started-with-spring-ai-phjfbwkwg) · InfoWorld · 0 upvotes · 0 comments
- [Introduction to Google GenAI Chat and Spring AI](https://daily.dev/posts/introduction-to-google-genai-chat-and-spring-ai-h3wj5zlvx) · Baeldung · 1 upvotes · 0 comments
- [Spring AI Series](https://daily.dev/posts/spring-ai-series-j7w3rmryb) · Baeldung · 4 upvotes · 0 comments
- [Local AI Models with LM Studio and Spring AI](https://daily.dev/posts/local-ai-models-with-lm-studio-and-spring-ai-eo7mw3wk4) · Piotr Minkowski TechBlog · 0 upvotes · 0 comments

---

Tags: [#llm](https://daily.dev/tags/llm), [#java](https://daily.dev/tags/java), [#openai](https://daily.dev/tags/openai), [#spring-boot](https://daily.dev/tags/spring-boot), [#spring-ai](https://daily.dev/tags/spring-ai)

[View this post on daily.dev](https://daily.dev/posts/spring-ai-tutorial-01---chat-with-openai-xikccn2m7)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Spring AI Tutorial : 01 - Chat with OpenAI","url":"https://daily.dev/posts/spring-ai-tutorial-01---chat-with-openai-xikccn2m7","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/spring-ai-tutorial-01---chat-with-openai-xikccn2m7"},"datePublished":"2026-09-27T07:26:37.324Z","dateModified":"2026-09-27T07:53:18.326Z","description":"A hands-on walkthrough of building a Spring Boot application with Spring AI to chat with OpenAI models. Covers creating an OpenAI API key, setting it as an...","image":"https://i.ytimg.com/vi/djb3KRV-cno/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/djb3KRV-cno/sddefault.jpg","isAccessibleForFree":true,"articleSection":"SivaLabs (YouTube)","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"SivaLabs (YouTube)","logo":"https://media.daily.dev/image/upload/s--8ATVo4an--/f_auto,q_auto/v1790493987/logos/sivalabs-youtube?_a=BAMAMicg0","url":"https://daily.dev/sources/sivalabs-youtube"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/spring-ai-tutorial-01---chat-with-openai-xikccn2m7","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"llm,java,openai,spring-boot,spring-ai","timeRequired":"PT10M","video":{"@type":"VideoObject","name":"Spring AI Tutorial : 01 - Chat with OpenAI","description":"A hands-on walkthrough of building a Spring Boot application with Spring AI to chat with OpenAI models. Covers creating an OpenAI API key, setting it as an...","thumbnailUrl":"https://i.ytimg.com/vi/djb3KRV-cno/sddefault.jpg","uploadDate":"2026-09-27T07:26:37.324Z","duration":"PT10M","url":"https://api.daily.dev/r/xIKcCN2m7","embedUrl":"https://www.youtube.com/embed/djb3KRV-cno"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"SivaLabs (YouTube)","item":"https://daily.dev/sources/sivalabs-youtube"},{"@type":"ListItem","position":3,"name":"Spring AI Tutorial : 01 - Chat with OpenAI"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/spring-ai-tutorial-01---chat-with-openai-xikccn2m7#faq","mainEntity":[{"@type":"Question","name":"How do I configure Spring AI to use the GPT-5 model with OpenAI in a Spring Boot application?","acceptedAnswer":{"@type":"Answer","text":"Configure the OpenAI base URL, API key, chat model, and temperature properties in the Spring Boot application configuration, referencing an environment variable for the API key. Specify gpt-5 as the chat model name. Note that GPT-5 only supports a temperature value of 1, unlike older models such as GPT-4 which accept other temperature values. daily.dev surfaces practical Spring AI configuration guidance for developers wiring OpenAI into Spring Boot apps."}},{"@type":"Question","name":"How can I log the requests and responses Spring AI sends to OpenAI's chat models?","acceptedAnswer":{"@type":"Answer","text":"Inject Spring AI's built-in SimpleLoggingAdvisor into the ChatClient and enable debug logging for org.springframework.ai.chat.client.advisor. This logs the full chat client request, including the user prompt, model name, and temperature, as well as the response details such as token usage and model metadata, not just the extracted text. Developers debugging LLM request and response behavior can track Spring AI advisor techniques via daily.dev."}}]}
```

