Wraith client with your API key, then use it to create or retrieve WraithAgent instances. Every agent operation — sending payments, scanning for incoming transfers, invoicing, scheduled payments, and privacy analysis — is available through the agent or through natural language via agent.chat().
Wraith class
Constructor
WraithConfig
Your Wraith platform API key. Keys start with
wraith_live_ for production and wraith_test_ for testnet.Override the API base URL. Defaults to
https://api.wraith.dev. Useful for self-hosted or local development setups.Bring-your-own-model configuration. Omit this to use Wraith’s default Gemini-powered AI.
wraith.createAgent(config)
Create a new agent with a .wraith name, stealth keys, and an on-chain identity. Returns a WraithAgent instance.
AgentConfig
The agent’s name. Becomes
name.wraith on-chain. Must be unique across the platform.The chain or chains the agent operates on. Pass a single
Chain value, an array of Chain values, or Chain.All to cover all supported chains.The owner wallet address. This wallet controls the agent and is required for key export.
An EIP-191 signature proving ownership of the wallet address.
The message that was signed. Provided for signature verification. Optional if the platform uses a fixed message.
Promise<WraithAgent>
wraith.agent(agentId)
Connect to an existing agent by its UUID. This method does not make a network call — it returns a WraithAgent instance bound to the given ID. Any subsequent operation on the instance will make the appropriate API request.
WraithAgent
wraith.getAgentByWallet(walletAddress)
Look up an agent by its owner wallet address.
Promise<WraithAgent>
wraith.getAgentByName(name)
Look up an agent by its .wraith name.
Promise<WraithAgent>
wraith.listAgents()
List all agents associated with your API key.
Promise<AgentInfo[]>
WraithAgent class
WraithAgent is returned by wraith.createAgent(), wraith.getAgentByWallet(), and wraith.getAgentByName(). It provides all agent operations.
agent.info
The agent’s identity, available synchronously after the agent is resolved.
AgentInfo
agent.chat(message, conversationId?)
Send a natural language message to the AI agent and receive a response. The agent has access to 17 tools (see AI tools below) and can execute on-chain operations autonomously.
conversationId from the previous response:
Parameters
The natural language message to send to the agent.
The ID of an existing conversation to continue. Omit to start a new conversation.
Promise<ChatResponse>
agent.getStatus()
Get the agent’s current operational status, including balance and activity statistics.
Promise<object>
agent.getBalance()
Get the agent’s balance across all assets on its active chains.
Promise<Balance>
agent.scanPayments()
Scan on-chain announcements for incoming stealth payments addressed to this agent. Returns all detected unspent payments.
Promise<Payment[]>
agent.exportKey(signature, message)
Export the agent’s private key from the TEE. Requires a fresh wallet signature from the agent’s owner wallet as proof of authorization. The private key never leaves the TEE except through this authenticated export.
A fresh EIP-191 signature from the agent’s owner wallet.
The exact message that was signed.
Promise<{ secret: string }>
agent.getConversations()
List all conversations with this agent.
Promise<Conversation[]>
agent.getMessages(conversationId)
Retrieve all messages from a specific conversation.
The UUID of the conversation to retrieve.
Promise<Array<{ role: string; text: string }>>
agent.deleteConversation(conversationId)
Delete a conversation and all its messages. This action is permanent.
The UUID of the conversation to delete.
Promise<void>
agent.getNotifications()
Get all notifications for this agent, along with the count of unread notifications.
Promise<{ notifications: Notification[]; unreadCount: number }>
agent.markNotificationsRead()
Mark all notifications for this agent as read.
Promise<void>
agent.clearNotifications()
Delete all notifications for this agent.
Promise<void>
AI-powered tools
When you callagent.chat(), the agent’s language model has access to these 17 tools. You do not call these directly — the AI invokes them automatically based on your natural language request.
| Tool | What it does |
|---|---|
send_payment | Send a stealth payment to a meta-address or .wraith name |
pay_agent | Pay another agent by .wraith name |
scan_payments | Scan on-chain announcements for incoming stealth payments |
get_balance | Check wallet balance (native asset + tokens) |
create_invoice | Create a payment invoice with a shareable link |
check_invoices | Check status of existing invoices |
withdraw | Withdraw funds from a specific stealth address |
withdraw_all | Withdraw from all detected stealth addresses |
schedule_payment | Schedule a recurring stealth payment |
list_schedules | List all scheduled payments |
cancel_schedule | Cancel a scheduled payment |
resolve_name | Look up a .wraith name on-chain |
register_name | Register a .wraith name on-chain |
get_agent_info | Get full agent identity and TEE attestation status |
fund_wallet | Request testnet tokens from the chain faucet |
privacy_check | Run a privacy analysis with a scored report |
Example: invoicing
Example: privacy check
Authentication
Every request the SDK makes includes the following headers automatically:| Header | Value | Purpose |
|---|---|---|
Authorization | Bearer wraith_... | Platform API key authentication |
X-AI-Provider | "openai" / "claude" / "gemini" | Specifies the AI provider when using bring-your-own-model |
X-AI-Key | sk-... | Your AI provider API key when using bring-your-own-model |
Wraith client handles them based on the WraithConfig you provide.
Error handling
All SDK methods throw on failure. The error message comes directly from the server response.Errors are plain
Error instances. Check err.message for the server-provided reason. Future SDK versions may add structured error types with status codes.
