GenX Router API

One API, 40+ AI models. Generate text, images, video, voice, and audio with a single REST endpoint. No provider keys to manage. Built-in billing, webhooks, sessions, and file uploads.

Why GenX Router

GenX Router gives you one API endpoint for 40+ AI models across text, image, video, voice, and audio. Instead of managing separate API keys, SDKs, and billing accounts for every provider, you get a single key and a unified interface.

  • 40+ models, one key — GPT-5.4, Claude, Gemini, Grok, Sora, Veo, Kling, and more. No provider accounts needed.
  • Stateful sessions — Multi-turn chat with automatic context management, compaction, and tool use (web search, code execution, file analysis).
  • File uploads — Upload PDFs, documents, and spreadsheets. Reference them in sessions across multiple messages.
  • Webhooks — Get notified when jobs complete. No polling required for production workloads.
  • Async by design — Submit a job, get a job ID, poll or receive a webhook. Works the same whether it takes 2 seconds or 2 minutes.
  • Volume discounts — Higher tiers unlock better pricing and higher rate limits automatically as you grow.

Quick Start

Three steps to your first generation:

  1. Create an account — Sign up at genx.sh and get 500 free credits.
  2. Create an API key — Go to Dashboard → API Keys. Your key starts with gnxk_.
  3. Make your first call
curl -X POST https://query.genx.sh/api/v1/generate \ -H "Authorization: Bearer gnxk_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "params": { "prompt": "Explain quantum computing in one paragraph" } }'
Base URL: https://query.genx.sh
All endpoints are under /api/v1.

How It Works

Authentication

Include your API key in every request using either method:

  • Authorization: Bearer gnxk_... (recommended)
  • X-Api-Key: gnxk_...

Generate → Poll (or Webhook)

All generation is asynchronous. You submit a job and get back a job ID immediately.

  1. POST /api/v1/generate — pick a model, send params, get a job_id back.
  2. GET /api/v1/jobs/:id — poll until status is completed or failed.
  3. On completion, result_url contains the output (text, image URL, video URL, etc.).

For production, register a webhook endpoint in your dashboard. GenX Router will POST to your URL when a job completes or fails — no polling needed. Webhook payloads include the full job result, usage metrics, and any metadata you attached.

Sessions (Multi-Turn Chat)

For conversational use cases, create a session instead of one-off generates. Sessions maintain message history, support system prompts, and handle context management automatically.

  • Tool use — Models can call web search, code execution, and custom functions within a session.
  • File context — Upload documents via /api/v1/files and reference them in messages.
  • Auto-compaction — When context fills up, summarize history to keep the conversation going.
  • Idempotent messages — Pass an idempotency_key for safe retries.

Metadata & Tracking

Attach up to 16 key-value pairs to any job via the metadata field. Use it to tag jobs with your own user IDs, project names, or tracking codes. Metadata is returned in job responses and webhook payloads.

Code Examples

# Generate an image curl -X POST https://query.genx.sh/api/v1/generate \ -H "Authorization: Bearer gnxk_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "grok-imagine", "params": { "prompt": "A futuristic city skyline at sunset" } }' # Poll for result curl https://query.genx.sh/api/v1/jobs/JOB_ID \ -H "Authorization: Bearer gnxk_YOUR_KEY" # Create a chat session curl -X POST https://query.genx.sh/api/v1/sessions \ -H "Authorization: Bearer gnxk_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "system_prompt": "You are a helpful assistant" }'
// Generate text with Claude Sonnet 4.6 const response = await fetch('https://query.genx.sh/api/v1/generate', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ model: 'claude-sonnet-4-6', params: { prompt: 'Write a haiku about AI' }, }), }); const { job_id } = await response.json(); // Poll for completion const result = await fetch( `https://query.genx.sh/api/v1/jobs/${job_id}`, { headers: { 'Authorization': `Bearer ${API_KEY}` } } ); const job = await result.json();
import requests # Generate a video with Veo 3.1 response = requests.post( "https://query.genx.sh/api/v1/generate", headers={ "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json", }, json={ "model": "veo-3.1", "params": { "prompt": "Aerial shot of ocean waves at golden hour", "duration": 8, "aspect_ratio": "16:9", }, }, ) job_id = response.json()["job_id"] # Poll for result result = requests.get( f"https://query.genx.sh/api/v1/jobs/{job_id}", headers={"Authorization": f"Bearer {API_KEY}"}, ) job = result.json()

