Text Generation
Transformers
Safetensors
English
qwen3
stablecoin
payments
compliance
x402
eip-3009
eip-712
disputes
refunds
agents
agentkit
trl
web3
usdc
fraud-detection
financial-risk
qwen
mcp
ai-agents
prompt-injection
agentic-payments
payment-security
risk-assessment
ofac
conversational
Eval Results (legacy)
Eval Results
text-generation-inference
Instructions to use sriram1983007/SRA-RiskGate-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use sriram1983007/SRA-RiskGate-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="sriram1983007/SRA-RiskGate-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("sriram1983007/SRA-RiskGate-4B") model = AutoModelForCausalLM.from_pretrained("sriram1983007/SRA-RiskGate-4B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use sriram1983007/SRA-RiskGate-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "sriram1983007/SRA-RiskGate-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sriram1983007/SRA-RiskGate-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/sriram1983007/SRA-RiskGate-4B
- SGLang
How to use sriram1983007/SRA-RiskGate-4B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "sriram1983007/SRA-RiskGate-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sriram1983007/SRA-RiskGate-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "sriram1983007/SRA-RiskGate-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "sriram1983007/SRA-RiskGate-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use sriram1983007/SRA-RiskGate-4B with Docker Model Runner:
docker model run hf.co/sriram1983007/SRA-RiskGate-4B
Card: Robinhood Chain mainnet check; sra-riskgate 0.20.0; MCP 0.12.0
Browse files
README.md
CHANGED
|
@@ -119,6 +119,7 @@ model-index:
|
|
| 119 |
[](https://flow-kg4x.vercel.app/row)
|
| 120 |
[](https://gist.github.com/sriram1983007-dev/8cd44e78adec20a0157368ec38c2fb42)
|
| 121 |
[](https://gist.github.com/sriram1983007-dev/1555e11a57682496f710a8224415c9e2)
|
|
|
|
| 122 |

|
| 123 |
|
| 124 |
**SRA-RiskGate-4B checks a stablecoin payment before an AI agent sends it, and answers `approve`, `hold` or `reject`** with reason codes. It is a 4B model, fine-tuned from `Qwen/Qwen3-4B-Instruct-2507`, that runs on a laptop.
|
|
@@ -146,6 +147,7 @@ All 4 unsafe approvals were prompt injections; the companion SDK's deterministic
|
|
| 146 |
- **Base Sepolia, independently re-checked:** an approved 0.01 USDC payment ([tx](https://sepolia.basescan.org/tx/0xf12e9084becefd94fa6e26e54761fbfc8f3c04215d7fc724d0fca6077ba084fc)) was read back from the chain and verified, and a 2.00 USDC payment to an unknown payee was held before signing. Flow Executor, an independent agent settlement verifier, re-checked both from the chain ([log](https://gist.github.com/sriram1983007-dev/35eab0e934a512346193bcdb5b12d9cf) · [Flow Executor's page](https://flow-kg4x.vercel.app/row)).
|
| 147 |
- **Circle Gateway on Arc testnet:** one agent task, three proposed payments. One was approved, accepted by Gateway and settled to the payee (agent 0.09 → 0.08 USDC, payee 0.01 → 0.02); an unlimited approval was held and a look-alike payee rejected, neither signed ([log](https://gist.github.com/sriram1983007-dev/8cd44e78adec20a0157368ec38c2fb42)).
|
| 148 |
- **Grok as the paying agent:** Grok (grok-4.7) refused both attacks on its own; told to submit everything to the gate, it got APPROVE for the real invoice, HOLD for the unlimited approval and REJECT for the look-alike ([logs](https://gist.github.com/sriram1983007-dev/1555e11a57682496f710a8224415c9e2)).
|
|
|
|
| 149 |
|
| 150 |
These runs used the library's deterministic checks, not this model.
|
| 151 |
|
|
@@ -179,7 +181,7 @@ If this is useful for your agent, a ❤️ like on this page helps others find i
|
|
| 179 |
|
| 180 |
## 🔌 Use It From an AI Agent (MCP)
|
| 181 |
|
| 182 |
-
[`sra-riskgate-mcp`](https://pypi.org/project/sra-riskgate-mcp/) gives Claude Desktop, Cursor and other MCP clients
|
| 183 |
|
| 184 |
| Tool | What it does | Needs |
|
| 185 |
| --- | --- | --- |
|
|
@@ -191,8 +193,9 @@ If this is useful for your agent, a ❤️ like on this page helps others find i
|
|
| 191 |
| `check_circle_wallets_request` | The same checks for a Circle Wallets API request (transfer, contract execution, signing) before it is sent to Circle; approvals, raw messages and wallet upgrades are held | Nothing |
|
| 192 |
| `check_delegation` | An EIP-7702 authorization before signing: always held, naming the contract and whether it is valid on every chain | Nothing |
|
| 193 |
| `check_user_operation` | An ERC-4337 UserOperation from a smart account (Coinbase Smart Wallet, Safe, Kernel, Nexus, SimpleAccount), call by call: an approval hidden in a batch is held, payments to the same payee are summed | Nothing |
|
| 194 |
-
| `verify_settlement` | **After** settlement: the mined receipt must hold exactly the approved
|
| 195 |
| `verify_gateway_balances` | **After** a Circle Gateway payment: the payer's balance went down, and the payee's up, by at least the amount | Nothing (you pass the balances) |
|
|
|
|
| 196 |
| `check_payment_with_model` | Full review by SRA-RiskGate-4B over your policy, the payment and your verification results | This model served locally (for example with Ollama) |
|
| 197 |
|
| 198 |
```json
|
|
@@ -207,10 +210,10 @@ Pass the payment's own text as `untrusted_text` so self-asserted claims are held
|
|
| 207 |
|
| 208 |
## 📦 Python SDK: One Call Before Every Payment (PyPI)
|
| 209 |
|
| 210 |
-
The `sra-riskgate` SDK runs fast deterministic checks before the model is involved: an offline match against the OFAC SDN list's crypto addresses (a dated snapshot, not a screening service), supported asset and chain, address and amount validation, a per-payment ceiling, USDC depeg in both directions, and a scan for payment text that claims its own verification. From 0.8.0 it can also hold the first payment to a new payee (`known_recipients`) and always reject addresses you block (`blocked_addresses`). It never raises on bad payment data: invalid payments are rejected and anything unexpected becomes `hold`. From 0.9.0, `check_transaction(tx, ...)` checks the exact transaction an agent is about to sign: a USDC `transfer` gets the same checks, and token approvals (including unlimited `approve()`), other functions, other contracts and native ETH are held. From 0.11.0, check_authorization(typed_data, ...) does the same for x402 payments, which the agent pays by signing an EIP-3009 authorization instead of sending a transaction: the signature must be for USDC on that chain, from the agent’s wallet, and valid for at most an hour by default, and the decoded payment then gets every check above. From 0.12.0, Circle Arc is supported (5042 mainnet, 5042002 testnet): on Arc, USDC is the native asset, so a plain native send is checked as a USDC payment, read at 18 decimals and rounded up to a whole micro-USDC before the payment check. From 0.12.1, EIP-7702 code delegation is always held (`CODE_DELEGATION`): a type-4 transaction or any `authorizationList` hands the whole account to contract code, on every chain if signed with chain id 0, and `check_delegation()` holds a signed authorization before the agent signs it. From 0.13.0, Circle Gateway batched x402 payments (nanopayments) are checked: an authorization signed for Gateway's `GatewayWalletBatched` domain with Circle's GatewayWallet contract gets its own validity limit (default 8 days, since Gateway requires at least 3 and Circle's SDK signs for 7) and every payment check above, while a look-alike Gateway contract is held. Shown live on Arc Testnet: a Gateway payment approved and accepted by Circle, three unsafe ones stopped before signing. From 0.14.0, Circle Wallets (developer-controlled) requests are checked before they are sent to Circle, which signs as soon as it accepts them: transfers, contract executions (an `approve()` is held), typed-data and transaction signing, with `sign/message` and wallet upgrades always held. `guard_circle_wallets()` wraps Circle's Python SDK so blocked requests never reach Circle (`pip install "sra-riskgate[circle]"`). Shown live on Arc Testnet: a USDC payment from a Circle wallet approved and completed, an unlimited approval, an unknown payee and an unlimited permit stopped before reaching Circle. From 0.15.0, a payee that imitates one of your known payees (address poisoning: the same first and last characters, such as `0x2ffb…b7ee` for `0x2ffb88…472deb7ee`) is rejected as `LOOKALIKE_RECIPIENT`, naming the payee it imitates. From 0.16.0, pass the sender's account code (the result of `eth_getCode`) as `account_code`: an account already delegated through EIP-7702 to a contract you did not expect is held as `ACCOUNT_DELEGATED` and the agent is told to stop signing, because that contract can move the wallet's funds without another signature (list the delegates you trust in `expected_delegates`). Shown live on Base Sepolia (2026-10-30): an agent's USDC transfer ([tx](https://sepolia.basescan.org/tx/0x575f36cbd56e323e4191de267fe8c229900a85fab925d3c16d6c4ee3da6a67f2)) and an x402 EIP-3009 payment ([tx](https://sepolia.basescan.org/tx/0x22c23ed654570f6c96a2beea478232aa8b72a3215ecacbad095c9e149f87be1f)) were approved and settled on chain, while an unlimited approval, a look-alike payee, a 30-day x402 authorization and a self-vouching request were stopped before signing. From 0.17.0, smart accounts are covered: `check_user_operation(user_op, chain_id=...)` decodes the calls an ERC-4337 UserOperation makes (Coinbase Smart Wallet, CDP smart accounts, Safe, Kernel, Nexus, SimpleAccount) and checks each one, so an unlimited `approve()` hidden in a batch next to a payment is held and payments to the same payee are summed against your limit; self-calls, delegatecalls and unexpected paymasters are held too. Tested against callData produced by viem and permissionless for seven account types. From 0.18.0, the SDK also checks what actually settled: `verify_settlement(receipt, ...)` confirms a mined receipt holds exactly the approved USDC payment (right payer, payee and amount, and for x402 the approved authorization), and `verify_gateway_balances(...)` confirms a Circle Gateway payment from balances read before and after. An x402 server asking for a signature valid longer than an hour (`maxTimeoutSeconds`) is held before the agent signs.
|
| 211 |
|
| 212 |
```bash
|
| 213 |
-
pip install --upgrade "sra-riskgate>=0.
|
| 214 |
```
|
| 215 |
|
| 216 |
```python
|
|
|
|
| 119 |
[](https://flow-kg4x.vercel.app/row)
|
| 120 |
[](https://gist.github.com/sriram1983007-dev/8cd44e78adec20a0157368ec38c2fb42)
|
| 121 |
[](https://gist.github.com/sriram1983007-dev/1555e11a57682496f710a8224415c9e2)
|
| 122 |
+
[](https://gist.github.com/sriram1983007-dev/1d915320d85c7ed12a6044e42b382a40)
|
| 123 |

|
| 124 |
|
| 125 |
**SRA-RiskGate-4B checks a stablecoin payment before an AI agent sends it, and answers `approve`, `hold` or `reject`** with reason codes. It is a 4B model, fine-tuned from `Qwen/Qwen3-4B-Instruct-2507`, that runs on a laptop.
|
|
|
|
| 147 |
- **Base Sepolia, independently re-checked:** an approved 0.01 USDC payment ([tx](https://sepolia.basescan.org/tx/0xf12e9084becefd94fa6e26e54761fbfc8f3c04215d7fc724d0fca6077ba084fc)) was read back from the chain and verified, and a 2.00 USDC payment to an unknown payee was held before signing. Flow Executor, an independent agent settlement verifier, re-checked both from the chain ([log](https://gist.github.com/sriram1983007-dev/35eab0e934a512346193bcdb5b12d9cf) · [Flow Executor's page](https://flow-kg4x.vercel.app/row)).
|
| 148 |
- **Circle Gateway on Arc testnet:** one agent task, three proposed payments. One was approved, accepted by Gateway and settled to the payee (agent 0.09 → 0.08 USDC, payee 0.01 → 0.02); an unlimited approval was held and a look-alike payee rejected, neither signed ([log](https://gist.github.com/sriram1983007-dev/8cd44e78adec20a0157368ec38c2fb42)).
|
| 149 |
- **Grok as the paying agent:** Grok (grok-4.7) refused both attacks on its own; told to submit everything to the gate, it got APPROVE for the real invoice, HOLD for the unlimited approval and REJECT for the look-alike ([logs](https://gist.github.com/sriram1983007-dev/1555e11a57682496f710a8224415c9e2)).
|
| 150 |
+
- **Someone else's agent, on mainnet:** Minimum Viable Agent's 25.075 USDG loan repayment on Robinhood Chain was pulled by the lender's contract, so there was nothing to sign. It was found on chain by amount and time and checked with `verify_settlement`: exactly 25.075 USDG to the lender, nothing else moved, allowance left 0. The agent confirmed the result publicly ([tx](https://robinhoodchain.blockscout.com/tx/0xe85c07f5d50f14f9ba33ba372193982a0fea47791c1e431732a1d424eb2fb481) · [check](https://gist.github.com/sriram1983007-dev/1d915320d85c7ed12a6044e42b382a40) · [confirmation](https://x.com/Agent_Minimum/status/2118130199283794342)).
|
| 151 |
|
| 152 |
These runs used the library's deterministic checks, not this model.
|
| 153 |
|
|
|
|
| 181 |
|
| 182 |
## 🔌 Use It From an AI Agent (MCP)
|
| 183 |
|
| 184 |
+
[`sra-riskgate-mcp`](https://pypi.org/project/sra-riskgate-mcp/) gives Claude Desktop, Cursor and other MCP clients twelve tools: nine to call **before** paying, two to confirm the payment **after** it settles, and one for the standing allowances a pull payment can draw on:
|
| 185 |
|
| 186 |
| Tool | What it does | Needs |
|
| 187 |
| --- | --- | --- |
|
|
|
|
| 193 |
| `check_circle_wallets_request` | The same checks for a Circle Wallets API request (transfer, contract execution, signing) before it is sent to Circle; approvals, raw messages and wallet upgrades are held | Nothing |
|
| 194 |
| `check_delegation` | An EIP-7702 authorization before signing: always held, naming the contract and whether it is valid on every chain | Nothing |
|
| 195 |
| `check_user_operation` | An ERC-4337 UserOperation from a smart account (Coinbase Smart Wallet, Safe, Kernel, Nexus, SimpleAccount), call by call: an approval hidden in a batch is held, payments to the same payee are summed | Nothing |
|
| 196 |
+
| `verify_settlement` | **After** settlement: the mined receipt must hold exactly the approved payment (payer, payee, amount, and for x402 the approved authorization). USDC by default; from 0.12.0 also `token="USDT"`, `"USDB"` or `"USDG"`, or any ERC-20 contract with its `decimals` | Nothing (you pass the receipt) |
|
| 197 |
| `verify_gateway_balances` | **After** a Circle Gateway payment: the payer's balance went down, and the payee's up, by at least the amount | Nothing (you pass the balances) |
|
| 198 |
+
| `check_allowances` | For pull payments (loan repayments, subscriptions), which need no new signature: the owner's standing allowances, `{spender: allowance}`. Unlimited, oversized or unexpected ones are held; one held by a sanctioned or blocked spender is rejected. Limits from `SRA_MAX_ALLOWANCE`, `SRA_EXPECTED_SPENDERS` and `SRA_BLOCKED_ADDRESSES` | Nothing (you pass the allowances) |
|
| 199 |
| `check_payment_with_model` | Full review by SRA-RiskGate-4B over your policy, the payment and your verification results | This model served locally (for example with Ollama) |
|
| 200 |
|
| 201 |
```json
|
|
|
|
| 210 |
|
| 211 |
## 📦 Python SDK: One Call Before Every Payment (PyPI)
|
| 212 |
|
| 213 |
+
The `sra-riskgate` SDK runs fast deterministic checks before the model is involved: an offline match against the OFAC SDN list's crypto addresses (a dated snapshot, not a screening service), supported asset and chain, address and amount validation, a per-payment ceiling, USDC depeg in both directions, and a scan for payment text that claims its own verification. From 0.8.0 it can also hold the first payment to a new payee (`known_recipients`) and always reject addresses you block (`blocked_addresses`). It never raises on bad payment data: invalid payments are rejected and anything unexpected becomes `hold`. From 0.9.0, `check_transaction(tx, ...)` checks the exact transaction an agent is about to sign: a USDC `transfer` gets the same checks, and token approvals (including unlimited `approve()`), other functions, other contracts and native ETH are held. From 0.11.0, check_authorization(typed_data, ...) does the same for x402 payments, which the agent pays by signing an EIP-3009 authorization instead of sending a transaction: the signature must be for USDC on that chain, from the agent’s wallet, and valid for at most an hour by default, and the decoded payment then gets every check above. From 0.12.0, Circle Arc is supported (5042 mainnet, 5042002 testnet): on Arc, USDC is the native asset, so a plain native send is checked as a USDC payment, read at 18 decimals and rounded up to a whole micro-USDC before the payment check. From 0.12.1, EIP-7702 code delegation is always held (`CODE_DELEGATION`): a type-4 transaction or any `authorizationList` hands the whole account to contract code, on every chain if signed with chain id 0, and `check_delegation()` holds a signed authorization before the agent signs it. From 0.13.0, Circle Gateway batched x402 payments (nanopayments) are checked: an authorization signed for Gateway's `GatewayWalletBatched` domain with Circle's GatewayWallet contract gets its own validity limit (default 8 days, since Gateway requires at least 3 and Circle's SDK signs for 7) and every payment check above, while a look-alike Gateway contract is held. Shown live on Arc Testnet: a Gateway payment approved and accepted by Circle, three unsafe ones stopped before signing. From 0.14.0, Circle Wallets (developer-controlled) requests are checked before they are sent to Circle, which signs as soon as it accepts them: transfers, contract executions (an `approve()` is held), typed-data and transaction signing, with `sign/message` and wallet upgrades always held. `guard_circle_wallets()` wraps Circle's Python SDK so blocked requests never reach Circle (`pip install "sra-riskgate[circle]"`). Shown live on Arc Testnet: a USDC payment from a Circle wallet approved and completed, an unlimited approval, an unknown payee and an unlimited permit stopped before reaching Circle. From 0.15.0, a payee that imitates one of your known payees (address poisoning: the same first and last characters, such as `0x2ffb…b7ee` for `0x2ffb88…472deb7ee`) is rejected as `LOOKALIKE_RECIPIENT`, naming the payee it imitates. From 0.16.0, pass the sender's account code (the result of `eth_getCode`) as `account_code`: an account already delegated through EIP-7702 to a contract you did not expect is held as `ACCOUNT_DELEGATED` and the agent is told to stop signing, because that contract can move the wallet's funds without another signature (list the delegates you trust in `expected_delegates`). Shown live on Base Sepolia (2026-10-30): an agent's USDC transfer ([tx](https://sepolia.basescan.org/tx/0x575f36cbd56e323e4191de267fe8c229900a85fab925d3c16d6c4ee3da6a67f2)) and an x402 EIP-3009 payment ([tx](https://sepolia.basescan.org/tx/0x22c23ed654570f6c96a2beea478232aa8b72a3215ecacbad095c9e149f87be1f)) were approved and settled on chain, while an unlimited approval, a look-alike payee, a 30-day x402 authorization and a self-vouching request were stopped before signing. From 0.17.0, smart accounts are covered: `check_user_operation(user_op, chain_id=...)` decodes the calls an ERC-4337 UserOperation makes (Coinbase Smart Wallet, CDP smart accounts, Safe, Kernel, Nexus, SimpleAccount) and checks each one, so an unlimited `approve()` hidden in a batch next to a payment is held and payments to the same payee are summed against your limit; self-calls, delegatecalls and unexpected paymasters are held too. Tested against callData produced by viem and permissionless for seven account types. From 0.18.0, the SDK also checks what actually settled: `verify_settlement(receipt, ...)` confirms a mined receipt holds exactly the approved USDC payment (right payer, payee and amount, and for x402 the approved authorization), and `verify_gateway_balances(...)` confirms a Circle Gateway payment from balances read before and after. An x402 server asking for a signature valid longer than an hour (`maxTimeoutSeconds`) is held before the agent signs. From 0.19.0, `verify_settlement` checks any ERC-20 on any EVM chain, and from 0.20.0 named stablecoins fill in the contract and decimals (`token="USDT"` on Ethereum, `"USDB"` from Bridge on Ethereum and Base, `"USDG"` on Ethereum and Robinhood Chain, and USDC), each read on chain before release. 0.20.0 also adds `check_allowances(owner, {spender: allowance})` for pull payments such as loan repayments and subscriptions, which need no new signature: an unlimited, oversized or unexpected standing allowance is held, and one held by a sanctioned or blocked spender is rejected. Checks before signing remain USDC-only.
|
| 214 |
|
| 215 |
```bash
|
| 216 |
+
pip install --upgrade "sra-riskgate>=0.20.0"
|
| 217 |
```
|
| 218 |
|
| 219 |
```python
|