Skip to main content

Step 1: Install SDK

npm add @orynt/ai-x402
Set your wallet private key in .env:
PRIVATE_KEY=<your_wallet_private_key>

Step 2: Initialize SDK

import { Orynt } from "@orynt/ai-x402";

const ai = new Orynt({
  baseUrl: "https://api.oryntai.xyz/api/v1",
  network: "solana-devnet",
});

Step 3: Chat Example

await ai.chat({
  model: "gpt-4.1",
  messages: [{ role: "user", content: "Hello" }],
});

await ai.chat({
  model: "gpt-4.1",
  input: "Explain the x402 in one sentence.",
});

await ai.chat({
  model: "gpt-4.1",
  prompt: "Explain the x402 in one sentence.",
});

Step 3: Image Generation

await ai.generateImage({
  model: "dall-e-3",
  prompt: "A futuristic city skyline at sunset",
  n: 1,
  width: 1024,
  height: 1024,
});

Step 3: Text-to-Speech

await ai.textToSpeech({
  model: "gpt-4o-mini-tts",
  text: "Hello, welcome to X402 AI service.",
  voice: "alloy",
  format: "mp3",
});

Step 4: Supported Networks

  • base
  • base-sepolia
  • solana
  • solana-devnet
  • polygon
  • polygon-amoy
Specify network via network in SDK, or X-Network in REST requests.

Step 5: Payment Flow

  • Requests handle x402 micropayments via PayAI
  • If payment is required, the SDK generates a signed payload
  • Request is automatically retried after payment
  • Failed requests refund your token automatically
For REST requests, include X-PAYMENT header with the signed proof.

Step 6: Next Steps

  • Explore the API Reference
  • Try other models: gradient-stratos, whisper-1, etc.
  • Generate embeddings, text-to-speech, or image outputs seamlessly
Orynt abstracts provider logic — just change model and network to switch AI backends.