Endpoints

Generate

POST /api/v1/generate
Submit a generation job. Returns a job ID immediately.
FieldTypeDescription
modelstringModel ID (e.g. claude-sonnet-4-6, grok-imagine). See model catalog.
paramsobjectModel-specific parameters (prompt, dimensions, duration, etc.)
metadataobject?Optional key-value pairs (up to 16 keys, string values)

Jobs

GET /api/v1/jobs/:id
Get job status, result URL, and usage.
GET /api/v1/jobs
List jobs. Supports ?status= filter and cursor pagination.
GET /api/v1/jobs/:id/result
Get just the result URL for a completed job.
GET /api/v1/jobs/:id/file
Download the result file directly.
POST /api/v1/jobs/:id/cancel
Cancel a queued or processing job.

Sessions

POST /api/v1/sessions
Create a chat session. Set the model, system prompt, and title.
POST /api/v1/sessions/:id/messages
Send a message and get the model's response. Supports text, images, files, and tool use.
GET /api/v1/sessions/:id/messages
Get message history with cursor pagination.
GET /api/v1/sessions
List sessions. Filter by model or status.
POST /api/v1/sessions/:id/compact
Summarize session history to free up context space.
POST /api/v1/sessions/:id/close
Close a session and clean up resources.

Files

POST /api/v1/files
Upload a file (PDF, DOCX, CSV, TXT, etc.). Max 100MB, up to 50 active files.
GET /api/v1/files/:id
Get file metadata.
DELETE /api/v1/files/:id
Delete an uploaded file.

Models

GET /api/v1/models
List all available models. Filter by ?category=text|image|video|voice|audio.
GET /api/v1/models/:id
Get model details including category and provider.

Account

GET /api/v1/account/credits
Check wallet balance and available credits.
GET /api/v1/account/pricing
Get per-model pricing adjusted for your tier. Filter by ?category=.
GET /api/v1/account/pricing/:modelId
Get pricing for a specific model at your tier.

Streaming API

GenX Router provides real-time token streaming via Server-Sent Events (SSE). Use the same API key as the REST API — streaming endpoints are fully compatible with OpenAI and Anthropic SDKs, so tools like Cursor, Windsurf, and Claude Code work out of the box.

Base URL: https://query.genx.sh
Streaming endpoints use /v1/... (not /api/v1/...) for SDK compatibility. They support all text models (GPT-5, Claude, Gemini, Grok). Image, video, and audio models use the async Generate API instead.

Endpoints

POST /v1/chat/completions
OpenAI Chat Completions format. Works with Cursor, Windsurf, Continue, and any OpenAI-compatible client.
POST /v1/messages
Anthropic Messages format. Works with Claude Code, Anthropic SDK, and any Anthropic-compatible client.
GET /v1/models
List available streaming models (OpenAI list format). Public — no auth required.
GET /v1/models/:id
Get a single model object by ID.

Cross-Format Routing

Any text model works with any endpoint. Send a request for claude-sonnet-4-6 to /v1/chat/completions, or gpt-5.4-turbo to /v1/messages — GenX Router translates between formats automatically.

Tool Configuration

Set up your coding tools to use GenX Router as a drop-in replacement for OpenAI or Anthropic:

Cursor / Windsurf

# In your tool settings: Base URL: https://query.genx.sh/v1 API Key: gnxk_YOUR_KEY Model: Any model from /v1/models

Claude Code

# Set environment variables: ANTHROPIC_BASE_URL=https://query.genx.sh ANTHROPIC_API_KEY=gnxk_YOUR_KEY

Reasoning & Thinking

Provider-specific parameters are passed through to the underlying model:

  • OpenAI modelsreasoning_effort ("low", "medium", "high") via /v1/chat/completions
  • Anthropic modelsthinking ({"type": "enabled", "budget_tokens": N}) via /v1/messages

Streaming Code Examples

