Get started
Send requests from code
Ask for approval from TypeScript, Python or plain HTTP, wait for the decision, and run only the approved arguments.
Transcript (30 seconds)
Ask for approval from your own code.
Install the SDK and set your API key.
Call requestAndWait with the action, its arguments and a reason.
A person approves, edits or rejects.
Your code runs only the approved arguments.
Before you start
- An API key from API keys (a test key is free and only reaches the test environment)
- Node 20 or later, or Python 3.9 or later
Steps
Install the SDK
Both SDKs have no dependencies.
npm install @promptcompute/sdk # or pip install promptcomputeSet your key
Store the key as a secret. The SDKs read
PROMPTCOMPUTE_API_KEY.export PROMPTCOMPUTE_API_KEY=pc_test_...Ask and wait
requestAndWaitsends the request and waits for a decision. It throws on reject, deny or expiry, so the action never runs without approval.import { PromptCompute } from "@promptcompute/sdk"; const pc = new PromptCompute(); const decision = await pc.requestAndWait({ action: "payment.refund", args: { order_id: "A-1001", amount: 120 }, reason: "Customer reported damage", }); await refund(decision.final_args); // never the original argsOr wrap a function
withApprovalreturns a function that asks first and runs with the approved arguments. In Python, use the@requires_approvaldecorator.from promptcompute import requires_approval @requires_approval(action="payment.refund") def refund(order_id: str, amount: float) -> None: ...Plain HTTP
POST the request, then long-poll its wait endpoint for up to 50 seconds at a time.
curl -X POST https://api.promptcompute.ai/v1/approvals \ -H "Authorization: Bearer $PROMPTCOMPUTE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"action":"payment.refund","args":{"order_id":"A-1001","amount":120}}' curl "https://api.promptcompute.ai/v1/approvals/apr_.../wait?timeout=50" -H "Authorization: Bearer $PROMPTCOMPUTE_API_KEY"
Use cases
A batch job that changes billing
- The situation
- A nightly job adjusts customer plans and you want a person on anything above a threshold.
- What to do
- Wrap the change in
withApprovalwith an idempotency key from the run id. - What happens
- Retries never ask twice, and changes run only with the approved values.
An agent framework
- The situation
- Your agent runs on LangGraph, the OpenAI Agents SDK, Temporal or Inngest.
- What to do
- Use the adapter from
@promptcompute/sdkfor your framework instead of writing the wait loop. - What happens
- The run pauses at the step that needs approval and resumes with the decision.
What you will see
Your code waits at the request, and continues with final_args once someone approves.
It worked when
- The request shows in the inbox with your reason
- Rejected requests raise an error and the action does not run
- After approval,
final_argsholds any edits the approver made
Example output: requestAndWait after an approver lowered the amount
{
"id": "apr_01j...",
"status": "approved_with_edits",
"action": "payment.refund",
"args": { "order_id": "A-1001", "amount": 120 },
"final_args": { "order_id": "A-1001", "amount": 80 },
"risk": "medium",
"rule_id": "larger-refunds"
}If something goes wrong
- 401 unauthorized
- The key is missing, malformed or revoked. Keys start with
pc_live_orpc_test_; create a new one under API keys. - 402 quota_exceeded
- The Free plan is past 120% of its monthly requests. Upgrade under Billing, or use the test environment, which is never limited.
- Unknown actions always need approval at high risk
- Register the action under Action types, or import it from the starter catalog, so it gets a summary and the right risk.