{"id":38992634,"url":"https://github.com/iflytek/spark-ai-go","last_synced_at":"2026-01-17T17:04:55.165Z","repository":{"id":228294369,"uuid":"773583123","full_name":"iflytek/spark-ai-go","owner":"iflytek","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-09T09:08:52.000Z","size":2497,"stargazers_count":4,"open_issues_count":4,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T14:05:52.438Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iflytek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-18T02:33:27.000Z","updated_at":"2024-05-21T03:20:57.000Z","dependencies_parsed_at":"2024-03-18T04:26:11.821Z","dependency_job_id":"28adbd52-06bb-4edc-8983-84ac3bc9a22a","html_url":"https://github.com/iflytek/spark-ai-go","commit_stats":null,"previous_names":["iflytek/spark-ai-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/iflytek/spark-ai-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iflytek%2Fspark-ai-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iflytek%2Fspark-ai-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iflytek%2Fspark-ai-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iflytek%2Fspark-ai-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iflytek","download_url":"https://codeload.github.com/iflytek/spark-ai-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iflytek%2Fspark-ai-go/sbom","scorecard":{"id":482132,"data":{"date":"2025-08-11","repo":{"name":"github.com/iflytek/spark-ai-go","commit":"11decd0816f60fa1884eb84fa74065a59ece2b7a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":6,"reason":"4 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T16:54:15.150Z","repository_id":228294369,"created_at":"2025-08-19T16:54:15.150Z","updated_at":"2025-08-19T16:54:15.150Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28511876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-17T17:04:55.046Z","updated_at":"2026-01-17T17:04:55.148Z","avatar_url":"https://github.com/iflytek.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 讯飞星火大模型接入库 (spark-ai-go)\n\n本Go SDK库帮助用户更快体验讯飞星火大模型\n\n## 项目地址\n\n* Github: [https://github.com/iflytek/spark-ai-go](https://github.com/iflytek/spark-ai-python)\n  欢迎点赞，star\n\n## 前言\n\n感谢开源的力量，希望讯飞开源越做越好，星火大模型效果越来越好！。\n\n\n![!img](logo.png)\n\n**本logo出自[星火大模型](https://xinghuo.xfyun.cn/)**\n\n***感谢社区(LangchainGo项目以及SparkLLM部分committer)[项目正在开发中]***\n\n## 近期规划新特性[待演进]\n\n- [x] 极简的接入,快速调用讯飞星火大模型\n- [ ] LLM类统一接口，快速切换业界大模型\n- [x] Python版本[SDK](https://github.com/iflytek/spark-ai-python/)进行中\n\n\n## 如何使用\n\n### 示例代码\n\n* 前置条件\n  需要在 xfyun.cn 申请有权限的\n    * app_id\n    * api_key\n    * api_secret\n\n* URL/Domain配置请查看[doc](https://www.xfyun.cn/doc/spark/Web.html#_1-%E6%8E%A5%E5%8F%A3%E8%AF%B4%E6%98%8E)\n* 运行测试脚本需要提前将 `.env.example` 拷贝为 `.env`并配置其中变量\n\n内如如下:\n\n```tpl\n# spark 授权信息\nSPARKAI_APP_ID=\nSPARKAI_API_KEY=\nSPARKAI_API_SECRET=\nSPARKAI_DOMAIN=\nSPARKAI_URL=wss://spark-api.xf-yun.com/v3.5/chat\n```\n\n### 一次性返回结果(非流式)\n\n\n```golang\nfunc TestLLMClientStream(t *testing.T) {\n\tSPARK_API_KEY := os.Getenv(ApiKeyEnvVarName)\n\tSPARK_API_SECRET := os.Getenv(ApiSecretEnvVarName)\n\tSPARK_API_BASE := os.Getenv(BaseURLEnvVarName)\n\tSPARK_APP_ID := os.Getenv(AppIdEnvVarName)\n\tSPARK_DOMAIN = os.Getenv(SparkDomainEnvVarName)\n\t_, client, err := spark.NewClient(spark.WithBaseURL(SPARK_API_BASE), spark.WithApiKey(SPARK_API_KEY), spark.WithApiSecret(SPARK_API_SECRET), spark.WithAppId(SPARK_APP_ID), spark.WithAPIDomain(SPARK_DOMAIN))\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n\tctx := context.Background()\n\tr := \u0026sparkclient.ChatRequest{\n\t\tDomain: \u0026SPARK_DOMAIN,\n\t\tMessages: []messages.ChatMessage{\n\t\t\t\u0026messages.GenericChatMessage{\n\t\t\t\tRole:    \"user\",\n\t\t\t\tContent: \"帮我润色并简化这句话: 国内科技大厂，创业公司都在演进大模型AI Agent且AI Agent框架仍然处于发展初期，采用开源化的AIAgent演进路线有助于快速构建影响力\\n\",\n\t\t\t},\n\t\t},\n\t}\n    res, err := client.CreateChat(ctx, r)\n    if err != nil {\n        fmt.Print(err.Error())\n        return\n    }\n    fmt.Print(res.GetContent())\n\n}\n```\n\n### 流式返回结果\n\n\n```golang\nfunc TestLLMClientStream(t *testing.T) {\n\tSPARK_API_KEY := os.Getenv(ApiKeyEnvVarName)\n\tSPARK_API_SECRET := os.Getenv(ApiSecretEnvVarName)\n\tSPARK_API_BASE := os.Getenv(BaseURLEnvVarName)\n\tSPARK_APP_ID := os.Getenv(AppIdEnvVarName)\n\tSPARK_DOMAIN = os.Getenv(SparkDomainEnvVarName)\n\t_, client, err := spark.NewClient(spark.WithBaseURL(SPARK_API_BASE), spark.WithApiKey(SPARK_API_KEY), spark.WithApiSecret(SPARK_API_SECRET), spark.WithAppId(SPARK_APP_ID), spark.WithAPIDomain(SPARK_DOMAIN))\n\tif err != nil {\n\t\tfmt.Println(err.Error())\n\t\treturn\n\t}\n\tctx := context.Background()\n\tr := \u0026sparkclient.ChatRequest{\n\t\tDomain: \u0026SPARK_DOMAIN,\n\t\tMessages: []messages.ChatMessage{\n\t\t\t\u0026messages.GenericChatMessage{\n\t\t\t\tRole:    \"user\",\n\t\t\t\tContent: \"帮我润色并简化这句话: 国内科技大厂，创业公司都在演进大模型AI Agent且AI Agent框架仍然处于发展初期，采用开源化的AIAgent演进路线有助于快速构建影响力\\n\",\n\t\t\t},\n\t\t},\n\t}\n\t_, err = client.CreateChatWithCallBack(ctx, r, func(msg messages.ChatMessage) error {\n\t\tfmt.Print(msg.GetContent())\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tfmt.Print(err.Error())\n\t\treturn\n\t}\n\n}\n```\n其中可以在CreateWithCallBack传入一个func用于回调处理流式数据\n\n### FunctionCall功能\n\n\n```golang\nfunc TestLLMFunctionCN(t *testing.T) {\n\tSPARK_API_KEY := os.Getenv(ApiKeyEnvVarName)\n\tSPARK_API_SECRET := os.Getenv(ApiSecretEnvVarName)\n\tSPARK_API_BASE := os.Getenv(BaseURLEnvVarName)\n\tSPARK_APP_ID := os.Getenv(AppIdEnvVarName)\n\tSPARK_DOMAIN = os.Getenv(SparkDomainEnvVarName)\n\t_, client, _ := NewClient(WithBaseURL(SPARK_API_BASE), WithApiKey(SPARK_API_KEY), WithApiSecret(SPARK_API_SECRET), WithAppId(SPARK_APP_ID), WithAPIDomain(SPARK_DOMAIN))\n\tctx := context.Background()\n\tr := \u0026sparkclient.ChatRequest{\n\t\tDomain: \u0026SPARK_DOMAIN,\n\t\tMessages: []messages.ChatMessage{\n\t\t\t\u0026messages.GenericChatMessage{\n\t\t\t\tRole:    \"user\",\n\t\t\t\tContent: \" 帮我生成一份2023ATP报表放到 /workspace目录下 \",\n\t\t\t},\n\t\t},\n\t\tFunctions: []messages.FunctionDefinition{\n\t\t\t{\n\t\t\t\tName:        \"generate_biz_report\",\n\t\t\t\tDescription: \"生成运营分析报表工具\",\n\t\t\t\tParameters: map[string]any{\n\t\t\t\t\t\"type\": \"object\",\n\t\t\t\t\t\"properties\": map[string]any{\n\t\t\t\t\t\t\"biz\": map[string]any{\n\t\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\t\"description\": \"业务类型,取值范围为 ase, aipaas, atp\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"output_dir\": map[string]any{\n\t\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\t\"description\": \"生成存放位置\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"type\": map[string]any{\n\t\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\t\"description\": \"报表类型，取值范围是 txt, excel, markdown之一,默认为excel\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"start\": map[string]any{\n\t\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\t\"description\": \"起始时间年份\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"end\": map[string]any{\n\t\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\t\"description\": \"结束时间年份\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t\"required\": []string{\n\t\t\t\t\t\t\"output_dir\", \"type\", \"start\", \"end\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tName:        \"translate_transcript\",\n\t\t\t\tDescription: \"using translate_text function to translate the script\",\n\t\t\t\tParameters: map[string]any{\n\t\t\t\t\t\"type\": \"object\",\n\t\t\t\t\t\"properties\": map[string]any{\n\t\t\t\t\t\t\"source_language\": map[string]any{\n\t\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\t\"description\": \"source language\",\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"target_language\": map[string]any{\n\t\t\t\t\t\t\t\"type\":        \"string\",\n\t\t\t\t\t\t\t\"description\": \"target language\",\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t\"required\": []string{\n\t\t\t\t\t\t\"source_language\",\n\t\t\t\t\t\t\"source_language\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t}\n\t_, err := client.CreateChatWithCallBack(ctx, r, func(msg messages.ChatMessage) error {\n\t\tfmt.Print(msg.GetContent())\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\treturn\n\t}\n\n}\n```\n\n## 欢迎贡献\n\n扫码加入交流群\n\n![img](weichat.jpg)\n\n## 已知问题\n\n* 项目目前开发阶段，有一些冗余代码，人力有限，部分思想借鉴开源实现\n\n## URL\n\n* wss://spark-api.xf-yun.com/v3.5/chat\n\n## 致谢\n\n* [LangchainGo](https://github.com/tmc/langchaingo)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiflytek%2Fspark-ai-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiflytek%2Fspark-ai-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiflytek%2Fspark-ai-go/lists"}