{"id":46813326,"url":"https://github.com/northes/go-moonshot","last_synced_at":"2026-03-10T08:35:20.844Z","repository":{"id":230335642,"uuid":"778759207","full_name":"northes/go-moonshot","owner":"northes","description":"Go SDK for moonshot kimi","archived":false,"fork":false,"pushed_at":"2025-02-18T13:52:10.000Z","size":168,"stargazers_count":22,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-18T14:32:23.840Z","etag":null,"topics":["ai","go","golang","kimi","kimi-ai","llm","moonshot","moonshot-ai","sdk","streaming-api"],"latest_commit_sha":null,"homepage":"","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/northes.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-28T10:49:46.000Z","updated_at":"2025-05-01T06:47:04.000Z","dependencies_parsed_at":"2024-05-09T07:46:47.701Z","dependency_job_id":"dae7ba99-bce9-4722-a316-dc7aafefa158","html_url":"https://github.com/northes/go-moonshot","commit_stats":null,"previous_names":["northes/go-moonshot"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/northes/go-moonshot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/northes%2Fgo-moonshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/northes%2Fgo-moonshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/northes%2Fgo-moonshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/northes%2Fgo-moonshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/northes","download_url":"https://codeload.github.com/northes/go-moonshot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/northes%2Fgo-moonshot/sbom","scorecard":{"id":694543,"data":{"date":"2025-08-11","repo":{"name":"github.com/northes/go-moonshot","commit":"38b725cd1c3344b3c647f586ddcc6c75ef8cf049"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/13 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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yaml:1","Info: no jobLevel write permissions found"],"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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"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":"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/northes/go-moonshot/ci.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yaml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/northes/go-moonshot/ci.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yaml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/northes/go-moonshot/ci.yaml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"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":"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":"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":2,"reason":"SAST tool is not run on all commits -- score normalized to 2","details":["Warn: 6 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T03:16:40.521Z","repository_id":230335642,"created_at":"2025-08-22T03:16:40.521Z","updated_at":"2025-08-22T03:16:40.521Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30328251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"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":["ai","go","golang","kimi","kimi-ai","llm","moonshot","moonshot-ai","sdk","streaming-api"],"created_at":"2026-03-10T08:35:19.769Z","updated_at":"2026-03-10T08:35:20.813Z","avatar_url":"https://github.com/northes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Go Moonshot\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/northes/go-moonshot)](https://goreportcard.com/report/github.com/northes/go-moonshot)\n![Go Version](https://img.shields.io/badge/Go-%3E%3D%201.18-%23007d9c)\n[![tag](https://img.shields.io/github/tag/northes/go-moonshot.svg)](https://github.com/northes/go-moonshot/releases)\n[![Go Reference](https://pkg.go.dev/badge/github.com/northes/go-moonshot.svg)](https://pkg.go.dev/github.com/northes/go-moonshot)\n[![codecov](https://codecov.io/gh/northes/go-moonshot/graph/badge.svg?token=81O85CA9KL)](https://codecov.io/gh/northes/go-moonshot)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fnorthes%2Fgo-moonshot.svg?type=shield\u0026issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fnorthes%2Fgo-moonshot?ref=badge_shield\u0026issueType=license)\n[![License](https://img.shields.io/github/license/northes/go-moonshot)](https://github.com/northes/go-moonshot)\n\n[简体中文](README_zh.md) | **English**\n\nA Go SDK for [Kimi](https://kimi.moonshot.cn) which created\nby [MoonshotAI](https://moonshot.cn).\n\n\u003e [!WARNING]  \n\u003e This project is still actively developing, and the API may change with the release of the version. Please pay attention when you upgrade the version.\n\n## 🚀 Installation\n\n```bash\ngo get github.com/northes/go-moonshot@v0.5.2\n```\n\nYou can find the docs at [go docs](https://pkg.go.dev/github.com/northes/go-moonshot).\n\n## 🤘 Feature\n\n- Easy to use and simple API, chain operation.\n- Full API and builtin functions support.\n- Predefined enumeration.\n- Messages builder.\n\n##  📄 Supported API\n\n| API                     | Done |\n|-------------------------|------|\n| Chat Completion         | ✅    |\n| Chat Completion(stream) | ✅    |\n| List Models             | ✅    |\n| List Files              | ✅    |\n| Upload File             | ✅    |\n| Delete File             | ✅    |\n| Get File Info           | ✅    |\n| Get File Contents       | ✅    |\n| Estimate Token Count    | ✅    |\n| User Balance            | ✅    |\n| Tool Use                | ✅    |\n| Context Cache           | ✅    |\n\n## 🗜 Builtin Functions\n\n- `$web_search`\n\n## 🥪 Usage\n\nFor more examples, you can view the test file of the corresponding interface.\n\n### Initialize client\n\n1. Get a MoonshotAI API Key: [https://platform.moonshot.cn](https://platform.moonshot.cn).\n2. Set up key using a configuration file or environment variable.\n\n\u003e [!TIP]\n\u003e Your API key is sensitive information. Do not share it with anyone.\n\n#### With Only Key\n\n```go\nkey, ok := os.LookupEnv(\"MOONSHOT_KEY\")\n// do something...\n\ncli, err := moonshot.NewClient(key)\n// do something...\n```\n\n#### With Config\n\n```go\nkey, ok := os.LookupEnv(\"MOONSHOT_KEY\")\n// do something...\n\ncli, err := moonshot.NewClientWithConfig(\n    moonshot.NewConfig(\n        moonshot.WithAPIKey(key),\n    ),\n)\n```\n\n### API\n\n#### List Models\n\n```go\nresp, err := cli.Models().List(context.Background())\n// do something...\n```\n\n#### Chat Completions\n\n```go\n// Use builder to build a request more conveniently\nbuilder := moonshot.NewChatCompletionsBuilder()\nbuilder.AppendPrompt(\"你是 Kimi，由 Moonshot AI 提供的人工智能助手，你更擅长中文和英文的对话。你会为用户提供安全，有帮助，准确的回答。同时，你会拒绝一切涉及恐怖主义，种族歧视，黄色暴力等问题的回答。Moonshot AI 为专有名词，不可翻译成其他语言。\").\n\tAppendUser(\"你好，我叫李雷，1+1等于多少？\").\n\tWithTemperature(0.3)\n\nresp, err := cli.Chat().Completions(ctx, builder.ToRequest()) \n// {\"id\":\"cmpl-eb8e8474fbae4e42bea9f6bbf38d56ed\",\"object\":\"chat.completion\",\"created\":2647921,\"model\":\"moonshot-v1-8k\",\"choices\":[{\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"你好，李雷！1+1等于2。这是一个基本的数学加法运算。如果你有任何其他问题或需要帮助，请随时告诉我。\"},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":87,\"completion_tokens\":31,\"total_tokens\":118}}\n\n// do something...\n\n// append context\nfor _, choice := range resp.Choices {\n    builder.AppendMessage(choice.Message)\n}\n\nbuilder.AppendUser(\"在这个基础上再加3等于多少\")\n\nresp, err := cli.Chat().Completions(ctx, builder.ToRequest())\n// {\"id\":\"cmpl-a7b938eaddc04fbf85fe578a980040ac\",\"object\":\"chat.completion\",\"created\":5455796,\"model\":\"moonshot-v1-8k\",\"choices\":[{\"index\":0,\"message\":{\"role\":\"assistant\",\"content\":\"在这个基础上，即1+1=2的结果上再加3，等于5。所以，2+3=5。\"},\"finish_reason\":\"stop\"}],\"usage\":{\"prompt_tokens\":131,\"completion_tokens\":26,\"total_tokens\":157}}\n\n// do something...\n```\n\n#### Chat completions with stream\n\n```go\n// use struct\nresp, err := cli.Chat().CompletionsStream(context.Background(), \u0026moonshot.ChatCompletionsRequest{\n    Model: moonshot.ModelMoonshotV18K,\n    Messages: []*moonshot.ChatCompletionsMessage{\n        {\n            Role:    moonshot.RoleUser,\n            Content: \"你好，我叫李雷，1+1等于多少？\",\n        },\n    },\n    Temperature: 0.3,\n    Stream:      true,\n})\n// do something...\n\nfor receive := range resp.Receive() {\n    msg, err := receive.GetMessage()\n    if err != nil {\n        if errors.Is(err, io.EOF) {\n            break\n        }\n        break\n    }\n    switch msg.Role {\n        case moonshot.RoleSystem,moonshot.RoleUser,moonshot.RoleAssistant:\n        // do something...\n        default:\n        // do something...\n    }\n}\n```\n\n#### Web search tool\n\n```go\nbuilder := moonshot.NewChatCompletionsBuilder()\nbuilder.SetModel(moonshot.ModelMoonshotV1128K)\nbuilder.AddUserContent(\"请搜索 Moonshot AI Context Caching 技术，并告诉我它是什么。\")\nbuilder.SetTool(\u0026moonshot.ChatCompletionsTool{\n\tType: moonshot.ChatCompletionsToolTypeBuiltinFunction,\n\tFunction: \u0026moonshot.ChatCompletionsToolFunction{\n\t\tName: moonshot.BuiltinFunctionWebSearch,\n\t},\n})\n\nresp, err := cli.Chat().Completions(ctx, builder.ToRequest())\n// do something...\n\nif len(resp.Choices) != 0 {\n\tchoice := resp.Choices[0]\n\tif choice.FinishReason == moonshot.FinishReasonToolCalls {\n\t\tfor _, tool := range choice.Message.ToolCalls {\n\t\t\tif tool.Function.Name == moonshot.BuiltinFunctionWebSearch {\n\t\t\t\t// web search\n\t\t\t\targuments := new(moonshot.ChatCompletionsToolBuiltinFunctionWebSearchArguments)\n\t\t\t\tif err = json.Unmarshal([]byte(tool.Function.Arguments), arguments); err != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t// do something...\n\n\t\t\t\tbuilder.AddMessageFromChoices(resp.Choices)\n\t\t\t\tbuilder.AddToolContent(tool.Function.Arguments, tool.Function.Name, tool.ID)\n\t\t\t}\n\t\t}\n\t}\n}\n\nresp, err = cli.Chat().Completions(ctx, builder.ToRequest())\n// do something...\n```\n\n## 🤝  Missing a Feature?\n\nFeel free to open a new issue, or contact me.\n\n## 🥳  Contributors\n\n\u003ca href=\"https://github.com/northes/go-moonshot/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=northes/go-moonshot\"  alt=\"contributors\"/\u003e\n\u003c/a\u003e\n\nMade with [contrib.rocks](https://contrib.rocks).\n\n## 📘 License\n\nThis is open-sourced library licensed under the [MIT license](LICENSE).\n\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fnorthes%2Fgo-moonshot.svg?type=large\u0026issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fnorthes%2Fgo-moonshot?ref=badge_large\u0026issueType=license)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorthes%2Fgo-moonshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnorthes%2Fgo-moonshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorthes%2Fgo-moonshot/lists"}