Kredit Skill Reference

Kredit SDK Skill

Use this skill when the user wants to add financial risk management, spending controls, or guardrails to AI agents. Kredit provides wallets, rules, kredit scoring, and spend tracking for autonomous agent fleets.

When to Use

  • User wants to control how much an AI agent can spend
  • User needs per-API spending limits or rate limits for agents
  • User wants to track agent spending and block risky transactions
  • User asks about agent wallets, budgets, or kredit scores
  • User wants to set up rules like "max $500 per flight booking" or "max 50 OpenAI calls per hour"
  • User wants to monitor a fleet of agents in real time
  • User wants to freeze or throttle rogue agents automatically
  • Install

    pip install kredit          # Python
    npm i @kredit/kredit        # JavaScript / TypeScript
    curl -sSL https://kredit.sh/install | sh  # CLI

    MCP Server (Claude Code / Claude Desktop)

    npm i -g kredit-mcp
    claude mcp add kredit -- kredit-mcp serve --api-key=kr_live_...

    Authentication

    # CLI login (opens browser, saves key to ~/.kredit/config)
    kredit login
    
    

    Or set env var

    export KREDIT_API_KEY=kr_live_...

    Or pass directly

    kredit = Kredit(api_key="kr_live_...") # Python const kr = new Kredit({ apiKey: "kr_live_..." }) # TypeScript

    Core Concepts

    Agent

    An autonomous program that spends money. Each agent has a wallet, rules, kredit score, and priority level. Agents belong to organizations.

    Organization

    A grouping of agents. Create orgs to separate teams, projects, or environments (e.g. "production", "staging", "research-team").

    Wallet

    Balance and global spending limits per agent:
  • balance — current dollars available
  • budget — total allocated dollars
  • max_per_txn — max dollars per single transaction (0 = unlimited)
  • daily_spend_limit — max dollars per day (0 = unlimited)
  • Rules

    Per-action spending limits with fnmatch pattern matching:
  • match — action pattern (openai.*, flight.*, * for all)
  • max_cost_per_txn — max dollars per call (0 = unlimited)
  • daily_spend_limit — max dollars per day on matched actions (0 = unlimited)
  • hourly_rate_limit — max calls per hour on matched actions (0 = unlimited)
  • Most specific rule wins (flight.booking beats flight.* beats *)
  • Priority Levels

  • normal — blocked when limits hit
  • high — auto-increase wallet by 50% when balance drops below 10% of budget
  • critical — never blocked, always allowed (logs warning)
  • Kredit Score (300-850)

    Composite score based on agent behavior. Updates on every reported outcome.
  • 600+ = active (full operation)
  • 400-600 = throttled (reduced limits, flagged for review)
  • <400 = frozen (all actions blocked, human approval required)
  • Score factors:

  • Task success rate (30%)
  • Cost efficiency (25%)
  • Violation rate (20%)
  • Spend consistency (15%)
  • Tenure bonus (10%)
  • Check Order (Risk Evaluation Flow)

    1. Priority override (critical → always allow) 2. Frozen status check → block 3. High priority auto-increase wallet 4. Global wallet: max_per_txn → block if exceeded 5. Global wallet: daily_spend_limit → block if exceeded 6. Wallet balance → block if insufficient 7. Rules: match action pattern → most specific wins → check limits 8. Kredit score < 400 → block 9. Anomaly detection (10x average cost → flag) 10. Score-based risk escalation

    Python SDK

    from kredit import Kredit

    kredit = Kredit(api_key="kr_live_...")

    Organizations

    org = kredit.orgs.create(name="my-team")
    orgs = kredit.orgs.list()

    Agents

    agent = kredit.agents.create(
        org_name="my-team",
        name="research-bot",
        priority="high",
        wallet={"balance": 5000, "budget": 5000, "max_per_txn": 100, "daily_spend_limit": 1000},
        rules=[
            {"name": "OpenAI cap", "match": "openai.*", "max_cost_per_txn": 5, "daily_spend_limit": 100, "hourly_rate_limit": 50},
            {"name": "Default", "match": "*", "max_cost_per_txn": 50, "daily_spend_limit": 500, "hourly_rate_limit": 200},
        ],
    )

    agents = kredit.agents.list() # all agents agents = kredit.agents.list(org_id=org.id) # by org agent = kredit.agents.get(agent_id=agent.id) kredit.agents.update(agent_id=agent.id, priority="critical") kredit.agents.delete(agent_id=agent.id)

    Rules

    kredit.rules.add(
        agent_id=agent.id,
        name="Flight cap",
        match="flight.*",
        max_cost_per_txn=800,
        daily_spend_limit=3000,
        hourly_rate_limit=10,
    )

    rules = kredit.rules.list(agent_id=agent.id) kredit.rules.update(agent_id=agent.id, rule_id=rules[0].id, max_cost_per_txn=1000) kredit.rules.remove(agent_id=agent.id, rule_id=rules[0].id)

    Check & Report (Core Loop)

    # Before any paid action
    result = kredit.check(
        agent_id=agent.id,
        action="openai.chat",
        estimated_cost=2.50,
        type="api_call",           # api_call | compute | data | tool | other
        metadata={"model": "gpt-4o"},
    )

    if result.status == "allowed": # Execute the action... response = call_openai(prompt)

    # Report outcome kredit.report( transaction_id=result.transaction_id, outcome="success", # success | failure | partial actual_cost=2.40, ) else: print(f"Blocked: {result.block_reason}") # e.g. "rule:OpenAI cap:max_cost_per_txn" or "wallet_empty" or "agent_frozen"

    Score, Spend & Fleet

    score = kredit.score(agent_id=agent.id)
    

    score.score = 742, score.status = "active"

    spend = kredit.spend(agent_id=agent.id)

    spend.total_spend, spend.daily_spend, spend.weekly_spend, spend.monthly_spend

    fleet = kredit.fleet()

    fleet.total_agents, fleet.active_agents, fleet.throttled_agents, fleet.frozen_agents

    fleet.total_spend, fleet.risk_events_blocked, fleet.avg_credit_score

    txns = kredit.transactions.list(agent_id=agent.id, status="blocked", limit=50)

    TypeScript SDK

    import { Kredit } from "@kredit/kredit";

    const kredit = new Kredit({ apiKey: "kr_live_..." });

    Organizations

    const org = await kredit.orgs.create({ name: "my-team" });
    const orgs = await kredit.orgs.list();

    Agents

    const agent = await kredit.agents.create({
      orgName: "my-team",
      name: "research-bot",
      priority: "high",
      wallet: { balance: 5000, budget: 5000, max_per_txn: 100, daily_spend_limit: 1000 },
      rules: [
        { name: "OpenAI cap", match: "openai.*", max_cost_per_txn: 5, daily_spend_limit: 100, hourly_rate_limit: 50 },
      ],
    });

    const agents = await kredit.agents.list(); const agentDetail = await kredit.agents.get({ agentId: agent.id }); await kredit.agents.update({ agentId: agent.id, priority: "critical" }); await kredit.agents.delete({ agentId: agent.id });

    Rules

    await kredit.rules.add({
      agentId: agent.id,
      name: "Flight cap",
      match: "flight.*",
      max_cost_per_txn: 800,
      daily_spend_limit: 3000,
      hourly_rate_limit: 10,
    });

    const rules = await kredit.rules.list({ agentId: agent.id }); await kredit.rules.update({ agentId: agent.id, ruleId: rules[0].id, max_cost_per_txn: 1000 }); await kredit.rules.remove({ agentId: agent.id, ruleId: rules[0].id });

    Check & Report

    const result = await kredit.check({
      agentId: agent.id,
      action: "openai.chat",
      estimatedCost: 2.50,
      type: "api_call",
      metadata: { model: "gpt-4o" },
    });

    if (result.status === "allowed") { const response = await callOpenAI(prompt); await kredit.report({ transactionId: result.transaction_id, outcome: "success", actualCost: 2.40, }); }

    Score, Spend & Fleet

    const score = await kredit.score({ agentId: agent.id });
    const spend = await kredit.spend({ agentId: agent.id });
    const fleet = await kredit.fleet();
    const txns = await kredit.transactions.list({ agentId: agent.id, status: "blocked" });

    CLI

    # Auth
    kredit login
    
    

    Organizations

    kredit orgs create --name=my-team kredit orgs list

    Agents

    kredit agents create --org-name=my-team --name=research-bot kredit agents list kredit agents list --org-id=ORG_ID

    Rules

    kredit rules add --agent-id=ID --name="OpenAI cap" --match="openai.*" \ --max-cost-per-txn=5 --daily-spend-limit=100 --hourly-rate-limit=50 kredit rules list --agent-id=ID kredit rules remove --agent-id=ID --rule-id=RULE_ID

    Check & Report

    kredit check --agent-id=ID --action=openai.chat --estimated-cost=2.50 kredit report --transaction-id=TXN_ID --outcome=success --actual-cost=2.40

    Score & Wallet

    kredit score --agent-id=ID kredit wallet --agent-id=ID

    Demo (1-hour simulation with 5 agents)

    kredit demo

    MCP Tools (22 total)

    When installed as an MCP server, Claude can call these tools natively:

    Risk Check & Report
    ToolDescription
    kredit_checkRisk evaluation before a paid action
    kredit_reportReport outcome after action completes

    Organizations
    ToolDescription
    kredit_list_orgsList all organizations
    kredit_create_orgCreate an organization
    kredit_rename_orgRename an organization
    kredit_delete_orgDelete an organization

    Agents
    ToolDescription
    kredit_list_agentsList agents (filter by org)
    kredit_create_agentCreate agent with wallet, priority, rules
    kredit_get_agentGet agent details
    kredit_update_agentUpdate name, priority, wallet
    kredit_delete_agentDelete an agent

    Rules
    ToolDescription
    kredit_list_rulesList rules for an agent
    kredit_add_ruleAdd a spending rule (match pattern + limits)
    kredit_update_ruleUpdate a rule
    kredit_delete_ruleDelete a rule

    Score & Wallet
    ToolDescription
    kredit_scoreGet kredit score and stats
    kredit_walletGet wallet balance and limits
    kredit_update_walletUpdate wallet balance, budget, limits

    Fleet & Logs
    ToolDescription
    kredit_fleetFleet overview stats
    kredit_transactionsList transactions (audit log)
    kredit_eventsAgent state change history

    API Reference

    Base URL: https://api.kredit.sh Auth: Authorization: Bearer kr_live_...

    Risk Check & Report
    MethodPathDescription
    POST/checkRisk evaluation (agent_id, action, estimated_cost, type, metadata)
    POST/reportReport outcome (transaction_id, outcome, actual_cost)

    Organizations
    MethodPathDescription
    GET/orgsList orgs
    POST/orgsCreate org
    PUT/orgs/:idRename org
    DELETE/orgs/:idDelete org

    Agents
    MethodPathDescription
    GET/agentsList agents (filter: org_id, status)
    POST/agentsCreate agent (name, org_name/org_id, priority, wallet, rules)
    GET/agents/:idGet agent
    PUT/agents/:idUpdate agent (name, priority, wallet)
    DELETE/agents/:idDelete agent

    Rules
    MethodPathDescription
    GET/agents/:id/rulesList rules
    POST/agents/:id/rulesAdd rule
    PUT/agents/:id/rules/:rule_idUpdate rule
    DELETE/agents/:id/rules/:rule_idDelete rule

    Score & Wallet
    MethodPathDescription
    GET/agents/:id/scoreGet kredit score
    GET/agents/:id/spendGet spend breakdown
    GET/wallets/:idGet wallet
    PUT/wallets/:idUpdate wallet

    Fleet & Logs
    MethodPathDescription
    GET/fleet/overviewFleet stats
    GET/transactionsAudit log (filter: org_id, agent_id, status, risk_level)
    GET/transactions/summaryStatus counts
    GET/agents/:id/eventsAgent events

    Claude Code Hooks (Zero-Integration Path)

    Use Kredit as a pre/post hook on tool calls — no SDK needed:

    // .claude/hooks.json
    {
      "PreToolCall": {
        "tools": ["Bash", "WebFetch"],
        "command": "kredit check --agent-id=$CLAUDE_SESSION_ID --action=$TOOL_NAME --estimated-cost=1"
      },
      "PostToolCall": {
        "tools": ["Bash", "WebFetch"],
        "command": "kredit report --transaction-id=$TXN_ID --outcome=$EXIT_CODE"
      }
    }

    Links

  • Dashboard: https://kredit.sh/dashboard
  • Docs: https://kredit.sh/docs
  • GitHub: https://github.com/kreditsh/kredit
  • npm: https://www.npmjs.com/package/@kredit/kredit
  • PyPI: https://pypi.org/project/kredit/
  • MCP: https://www.npmjs.com/package/kredit-mcp