获取API Key

https://platform.moonshot.cn/

打开终端

#打开环境变量设置
nano ~/.zshrc

#添加以下内容

# Kimi API 配置
export KIMI_API_KEY="your-api-key-here"
export KIMI_BASE_URL="https://api.moonshot.cn/v1"

#保存并生效配置

source ~/.zshrc

撤销配置

撤销即直接进入到环境配置删除添加的内容即可

终端直接的使用方法

curl https://api.moonshot.cn/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $KIMI_API_KEY" \
  -d '{
    "model": "moonshot-v1-8k",
    "messages": [{"role": "user", "content": "讲个程序员笑话"}]
  }'

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