spring-projects / spring-ai

An Application Framework for AI Engineering
https://docs.spring.io/spring-ai/reference/index.html
Apache License 2.0
3.25k stars 829 forks source link

spring-ai-qianfan unknown client id #1438

Open huashuiwujiale opened 1 month ago

huashuiwujiale commented 1 month ago

Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create. If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description 按照springai官网的配置接入qianfan(spring-ai-qianfan-spring-boot-starter),调用以下接口报错 401 Unauthorized: "{"error_description":"unknown client id","error":"invalid_client"}"

我知道请求中缺少client id,但是不知道在哪里进行配置

Environment @GetMapping("/ai/generate") public Map generate(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) { return Map.of("generation", chatClient.call(message)); }

Steps to reproduce Steps to reproduce the issue.

Expected behavior A clear and concise description of what you expected to happen.

Minimal Complete Reproducible example Please provide a failing test or a minimal complete verifiable example that reproduces the issue. Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.

mxsl-gr commented 1 month ago

the client id is your app api key, check you application on: https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application/v1

you can create an app, get the api key and secret key.

mxsl-gr commented 1 month ago

and config the application.yml file, like this:

spring:
  ai:
    qianfan:
      apiKey: {your app api key}
      secretKey: {your app secret key}