• API 功能

    • RAG 智能体,强大的 AI 问答能力,支持高校基础信息查询、招生政策解读、专业介绍与选择建议等;
    • 支持招生政策解读、报考指南与志愿填报建议;
    • 支持多轮对话,通过 session_id 保持对话上下文;
    • 支持知识库检索(RAG),可指定检索范围;
    • 支持流式输出(SSE),实时返回 AI 生成内容;
    • 支持多种请求方式:JSON、Form、Query String;
    • 全接口支持 HTTPS(TLS v1.0 / v1.1 / v1.2 / v1.3);
    • 全面兼容 Apple ATS;
    • 全国多节点 CDN 部署;
    • 接口极速响应,多台服务器构建 API 接口负载均衡。
    • 接口调用状态与状态监控
  • API 文档

    接口地址: https://api.gugudata.com/ai/gaokao/chat

    返回格式: application/json; charset=utf-8

    请求方式: POST

    请求协议: HTTPS

    请求示例: https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY

    数据预览: https://www.gugudata.com/preview/gaokao-chat

    接口测试:  https://api.gugudata.com/ai/gaokao/chat/demo

    OpenAPI: https://www.gugudata.com/openapi/gugudata.openapi.3.1.json

    请求参数(POST 请求参数以 application/x-www-form-urlencoded 格式、文件流以 formdata 格式传递,具体可参见下方示例代码)

    参数名 参数类型 是否必须 默认值 备注
    appkey string YOUR_APPKEY 付费后获取的 APPKEY,可通过 Query 参数或 JSON body 传入
    prompt string 你好,请介绍一下你自己 用户输入的问题,支持通过 JSON body 或 Form 参数传入
    session_id string 会话ID,用于多轮对话。首次请求可不传,系统会自动生成并返回;后续请求使用返回的 session_id 可保持对话上下文
    streaming string false 是否启用流式输出(true/false),流式输出采用 SSE (Server-Sent Events) 格式,可通过 Query 参数或 JSON body 传入

    返回参数

    参数名 参数类型 备注
    DataStatus.StatusCode integer 接口返回状态码,100 表示成功
    DataStatus.StatusDescription string 接口返回状态说明
    DataStatus.ResponseDateTime string 接口数据返回时间
    DataStatus.DataTotalCount integer 此条件下的总数据量,一般用于分页计算
    Data.text string 回复的文本内容
    Data.session_id string 会话ID,用于多轮对话。首次请求会自动生成,后续请求使用此 ID 可保持对话上下文
    Data.finish_reason string 完成原因,通常为 'stop' 表示正常完成
    Data.request_id string 请求ID,用于追踪和调试
  • 接口 HTTP 响应标准状态码

    状态码 状态码解释 备注
    200 接口正常响应 请求成功,业务状态请结合响应体中的自定义业务码判断。
    400 请求参数错误 请求参数缺失、格式错误或参数组合不合法。
    401 鉴权失败 缺少 appkey 或 appkey 无效。
    403 无权限访问 订单到期、权限不足或接口额度不可用。
    404 资源不存在 请求路径不存在。
    405 请求方法不允许 当前路径不支持该 HTTP 方法。
    415 请求内容类型不支持 上传或请求体的内容类型不符合接口要求。
    429 请求频率受限 一般建议同一个 IP 每秒请求不超过 5 次 (QPS<=5),我们不限制同一个 key 的请求总次数,但当单位时间内同一个 IP 请求次数过多,或 AI CDN 判定为恶意抓取数据、流量攻击等异常时,CDN 会返回此状态码,请适当降低请求频率。如有特殊大并发请求场景需求,可联系我们添加白名单处理。
    500 服务内部错误 服务端处理异常,请稍后重试。
    502 上游依赖错误 上游依赖服务不可用或返回异常。
  • 接口自定义状态码

    自定义状态码 自定义状态码解释 备注
    100 正常返回
    101 参数错误 请检查传递的参数是否完整,prompt 和 appkey 为必填参数
    102 请求频率受限 一般建议同一个 IP 每秒请求不超过 5 次 (QPS<=5),我们不限制同一个 key 的请求总次数,但当单位时间内同一个 IP 请求次数过多,或 AI CDN 判定为恶意抓取数据、流量攻击等异常时,CDN 会返回此状态码,请适当降低请求频率。如有特殊大并发请求场景需求,可联系我们添加白名单处理。
    103 账号欠费
    104 APPKEY 错误 请检查传递的 APPKEY 是否为开发者中心获取到的值
    110 接口响应错误 阿里云百炼智能体调用失败,请稍后重试
  • 请求示例代码
    curl --location --request POST 'https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data-urlencode 'prompt=你好,请介绍一下你自己' \
    --data-urlencode 'session_id=' \
    --data-urlencode 'streaming=false'
    #include <curl/curl.h>
    
    int main(void) {
      CURL *curl = curl_easy_init();
      if (curl) {
        curl_easy_setopt(curl, CURLOPT_URL, "https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY");
        curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
        curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
        struct curl_slist *headers = NULL;
        headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "prompt=%e4%bd%a0%e5%a5%bd%ef%bc%8c%e8%af%b7%e4%bb%8b%e7%bb%8d%e4%b8%80%e4%b8%8b%e4%bd%a0%e8%87%aa%e5%b7%b1&session_id=&streaming=false");
        CURLcode res = curl_easy_perform(curl);
        (void)res;
        curl_slist_free_all(headers);
        curl_easy_cleanup(curl);
      }
      return 0;
    }
    
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Net.Http;
    
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Post, "https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY");
    request.Content = new FormUrlEncodedContent(new Dictionary<string, string>
    {
        { "prompt", "你好,请介绍一下你自己" },
        { "session_id", "" },
        { "streaming", "false" }
    });
    var response = client.SendAsync(request).Result;
    Console.WriteLine(response.Content.ReadAsStringAsync().Result);
    
    package main
    
    import (
      "strings"
      "fmt"
      "io"
      "net/http"
    )
    
    func main() {
      url := "https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY"
      payload := strings.NewReader("prompt=%e4%bd%a0%e5%a5%bd%ef%bc%8c%e8%af%b7%e4%bb%8b%e7%bb%8d%e4%b8%80%e4%b8%8b%e4%bd%a0%e8%87%aa%e5%b7%b1&session_id=&streaming=false")
      req, err := http.NewRequest("POST", url, payload)
      if err != nil {
        fmt.Println(err)
        return
      }
      req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
      res, err := http.DefaultClient.Do(req)
      if err != nil {
        fmt.Println(err)
        return
      }
      defer res.Body.Close()
      body, err := io.ReadAll(res.Body)
      if err != nil {
        fmt.Println(err)
        return
      }
      fmt.Println(string(body))
    }
    
    OkHttpClient client = new OkHttpClient().newBuilder().build();
    MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
    RequestBody body = RequestBody.create(mediaType, "prompt=%e4%bd%a0%e5%a5%bd%ef%bc%8c%e8%af%b7%e4%bb%8b%e7%bb%8d%e4%b8%80%e4%b8%8b%e4%bd%a0%e8%87%aa%e5%b7%b1&session_id=&streaming=false");
    Request request = new Request.Builder()
      .url("https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY")
      .method("POST", body)
      .build();
    Response response = client.newCall(request).execute();
    System.out.println(response.body().string());
    
    $.ajax({
      url: "https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY",
      method: "POST",
      data: { "prompt": "你好,请介绍一下你自己", "session_id": "", "streaming": "false" },
    }).done(function (response) {
      console.log(response);
    });
    
    const response = await fetch("https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY", {
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      body: new URLSearchParams({ "prompt": "你好,请介绍一下你自己", "session_id": "", "streaming": "false" })
    });
    console.log(await response.text());
    
    const response = await fetch("https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY", {
      method: "POST",
      headers: { "Content-Type": "application/x-www-form-urlencoded" },
      body: new URLSearchParams({ "prompt": "你好,请介绍一下你自己", "session_id": "", "streaming": "false" })
    });
    console.log(await response.text());
    
    #import <Foundation/Foundation.h>
    
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY"]];
    [request setHTTPMethod:@"POST"];
    NSString *body = @"prompt=%e4%bd%a0%e5%a5%bd%ef%bc%8c%e8%af%b7%e4%bb%8b%e7%bb%8d%e4%b8%80%e4%b8%8b%e4%bd%a0%e8%87%aa%e5%b7%b1&session_id=&streaming=false";
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
    NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
      if (error) {
        NSLog(@"%@", error);
        return;
      }
      NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
    }];
    [task resume];
    
    <?php
    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "prompt=%e4%bd%a0%e5%a5%bd%ef%bc%8c%e8%af%b7%e4%bb%8b%e7%bb%8d%e4%b8%80%e4%b8%8b%e4%bd%a0%e8%87%aa%e5%b7%b1&session_id=&streaming=false",
      CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded"),
    ));
    $response = curl_exec($curl);
    curl_close($curl);
    echo $response;
    
    import requests
    
    url = "https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY"
    payload = { "prompt": "你好,请介绍一下你自己", "session_id": "", "streaming": "false" }
    response = requests.post(url, data=payload)
    print(response.text)
    
    require "uri"
    require "net/http"
    
    url = URI("https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY")
    https = Net::HTTP.new(url.host, url.port)
    https.use_ssl = true
    request = Net::HTTP::Post.new(url)
    request["Content-Type"] = "application/x-www-form-urlencoded"
    request.body = "prompt=%e4%bd%a0%e5%a5%bd%ef%bc%8c%e8%af%b7%e4%bb%8b%e7%bb%8d%e4%b8%80%e4%b8%8b%e4%bd%a0%e8%87%aa%e5%b7%b1&session_id=&streaming=false"
    response = https.request(request)
    puts response.read_body
    
    import Foundation
    
    let semaphore = DispatchSemaphore(value: 0)
    var request = URLRequest(url: URL(string: "https://api.gugudata.com/ai/gaokao/chat?appkey=YOUR_APPKEY")!, timeoutInterval: .infinity)
    request.httpMethod = "POST"
    request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
    request.httpBody = "prompt=%e4%bd%a0%e5%a5%bd%ef%bc%8c%e8%af%b7%e4%bb%8b%e7%bb%8d%e4%b8%80%e4%b8%8b%e4%bd%a0%e8%87%aa%e5%b7%b1&session_id=&streaming=false".data(using: .utf8)
    let task = URLSession.shared.dataTask(with: request) { data, response, error in
      defer { semaphore.signal() }
      guard let data = data else {
        print(String(describing: error))
        return
      }
      print(String(data: data, encoding: .utf8)!)
    }
    task.resume()
    semaphore.wait()
    
  • 常见问题 Q&A

    • Q: 数据请求有缓存吗?

      A: 我们为所有数据请求提供实时响应。对于定期更新的数据,我们在其更新周期内实施缓存策略,以优化性能。

    • Q: 如何保证请求时 key 的安全性?

      A: 我们建议将对 API 的请求操作放置在您的应用程序后端。这样,前端请求只与您的后端服务交互,确保了更高的安全性和易于维护的架构。

    • Q: 接口可以用于哪些开发语言?

      A: 我们的接口支持所有能进行网络请求的开发语言,便于在各类项目中快速整合数据。

    • Q: 接口的性能可以保证吗?

      A: 我们的接口后台使用与商业级项目相同的架构,保证了稳定且高效的性能。您可以通过访问测试接口了解更多性能信息。

  • 服务协议以及服务免责声明

    用户应当充分阅读 服务协议 以及 服务免责声明 ,用户购买与使用咕咕数据 API 服务亦视为接受本协议。

  • 技术支持

    • 技术支持邮箱: support@gugudata.com
    • 微信客服: 客服链接

业务相关接口推荐

基于模型的高校录取概率预测
  • 融合历年分数线与分段位次特征录取概率模型
  • AI预测 / 高考志愿 / 录取概率
  • 9999元/年限时折扣 4999元/年
查看详情 数据校验更新于 9 小时前
50% 折扣
职业与发展心理测评问卷
  • 专业心理测评与职业发展心理测评
  • 心理测评 / 职业发展
  • 1999元/年限时折扣 999元/年
查看详情 被调用于 7 秒前
50% 折扣
高校评分实时分析与推荐
  • 基于多维度指标对大学进行综合评分与分析
  • 多维度评估 / 专业推荐
  • 1999元/年限时折扣 999元/年
查看详情 数据校验更新于 8 小时前
50% 折扣
稳定提供服务 10 年 全球 QS 世界大学排名数据
  • 详细排名指标和得分信息
  • 全球排名 / 高等教育
  • 1999元/年限时折扣 999元/年
查看详情 数据校验更新于 4 小时前
50% 折扣