# OpenAI format — works with any text model curl -N https://query.genx.sh/v1/chat/completions \ -H "Authorization: Bearer gnxk_YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.4-turbo", "stream": true, "messages": [{"role": "user", "content": "Explain async/await in 3 sentences."}], "max_tokens": 1000 }' # Anthropic format — works with Claude Code curl -N https://query.genx.sh/v1/messages \ -H "Authorization: Bearer gnxk_YOUR_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "stream": true, "max_tokens": 1000, "messages": [{"role": "user", "content": "Explain async/await in 3 sentences."}] }'
// OpenAI SDK — streaming with GPT-5 import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://query.genx.sh/v1", apiKey: "gnxk_YOUR_KEY", }); const stream = await client.chat.completions.create({ model: "gpt-5.4-turbo", stream: true, messages: [{ role: "user", content: "Explain async/await in 3 sentences." }], max_tokens: 1000, }); for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content || ""); } // Anthropic SDK — streaming with Claude import Anthropic from "@anthropic-ai/sdk"; const anthropic = new Anthropic({ baseURL: "https://query.genx.sh", apiKey: "gnxk_YOUR_KEY", }); const stream2 = anthropic.messages.stream({ model: "claude-sonnet-4-6", max_tokens: 1000, messages: [{ role: "user", content: "Explain async/await in 3 sentences." }], }); for await (const event of stream2) { if (event.type === "content_block_delta" && event.delta.type === "text_delta") { process.stdout.write(event.delta.text); } }
# OpenAI SDK — streaming with GPT-5 from openai import OpenAI client = OpenAI( base_url="https://query.genx.sh/v1", api_key="gnxk_YOUR_KEY", ) stream = client.chat.completions.create( model="gpt-5.4-turbo", stream=True, messages=[{"role": "user", "content": "Explain async/await in 3 sentences."}], max_tokens=1000, ) for chunk in stream: print(chunk.choices[0].delta.content or "", end="") # Anthropic SDK — streaming with Claude import anthropic client = anthropic.Anthropic( base_url="https://query.genx.sh", api_key="gnxk_YOUR_KEY", ) with client.messages.stream( model="claude-sonnet-4-6", max_tokens=1000, messages=[{"role": "user", "content": "Explain async/await in 3 sentences."}], ) as stream: for text in stream.text_stream: print(text, end="")

Billing

Streaming uses the same credit wallet as the REST API. Your balance is checked when the stream starts. Once streaming begins, the response completes fully — you're charged based on actual token usage at completion. Failed or disconnected streams are only charged for tokens consumed up to that point.

Pricing

GenX Router uses credit-based billing powered by the DashNex Credits System — credits never expire and you can use them across the entire DashNex ecosystem. New accounts start with 500 free credits.

How Billing Works

  1. Submit a job — your balance is checked to ensure you have enough credits.
  2. Job completes — the actual cost is calculated from real usage metrics and charged on completion.
  3. Job failed? No charge. You only pay for successful generations.

Each model has per-metric pricing (tokens, images, audio seconds, video seconds, etc.). Check per-model rates in the model catalog or via GET /api/v1/account/pricing for your tier-adjusted prices.

Tiers

Tiers are earned automatically based on your cumulative top-up spend. Higher tiers get better pricing and higher rate limits.

TierDiscountRate LimitConcurrency
Starter10 RPM10
Blaze5% off60 RPM25
Agent10% off200 RPM50
Operator15% off500 RPM100

Enterprise

For companies building products on top of GenX Router, the Enterprise tier removes all rate limits and provides contract-based pricing.

Enterprise accounts get a Platform Secret that unlocks a powerful sub-key system:

  • Sub-keys for your users — Programmatically create API keys scoped to individual users in your platform via the Platform API. Each key is tied to an external ID you control.
  • Per-user usage tracking — Query usage by key or user. Build your own billing, quotas, or dashboards on top of GenX Router without managing any AI provider accounts.
  • Zero-config onboarding — New users are auto-provisioned on first key creation. No manual setup, no waiting.
  • Key lifecycle management — Create, list, and revoke keys programmatically. Full control over your user base.

This means you can offer AI capabilities to your own customers — text, image, video, voice, audio — without integrating with a single provider directly. GenX Router handles the routing, billing, and infrastructure. You focus on your product.

Interested in Enterprise? Get in touch to discuss your use case.

Ready to Build?

Sign up for free and get 500 credits to start generating with 40+ AI models.