Assistant API
Call Torque Assistant programmatically with a business API key. The assistant returns conversational text and optional functionResults for confirmable on-chain actions — your client signs and submits via the Actions API.
At a glance
| Preferred route | POST /api/v1/assistant/chat |
| Legacy alias | POST /api/assistant/chat (same handler) |
| Auth (programmatic) | Authorization: Bearer sk_live_… |
| Streaming | ?stream=true → SSE (text/event-stream) |
| Client executes txs | true — functionResults → Actions API |
Who this is for
Fintech shells, notification products, and partner dashboards that want conversational portfolio intelligence and draft on-chain actions without rebuilding Torque's tool pipeline. Pass a walletAddress in context to personalize responses.
Authentication
| Caller | Requirement |
|---|---|
| Programmatic / server | Authorization: Bearer sk_live_… required |
| In-app browser (Torque origins) | May call without business key |
| Free tier (wallet in context) | 20 messages / 30 days → 402 assistant_credits_exhausted |
See Authentication for key setup. Do not call /api/assistant/functions directly — it is internal infrastructure invoked by the chat pipeline.
Request body
{
"messages": [
{ "role": "user", "content": "What is the price of ETH?" }
],
"context": {
"walletAddress": "0x…",
"solanaWalletAddress": "…",
"chainId": 8453,
"localCurrency": "USD",
"authJWT": "<smart_wallet_jwt>"
},
"conversationId": "optional-thread-id"
}Required: messages (array).
Important context fields: walletAddress, chainId, authJWT (required for protected tools that touch portfolio or draft transactions). Optional enrichment: portfolioData, userProfile, userIntents.
Response (JSON)
{
"content": [
{ "type": "text", "text": "Here's the best route I found…" }
],
"functionResults": [
{
"toolName": "swap_tokens",
"result": {
"success": true,
"requiresConfirmation": true,
"tokenIn": "USDC",
"tokenOut": "ETH",
"amountIn": "100",
"chainId": 8453,
"transaction": { … }
}
}
]
}functionResults is omitted when empty. Read-only tools return answers in content only.
functionResults by tool
| toolName | Key result fields |
|---|---|
| swap_tokens | tokenIn, tokenOut, amountIn, chainId, transaction, … |
| transfer_tokens | token, amount, recipient, chainId, transaction |
| lend_tokens | token, amount, protocol, chainId, transaction |
| borrow_tokens | collateralToken, borrowToken, amounts, protocol, … |
Confirmable actions set result.success and result.requiresConfirmation: true. Submit signed payloads through Actions API with a smart wallet JWT.
Streaming
Append ?stream=true for Server-Sent Events.
| Event type | Payload |
|---|---|
| delta | { text } — incremental assistant text |
| correction | { text } — full text replacement |
| done | { functionResults } — final tool payloads |
| error | { message } |
| (terminal) | data: [DONE] |
curl -sS -N -X POST "https://app.torque.fi/api/v1/assistant/chat?stream=true" \
-H "Authorization: Bearer $TORQUE_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [{ "role": "user", "content": "Trade 100 USD for ETH on Base" }],
"context": { "walletAddress": "0x…", "chainId": 8453 }
}'Example (non-streaming)
export TORQUE_KEY="sk_live_…"
curl -sS -X POST "https://app.torque.fi/api/v1/assistant/chat" \
-H "Authorization: Bearer $TORQUE_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [{ "role": "user", "content": "What is my net worth?" }],
"context": {
"walletAddress": "0x…",
"chainId": 8453
}
}' | jq '.content, .functionResults'Execution flow
- Your server calls chat with business key + wallet context.
- Read-only answers appear in
content. - Action tools add
functionResultswith prepared transactions. - User confirms in your UI (or Torque app).
- Client signs and POSTs to
/api/v1/actions/**with smart wallet JWT.
End-user prompt examples live in the Wallet Guide.