### Install @solrouter/sdk with npm Source: https://docs.solrouter.com/docs/build/quickstart Install the SDK using npm. The SDK handles encryption, routing, and decryption for you. ```bash npm install @solrouter/sdk ``` -------------------------------- ### Install @solrouter/sdk with yarn Source: https://docs.solrouter.com/docs/build/quickstart Install the SDK using yarn. The SDK handles encryption, routing, and decryption for you. ```bash yarn add @solrouter/sdk ``` -------------------------------- ### Install @solrouter/sdk Source: https://docs.solrouter.com/docs/integrations/typescript-sdk Install the SDK package using npm. ```APIDOC ## Install @solrouter/sdk ### Description Install the SDK package using npm. ### Command ```bash npm install @solrouter/sdk ``` ``` -------------------------------- ### Install @solrouter/sdk with pnpm Source: https://docs.solrouter.com/docs/build/quickstart Install the SDK using pnpm. The SDK handles encryption, routing, and decryption for you. ```bash pnpm add @solrouter/sdk ``` -------------------------------- ### Example response from /tee/public-key Source: https://docs.solrouter.com/docs/api-reference/tee/public-key Example JSON response. Values shortened. The response has no top-level 'success' field. ```json { "publicKey": "base64...=", "publicKeySha256": "hex...", "algorithm": "x25519", "teeType": "INTEL-TDX-PHALA" } ``` -------------------------------- ### Successful response for GET /agents/v1/anonymity-set Source: https://docs.solrouter.com/docs/api-reference/agent-privacy/swaps/agents/v1/anonymity-set/get Example 200 response showing the bucket, pool depth, strength, and raw data. The strength field indicates whether the amount snaps to a standard denomination bucket. ```JSON { "bucket": "SOL_1", "poolDepth": 42, "strength": "strong", "raw": {} } ``` -------------------------------- ### BRAID path example response Source: https://docs.solrouter.com/docs/api-reference/agent Example JSON response for the BRAID reasoning path. The braidTrace field is included only when braidOptions.includeTrace is set to true. ```json { "success": true, "reply": "## Marginfi vs Kamino Lending Comparison\n\n...", "reasoning": "braid", "braidTrace": { "grdId": "comparison", "intent": "comparison", "nodes": [ { "nodeId": "...", "label": "...", "type": "action", "status": "completed" } ], "totalDurationMs": 0, "totalTokens": 0 }, "usage": { "promptTokens": 0, "completionTokens": 0, "totalTokens": 0 }, "iterations": 1, "model": "gpt-oss:20b", "provider": "nosana", "cost": "FREE", "freeMessagesRemaining": 0 } ``` -------------------------------- ### POST /agent request example Source: https://docs.solrouter.com/docs/api-reference/agent Sends a prompt to the SolRouter agent using a specified model and tool usage enabled. ```bash curl -X POST "https://api.solrouter.com/agent" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "Compare Marginfi vs Kamino lending on Solana", "model": "gpt-oss:20b", "useTools": true }' ``` -------------------------------- ### POST /agents/v1/swaps/oneshot/{id}/execute Source: https://docs.solrouter.com/docs/api-reference/agent-privacy/swaps/agents/v1/swaps/oneshot/id/execute/post Submits the funding transaction signature to start the swap orchestrator for a one-shot session. ```APIDOC ## POST /agents/v1/swaps/oneshot/{id}/execute ### Description After signing and broadcasting the funding transaction from a one-shot session, submit its signature here to start the swap. ### Method POST ### Endpoint `https://api.solrouter.com/agents/v1/swaps/oneshot/{id}/execute` ### Parameters #### Path Parameters - **id** (string, uuid) - Required - The one-shot session ID. #### Request Body - **fundingTxSig** (string) - Required - The signature of the funding transaction. ### Request Example ```json { "fundingTxSig": "5h7Qw2KQz9oA3nP1cVxYtRb8sLmJ4dE6fGh9kU2wXcZ1aBpQ7rT3vN5mY8sD0fL2gH4jK6lM9nP1qR3sT5uV7w" } ``` ### Response #### Success Response (200) - **sessionId** (string) - The session ID. - **status** (string) - The status of the swap (e.g., "running"). - **estimatedSeconds** (number) - Estimated time in seconds for the swap to complete. #### Response Example ```json { "sessionId": "b3d9a1e2-5c4f-4a8b-9e7d-1f2a3b4c5d6e", "status": "running", "estimatedSeconds": 75 } ``` #### Error Responses - **400** - Bad Request - Missing required fields. ```json { "error": "missing_required_fields" } ``` - **404** - Not Found - Session not found. ```json { "error": "missing_required_fields" } ``` ``` -------------------------------- ### Response: 201 success Source: https://docs.solrouter.com/docs/api-reference/agent-privacy/private-balance/agents/v1/wallets/id/encrypt/post Example 201 response body showing a running session with an estimated completion time of 12 seconds. ```json { "sessionId": "b3d9a1e2-5c4f-4a8b-9e7d-1f2a3b4c5d6e", "status": "running", "estimatedSeconds": 12 } ``` -------------------------------- ### POST /agents/v1/swaps/oneshot/{SESSION_ID}/execute Source: https://docs.solrouter.com/docs/build/agent-privacy-api Submits the confirmed transaction signature to start execution of a one-shot swap session. ```APIDOC ## POST /agents/v1/swaps/oneshot/{SESSION_ID}/execute ### Description Submits the confirmed transaction signature to start execution of a one-shot swap session. ### Method POST ### Endpoint https://api.solrouter.com/agents/v1/swaps/oneshot/{SESSION_ID}/execute ### Parameters #### Path Parameters - **SESSION_ID** (string) - Required - The identifier of the one-shot swap session. #### Request Body - **fundingTxSig** (string) - Required - The confirmed transaction signature. ### Request Example ``` curl -X POST "https://api.solrouter.com/agents/v1/swaps/oneshot/SESSION_ID/execute" \ -H "Content-Type: application/json" \ -d '{"fundingTxSig": "..."}' ``` ### Response No response schema is specified in the source. ``` -------------------------------- ### Agent response example Source: https://docs.solrouter.com/docs/api-reference/agent The default JSON response structure returned by the /agent endpoint. ```json { "success": true, "reply": "## Marginfi vs Kamino Lending Comparison\n\n...", "toolCalls": [ { "tool": "web_search", "args": { "query": "Marginfi vs Kamino lending Solana" }, "result": { "...": "..." } }, { "tool": "token_price", "args": { "token": "MNDE" }, "result": { "...": "..." } } ], "usage": { "promptTokens": 0, "completionTokens": 0, "totalTokens": 0 }, "iterations": 4, "model": "gpt-oss:20b", "provider": "nosana", "billing": null, "freeMessagesRemaining": 0 } ``` -------------------------------- ### cURL request to fetch wallet audit log Source: https://docs.solrouter.com/docs/api-reference/agent-privacy/managed-wallets/agents/v1/wallets/id/audit/get Sends a GET request to the audit endpoint with an example wallet ID and query parameters. Requires an Authorization header with a Bearer token. ```bash curl -X GET "https://api.solrouter.com/agents/v1/wallets/f47ac10b-58cc-4372-a567-0e02b2c3d479/audit?limit=100&since=2026-06-01T00%3A00%3A00.000Z" \ -H "Authorization: Bearer " ``` -------------------------------- ### POST /agent Source: https://docs.solrouter.com/docs/api-reference/overview Runs a prompt through the tool-calling agent. ```APIDOC ## POST /agent ### Description Runs a prompt through the tool-calling agent, which includes tools for web search, on-chain data, DEX quotes, and Solana wallet inspection. ### Method POST ### Endpoint /agent ### Request Body - **reasoning** (string) - Optional - Set to 'braid' for guided reasoning. ``` -------------------------------- ### Authorization Header Example Source: https://docs.solrouter.com/docs/api-reference/overview Example of the Authorization header format using a Bearer token. Requests without a valid token may be rejected or metered differently. ```http Authorization: Bearer sk_solrouter_... ``` -------------------------------- ### Example audit log response Source: https://docs.solrouter.com/docs/api-reference/agent-privacy/managed-wallets/agents/v1/wallets/id/audit/get Shows a 200 response with an entries array containing an audit event. The example includes a 'created' event with metadata and a timestamp. ```json { "entries": [ { "event": "created", "metadata": { "owner": "user_123" }, "created_at": "2026-06-09T17:55:00.000Z" } ] } ``` -------------------------------- ### POST /tee/process Source: https://docs.solrouter.com/docs/api-reference/overview Relays a sealed prompt to the enclave. ```APIDOC ## POST /tee/process ### Description Relays one sealed prompt to the enclave and reports usage. ### Method POST ### Endpoint /tee/process ``` -------------------------------- ### cURL request to GET /agents/v1/anonymity-set Source: https://docs.solrouter.com/docs/api-reference/agent-privacy/swaps/agents/v1/anonymity-set/get Sends a GET request to the anonymity-set endpoint with the required bucket query parameter. The response includes pool depth and privacy strength. ```cURL curl -X GET "https://api.solrouter.com/agents/v1/anonymity-set?bucket=SOL_1" ``` -------------------------------- ### cURL request to get encrypted balance Source: https://docs.solrouter.com/docs/api-reference/agent-privacy/private-balance/agents/v1/wallets/id/balance/get Sends a GET request to the balance endpoint with the wallet ID and mints query parameter. Requires an Authorization header with a Bearer token. ```cURL curl -X GET "https://api.solrouter.com/agents/v1/wallets/f47ac10b-58cc-4372-a567-0e02b2c3d479/balance?mints=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v%2CSo11111111111111111111111111111111111111112" \ -H "Authorization: Bearer " ``` -------------------------------- ### POST /agent Source: https://docs.solrouter.com/docs/api-reference/overview Runs a prompt through a tool loop with web search, on-chain data, DEX quotes, and Solana tools. Supports optional guided reasoning (BRAID) and encrypted mode. ```APIDOC ## POST /agent ### Description Runs a prompt through a tool loop with web search, on-chain data, DEX quotes, and Solana tools. Supports optional guided reasoning (BRAID) and encrypted mode. ### Method POST ### Endpoint /agent ### Response #### Success Response (200) - **success** (boolean) - Indicates whether the request succeeded. - **error** (string) - Present when success is false, names the failure. #### Response Example { "success": true } ### Error Handling - **402 insufficient_funds** - Insufficient funds. - **429 guest_limit** - Guest limit reached. - **503 billing_unavailable** - Billing service unavailable. ``` -------------------------------- ### POST /agent Source: https://docs.solrouter.com/docs/api-reference/agent Runs a prompt through Solrouter's agent pipeline with built-in tools, optional guided reasoning (BRAID), and encrypted mode. ```APIDOC ## POST /agent ### Description Runs a prompt through Solrouter's agent pipeline. Unlike a direct chat completion, the agent can call built-in tools: web search, on-chain data, DEX quotes, token prices, and more. The request body selects one of three paths: default tool loop, guided reasoning (BRAID), or encrypted mode. ### Method POST ### Endpoint https://api.solrouter.com/agent ### Parameters #### Request Body - **prompt** (string) - Required - The question or task. Research, comparisons, on-chain analysis, swap quotes, or any task the built-in tools cover. - **model** (string) - Optional - The model that runs the loop and writes the reply. `gpt-oss:20b` (default), `qwen3.8:27b` (uncensored), or `qwen3-coder:30b` (coding). A model with no configured Nosana endpoint returns 501 `nosana_not_configured`. - **useTools** (boolean) - Optional - Defaults to `true`. When `true`, the model can call any built-in tool before it writes the reply. Set `false` to run one plain completion with no tools. This field does not select guided reasoning. - **chatId** (string) - Optional - Conversation id. When present, the backend stores the turn in that chat's history and sends prior turns as context. When absent, the call is stateless. - **reasoning** (string) - Optional - Set `'braid'` to run guided reasoning instead of the tool loop. - **braidOptions** (object) - Optional - BRAID only. `includeTrace: true` adds `braidTrace` to the response. `forceGrdId` picks a GRD by id instead of intent detection. - **encryptedPrompt** (string) - Optional - Encrypted mode. The prompt is encrypted client-side to the enclave public key and packaged as a JSON string with `ciphertext`, `nonce`, `publicKey`, `algorithm`, and `version`. The backend forwards it to the CVM without reading it. ### Response #### Success Response (200) - **braidTrace** (object) - Optional - Present when `braidOptions.includeTrace` is true. #### Error Response (501) - **error** (string) - `nosana_not_configured` when the selected model has no configured Nosana endpoint. ``` -------------------------------- ### Encrypted mode example response Source: https://docs.solrouter.com/docs/api-reference/agent Example JSON response when using encrypted mode. The reply is encrypted to the publicKey provided in the request, and any enclave error will result in an HTTP 500 status. ```json { "success": true, "encrypted": true, "encryptedResponse": { "...": "..." }, "toolCallsCount": 2, "attestation": { "...": "..." }, "privacyGuarantee": { "backendSawPlaintext": false, "toolsExecutedInTEE": true }, "freeMessagesRemaining": 0 } ``` -------------------------------- ### GET /tee/attestation Source: https://docs.solrouter.com/docs/api-reference/overview Returns the TDX quote for the enclave. ```APIDOC ## GET /tee/attestation ### Description Returns the TDX quote when the CVM can reach the dStack agent. ### Method GET ### Endpoint /tee/attestation ``` -------------------------------- ### Check credit balance with client.getBalance() Source: https://docs.solrouter.com/docs/build/quickstart Read the credit balance from the SDK. Calls draw from your plan first, then from USDC credit at $0.02 a call. ```typescript const { balance, balanceFormatted } = await client.getBalance(); console.log(`Balance: ${balanceFormatted}`); ```