TorqueTorque

Search docs

Search Torque documentation pages and sections

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 routePOST /api/v1/assistant/chat
Legacy aliasPOST /api/assistant/chat (same handler)
Auth (programmatic)Authorization: Bearer sk_live_…
Streaming?stream=true → SSE (text/event-stream)
Client executes txstrue — 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

CallerRequirement
Programmatic / serverAuthorization: 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

AssistantChatPostBody
{
  "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)

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

toolNameKey result fields
swap_tokenstokenIn, tokenOut, amountIn, chainId, transaction, …
transfer_tokenstoken, amount, recipient, chainId, transaction
lend_tokenstoken, amount, protocol, chainId, transaction
borrow_tokenscollateralToken, 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 typePayload
delta{ text } — incremental assistant text
correction{ text } — full text replacement
done{ functionResults } — final tool payloads
error{ message }
(terminal)data: [DONE]
assistant-chat.sh
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)

assistant-chat.sh
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

  1. Your server calls chat with business key + wallet context.
  2. Read-only answers appear in content.
  3. Action tools add functionResults with prepared transactions.
  4. User confirms in your UI (or Torque app).
  5. Client signs and POSTs to /api/v1/actions/** with smart wallet JWT.

End-user prompt examples live in the Wallet Guide.

Was this helpful?