# hello-ai **Repository Path**: fq1995/hello-ai ## Basic Information - **Project Name**: hello-ai - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-06-26 - **Last Updated**: 2026-07-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Hello AI · Spring AI + 智谱 GLM 第一个 AI 应用,跑通 Spring AI 调用智谱 GLM。 ## 快速开始 ### 1. 配置 API Key 设置环境变量 `ZHIPU_API_KEY`: **Windows(系统环境变量)**: ``` 控制面板 → 系统 → 高级系统设置 → 环境变量 → 新建 变量名: ZHIPU_API_KEY 变量值: 你的智谱APIKey ``` **IDEA 启动配置(推荐,只对本项目生效)**: ``` Run → Edit Configurations → Environment Variables ZHIPU_API_KEY=你的智谱APIKey ``` **命令行临时(当前会话有效)**: ```bash export ZHIPU_API_KEY=你的智谱APIKey mvn spring-boot:run ``` ### 2. 启动项目 IDEA 里打开项目 → 等待 Maven 拉依赖 → 运行 `HelloAiApplication` 主类。 或命令行: ```bash mvn spring-boot:run ``` ### 3. 测试接口 浏览器打开: ``` http://localhost:8080/ai/hello?message=你好,请用一句话介绍自己 ``` 或命令行: ```bash curl "http://localhost:8080/ai/hello?message=用Java写一个冒泡排序" ``` ## 技术栈 - Spring Boot 3.3.5 - Spring AI 1.0.0 - 智谱 GLM(glm-4-flash) ## 常见问题 | 问题 | 解决 | |------|------| | `401 Unauthorized` | 检查 API Key 是否正确、环境变量是否生效 | | `404 Not Found` | base-url 必须是 `https://open.bigmodel.cn/api/paas/v4` | | `Cannot resolve spring-ai` | 已配 Spring Milestones 仓库,等待 Maven 同步 | | 启动报错找不到 bean | 检查 pom.xml 里 spring-ai-starter-model-openai 是否加了 |