Skip to main content
By default, Wraith agents use a hosted Gemini model managed by the platform. You can replace it with your own OpenAI, Claude, or Gemini key — useful when you want to control costs, pin a specific model version, or comply with data residency requirements.
All 17 agent tools work identically regardless of which AI provider you choose. The TEE server adapts the tool declarations to each provider’s function-calling format automatically.

Configure the AI provider

Pass an ai object when constructing the Wraith client. Every agent created from that client will use your specified provider:
import { Wraith, Chain } from "@wraith-protocol/sdk";

const wraith = new Wraith({
  apiKey: "wraith_live_abc123",
  ai: {
    provider: "openai",
    apiKey: "sk-proj-...",
  },
});

Supported providers

Providerai.provider valueAPI key format
Google Gemini"gemini"Gemini API key
OpenAI"openai"sk-...
Anthropic Claude"claude"Anthropic API key (sk-ant-...)

OpenAI

const wraith = new Wraith({
  apiKey: "wraith_live_abc123",
  ai: {
    provider: "openai",
    apiKey: "sk-proj-...",
  },
});

const agent = await wraith.createAgent({
  name: "alice",
  chain: Chain.Horizen,
  wallet: "0x...",
  signature: "0x...",
  message: "Sign to create Wraith agent",
});

// Chat uses your OpenAI key
const res = await agent.chat("send 0.1 ETH to bob.wraith");

Anthropic Claude

const wraith = new Wraith({
  apiKey: "wraith_live_abc123",
  ai: {
    provider: "claude",
    apiKey: "sk-ant-...",
  },
});

Your own Gemini key

Provide your own Gemini key to bypass the platform’s shared quota and control which model version is used:
const wraith = new Wraith({
  apiKey: "wraith_live_abc123",
  ai: {
    provider: "gemini",
    apiKey: "AIza...",
  },
});

How the provider key is used

The SDK passes your AI configuration to the TEE server via HTTP headers on every request:
HeaderValue
AuthorizationBearer wraith_... — your Wraith platform API key
X-AI-Provideropenai, claude, or gemini
X-AI-KeyYour AI provider API key
The TEE server then:
1

Receives your chat message

Your message arrives at the TEE alongside the X-AI-Provider and X-AI-Key headers.
2

Prepares the request

The server assembles the agent’s full identity, chain configuration, and tool declarations in the format your provider expects.
3

Calls your AI provider

The conversation is forwarded to your specified provider using your key. The platform’s default Gemini model is bypassed entirely.
4

Executes tool calls

When the AI returns tool calls (e.g., send_payment, privacy_check), the TEE executes them on-chain and feeds the results back to the model.
5

Returns the response

The final natural-language response is returned to your code in the same ChatResponse shape regardless of provider.
Your AI provider key is used server-side inside the TEE only. It is never stored — it exists in memory for the duration of the request and is then discarded.

Tool compatibility

All agent tools work the same way regardless of provider:
// Identical behaviour with Gemini, OpenAI, or Claude
const res1 = await agent.chat("send 0.1 ETH to bob.wraith");
const res2 = await agent.chat("run a privacy check");
const res3 = await agent.chat("create an invoice for 1 ETH");
const res4 = await agent.chat("scan for payments on all chains");
The toolCalls field on the response always reflects what the model invoked, independent of provider:
const res = await agent.chat("send 0.1 ETH to bob.wraith");
console.log(res.toolCalls);
// [{ name: "send_payment", status: "success" }]

Default vs. bring your own model

AspectDefault (Gemini)Bring your own
CostIncluded in Wraith API usageBilled directly by your AI provider
Model versionWraith’s chosen Gemini modelYour choice
QuotaShared platform quotaYour provider quota
ConfigurationNone requiredPass ai to WraithConfig
Tool compatibilityFullFull
If you’re building a production application and want predictable costs, bringing your own key lets you track AI spend separately in your provider’s billing dashboard.

What’s next

Single-chain guide

Full agent lifecycle walkthrough with working code examples.

Multichain setup

Run one agent across multiple chains simultaneously.

Privacy best practices

Avoid common privacy pitfalls when using stealth payments.

SDK reference

Full WraithConfig and AgentConfig API documentation.