# chatgpt-spring-boot-starter **Repository Path**: thinkopenai/chatgpt-spring-boot-starter ## Basic Information - **Project Name**: chatgpt-spring-boot-starter - **Description**: ChatGPT Spring boot starter - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 18 - **Created**: 2023-03-17 - **Last Updated**: 2023-03-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ChatGPT [![GitHub release](https://img.shields.io/github/v/release/m9d2/chatgpt)](https://github.com/m9d2/chatgpt/releases) [![Maven Central](https://img.shields.io/maven-central/v/cn.m9d2.chatgpt/chatgpt)](https://mvnrepository.com/artifact/cn.m9d2.chatgpt/chatgpt) [![GitHub license](https://img.shields.io/github/license/m9d2/chatgpt)](https://github.com/m9d2/chatgpt/blob/main/LICENSE) Java版本openai api的SDK,支持spring boot快速开始。   ## 快速使用 ### 一、引入依赖 ```xml cn.m9d2.chatgpt chatgpt {release-version} ```   ### 二、application.yml 配置 ```yaml openai: api-key: "YOUR OWNER KEY" proxy: enable: true type: http hostname: 127.0.0.1 port: 1087 connect-timeout: 10000 read-timeout: 30000 ```   ### 三、示例代码 ```java @SpringBootApplication public class SampleApplication implements ApplicationRunner { @Autowired private ChatService chatService; public static void main(String[] args) { SpringApplication.run(SampleApplication.class, args); } @Override public void run(ApplicationArguments args) throws Exception { Completions completions = new Completions(); List messages = new ArrayList<>(); Message message = new Message(); message.setContent("你好"); message.setRole("user"); messages.add(message); completions.setMessages(messages); CompletionsResponse response = chatService.completions(completions); for (CompletionsResponse.Choice choice : response.getChoices()) { System.out.print(choice.getMessage().getContent()); } } } ```   ## 鸣谢 本项目参考以下项目 [Grt1228/chatgpt-java](https://github.com/Grt1228/chatgpt-java)