← 返回
开发者工具 Key

Setup Agent

Set up or log in to Karma. Use when user says "set up agent", "configure API key", "connect to Karma", "login to Karma", "log in", or before first use of any...
设置或登录 Karma。当用户说"设置代理"、"配置 API 密钥"、"连接 Karma"、"登录"或首次使用任何功能前使用。
maheshmurthy
开发者工具 clawhub v0.2.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 593
下载
💾 2
安装
1
版本
#karma#latest

概述

Setup Karma Agent

Configure your environment to use Karma agent skills. Run this once before using any action skill.

See Agent API Reference for base URL and error handling.

Flow

Check if KARMA_API_KEY is already set:

  • If set → skip to Verify Configuration
  • If not set → use the AskUserQuestion tool with these options:
  • Question: "You need a Karma API key to continue. How would you like to set it up?"
  • Options: ["Quick start — Generate instantly (no account needed)", "Email login — Link to existing Karma account", "I already have a key"]

Quick Start — No Account Needed

The fastest way to get started. No email, no login, no existing account required.

BASE_URL="${KARMA_API_URL:-https://gapapi.karmahq.xyz}"
INVOCATION_ID=$(uuidgen)

curl -s -X POST "${BASE_URL}/v2/agent/register" \
  -H "Content-Type: application/json" \
  -H "X-Source: skill:setup-agent" -H "X-Invocation-Id: $INVOCATION_ID" -H "X-Skill-Version: 0.2.0" \
  -d '{}'

Expected response:

{ "key": "karma_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }

The key is shown only once. Proceed immediately to Set Your API Key.

> Note: Projects created with this method get their own wallet. They won't be linked to an existing Karma account, so they can't be managed from the website yet (coming in a future update).

Create API Key via Email

Step 1: Ask for Email

Ask the user for their email address.

Step 2: Send Verification Code

BASE_URL="${KARMA_API_URL:-https://gapapi.karmahq.xyz}"
INVOCATION_ID=$(uuidgen)

curl -s -X POST "${BASE_URL}/v2/api-keys/auth/init" \
  -H "Content-Type: application/json" \
  -H "X-Source: skill:setup-agent" -H "X-Invocation-Id: $INVOCATION_ID" -H "X-Skill-Version: 0.2.0" \
  -d '{ "email": "user@example.com" }'

Expected response:

{ "message": "Verification code sent to user@example.com" }

Tell the user: "Check your email for a verification code from Karma."

Step 3: Verify Code

Ask the user for the code they received, then:

curl -s -X POST "${BASE_URL}/v2/api-keys/auth/verify" \
  -H "Content-Type: application/json" \
  -H "X-Source: skill:setup-agent" -H "X-Invocation-Id: $INVOCATION_ID" -H "X-Skill-Version: 0.2.0" \
  -d '{
    "email": "user@example.com",
    "code": "123456",
    "name": "claude-agent"
  }'

Expected response:

{ "key": "karma_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }

Important: The key is shown only once. Proceed immediately to set it.

Step 4: Handle Errors

ErrorMeaningAction
------------------------
400 Invalid or expired codeWrong code or expiredAsk user to check code or request a new one
409 Active key already existsUser already has a keyTell them to use their existing key or revoke it from the website
429 Too many requestsRate limitedWait and try again

1. Save Your API Key

After obtaining the key, ask permission to save it permanently:

> Would you like me to save your API key to your shell config so you don't have to paste it every time?

If yes, detect the user's shell and append the export:

# Detect shell config file
if [ -f "$HOME/.zshrc" ]; then
  SHELL_RC="$HOME/.zshrc"
elif [ -f "$HOME/.bashrc" ]; then
  SHELL_RC="$HOME/.bashrc"
fi

# Append only if not already present
grep -q 'KARMA_API_KEY' "$SHELL_RC" || echo '\n# Karma API Key\nexport KARMA_API_KEY="karma_..."' >> "$SHELL_RC"

# Also export for current session
export KARMA_API_KEY="karma_..."

If the key already exists in the file, replace the old value instead of appending a duplicate.

If the user declines, just set it for the current session:

export KARMA_API_KEY="karma_your_key_here"

2. Set the API URL (Optional)

Defaults to production. For local development:

export KARMA_API_URL="http://localhost:3002"

3. Verify Configuration

curl -s "${KARMA_API_URL:-https://gapapi.karmahq.xyz}/v2/agent/info" \
  -H "x-api-key: ${KARMA_API_KEY}" \
  -H "X-Source: skill:setup-agent" -H "X-Invocation-Id: $INVOCATION_ID" -H "X-Skill-Version: 0.2.0" \
  | python3 -m json.tool

Expected response:

{
  "walletAddress": "0x...",
  "smartAccountAddress": "0x...",
  "supportedChainIds": [10, 137, 1135, ...],
  "supportedActions": ["createProject", "createMilestone", ...]
}

4. Confirm Success

If the response includes walletAddress and supportedActions, tell the user their API key and that they're ready:

> Your Karma agent is ready!

>

> API Key: karma_... (the key from step 1 or the email flow)

>

> You can now use these skills:

> - project-manager — Create and manage projects, grants, milestones, and updates

> - find-funding-opportunities — Search for grants, hackathons, bounties, and more

Do NOT show wallet address, smart account address, or chain IDs to the user. They only need the API key.

Troubleshooting

IssueFix
------------
401 Invalid or revoked API keyKey is wrong or expired — regenerate via email flow or at karmahq.xyz
walletAddress: nullKey was created before server wallets — regenerate it
Connection refusedWrong KARMA_API_URL — check the URL is reachable
KARMA_API_KEY not setRun export KARMA_API_KEY="karma_..." in your terminal

版本历史

共 1 个版本

  • v0.2.0 当前
    2026-03-19 13:35 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 66 📥 179,856
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 667 📥 323,821
developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 921 📥 185,734