---
name: wraith-nexus
description: Call 250+ AI models (Claude, Gemini, Grok, GLM, Qwen, DeepSeek, FLUX, Whisper, TTS, embeddings) through WRAITH Nexus at ai.dagentx.com, paid in USDC on Monad. Use when the user wants to generate text, images, speech, transcriptions or embeddings with a model other than the current one, compare models, run a model privately (Venice, NEAR AI TEE), or when an agent needs to pay for inference itself with x402 or a crk_ API key.
---

# WRAITH Nexus

One OpenAI-compatible API for every model, billed from a USDC balance on Monad (chain 143).

- Base URL: `https://ai.dagentx.com/v1` (Anthropic clients: `https://ai.dagentx.com`)
- Model list with prices: `https://ai.dagentx.com/models` or `GET /v1/models` (authenticated)
- Full docs: `https://ai.dagentx.com/llms.txt`

## Choosing how to authenticate

Check in this order and use the first that is available. Never print keys or private keys.

1. **API key** in `WRAITH_NEXUS_KEY` (starts with `crk_`): send `Authorization: Bearer $WRAITH_NEXUS_KEY`.
2. **Agent wallet** in `AGENT_KEY` (EVM private key holding USDC on Monad): pay per call with x402, or prepay and sign in (see below).
3. Neither: tell the user to create a key at https://ai.dagentx.com/account (connect wallet, deposit USDC, Create key) and set `WRAITH_NEXUS_KEY`. Do not ask for a private key in chat.

## Endpoints

| Task | Endpoint | Example model |
|---|---|---|
| Chat / reasoning / vision | `POST /v1/chat/completions` (OpenAI) or `POST /v1/messages` (Anthropic) | `venice/zai-org-glm-5`, `near/anthropic/claude-sonnet-5` |
| Embeddings | `POST /v1/embeddings` | `venice/text-embedding-bge-m3` |
| Image | `POST /v1/images/generations` | `venice/flux-2-pro` |
| Text to speech | `POST /v1/audio/speech` | `venice/tts-kokoro` |
| Speech to text | `POST /v1/audio/transcriptions` (multipart) | `venice/openai/whisper-large-v3` |
| Balance and settlements | `GET /relay/account` | |
| Your call records | `GET /relay/usage?fromSeq=0`, `GET /relay/proof/<seq>` | |

Model ids are prefixed by provider (`venice/…`, `near/…`); use them exactly as listed. Streaming (`"stream": true`) is supported for chat.

## With an API key

```bash
curl -s https://ai.dagentx.com/v1/chat/completions \
  -H "Authorization: Bearer $WRAITH_NEXUS_KEY" -H "content-type: application/json" \
  -d '{"model":"venice/zai-org-glm-5","max_tokens":500,"messages":[{"role":"user","content":"Hello"}]}'
```

```python
from openai import OpenAI
client = OpenAI(base_url="https://ai.dagentx.com/v1", api_key=os.environ["WRAITH_NEXUS_KEY"])
```

## With an agent wallet (x402, no key)

Per call: POST to a paid endpoint without credentials. The 402 response carries a `PAYMENT-REQUIRED` header (base64 JSON, x402 v2) asking for USDC on `eip155:143`, scheme `exact`. Sign it and retry with `PAYMENT-SIGNATURE`. Settlement is gasless for the agent. The amount is the worst case for the request; unused value stays as the wallet's credit. Per-call payments are capped (about $1); prepay for larger jobs.

```js
import { x402Client, x402HTTPClient } from "@x402/core/client";      // npm i @x402/core@2.29.0 @x402/evm@2.29.0 viem
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const agent = privateKeyToAccount(process.env.AGENT_KEY);
const c = new x402Client();
c.setSpendControls({ maxAmountPerPayment: "$1" });
registerExactEvmScheme(c, { signer: agent, networks: ["eip155:143"] });
const http = new x402HTTPClient(c);
let res = await fetch(url, init);
if (res.status === 402) {
  const req = http.getPaymentRequiredResponse((h) => res.headers.get(h), await res.json());
  res = await fetch(url, { ...init, headers: { ...init.headers, ...http.encodePaymentSignatureHeader(await http.createPaymentPayload(req)) } });
}
```

Prepay: `POST /v1/x402/top-up?usd=10` (pay the 402 the same way; $1 to $1,000). Then on each call send `SIGN-IN-WITH-X: base64(JSON {address, message, signature, chainId: 143})`, where `message` is a fresh EIP-4361 SIWE message with domain `ai.dagentx.com`, `uri` equal to the exact URL being called, chain id 143, issued now, a random nonce (single use), signed by the wallet. A complete script: `https://ai.dagentx.com/x402-agent.mjs`.

## Rules

- Always set `max_tokens`: the request reserves its worst-case cost up front.
- Status codes: 401 bad/revoked key or sign-in; 402 payment required; 429 balance too low, daily cap or rate limit (read the message); 503 retry shortly.
- Before spending more than a few dollars for the user, say the expected cost (prices on /models).
- Do not send secrets, private keys or personal data the user has not approved for a third-party model.
