call_service
Invokes an upstream API through LemonCake's pay-per-call proxy, automatically charging USDC from your Pay Token for each successful call.
Instructions
Invoke an upstream API service through LemonCake's pay-per-call proxy. Each successful call automatically charges USDC against your configured Pay Token.
PRECONDITIONS:
• LEMON_CAKE_PAY_TOKEN env var must be set for real services. If missing, the tool
returns a structured CREDENTIAL_MISSING error with how-to-fix steps.
• DEMO MODE: serviceId values starting with demo_ (demo_search / demo_echo / demo_fx)
work WITHOUT any auth and return canned responses — useful for Glama Inspector
or new-user trial. They are clearly marked with mode: "demo" and incur no charge.
• serviceId must come from list_services.
BEHAVIOR: • Returns the upstream response body verbatim (JSON or text), plus the X-Charge-Id and X-Amount-Usdc headers reported by the proxy. • HTTP 402 Payment Required is returned as a normal result (NOT thrown) so the agent can autonomously stop spending when the Pay Token's limitUsdc is exhausted. • Pass the same idempotencyKey to retry safely without double-charging. • This tool spends real money and contacts an external service — it is non-idempotent by default and has external side effects.
x402-COMPATIBLE INTERFACE (since v0.5.1):
• Successful calls include an x402Receipt field with { scheme, chain, asset, amount,
recipient, paymentIntentId, settledAt }. Same shape as on-chain x402 receipts so the
agent's payment-handling logic is portable.
• If upstream returns an x402 challenge (WWW-Authenticate: x402, X-402-* headers, or
body.x402), it's parsed into x402Challenge for the agent to reason about. On-chain
auto-pay from Pay Token is gated (see issue #4); for now the agent should escalate.
• If upstream returns 202 + Retry-After + X-Payment-Status: pending, the result is
{ status: "PAYMENT_PENDING", paymentIntentId, retryAfterMs, retryContract }.
Re-call with the same idempotencyKey to resume — no double-charge.
Returns: { status, chargeId, amountUsdc, response, x402Receipt?, x402Challenge?, hint? }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serviceId | Yes | ID of the service to call (obtain from list_services). | |
| path | No | Sub-path on the service (e.g. "/search", "/v1/completions"). Defaults to "/". | / |
| method | No | HTTP method to use against the service. Defaults to GET. | GET |
| body | No | JSON request body (only used for POST/PUT/PATCH). | |
| idempotencyKey | No | Optional idempotency key (UUID recommended). Identical keys within the proxy's retention window return the cached result without re-charging. |