# chatgpt
**Repository Path**: wwwpythonpw/chatgpt
## Basic Information
- **Project Name**: chatgpt
- **Description**: ChatGPT Spring boot starter - ChatGPT Java版本SDK,开箱即用,支持Spring Boot项目快速集成
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 18
- **Created**: 2023-03-27
- **Last Updated**: 2023-03-27
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# ChatGPT
[](https://github.com/m9d2/chatgpt/releases)
[](https://mvnrepository.com/artifact/cn.m9d2.chatgpt/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());
}
}
}
```
## Spring boot示例项目
[sample-chatgpt](https://github.com/m9d2/sample-chatgpt)
## 鸣谢
本项目参考以下项目
[Grt1228/chatgpt-java](https://github.com/Grt1228/chatgpt-java)